• 0 Posts
  • 16 Comments
Joined 1 year ago
cake
Cake day: June 11th, 2023

help-circle

  • There were breaking changes between C and C++ (and some divergent evolution since the initial split) as well as breaking changes between different releases of C++ itself. I am not saying these never happened, but the powers that be controlling the standard have worked hard to minimize these for better or worse.

    If I took one of my earliest ANSI C programs from the 80s and ran it through a C++23 compiler, I would probably need to remove a bunch of register statements and maybe check if an assumption of 16-bit int is going to land me in some trouble, but otherwise, I think it would build as long as it’s not linking in any 3rd party libraries.


  • I think the thing with C++ is they have tried to maintain backward compatibility from Day 1. You can take a C++ program from the 80s (or heck, even a straight up C program), and there’s a good chance it will compile as-is, which is rather astonishing considering modern C++ feels like a different language.

    But I think this is what leads to a lot of the complexity as it stands? By contrast, I started Python in the Python 2 era, and when they switched to 3, I was like “Wow, did they just break hello world?” It’s a different philosophy and has its trade-offs. By reinventing itself, it can get rid of the legacy cruft that never worked well or required hacky workarounds, but old code will not simply run under the new interpreter. You have to hope your migration tools are up to the task.


  • I haven’t done so personally. A lot of my old activity had to do with helping people with programming questions, so if it’s still useful to someone on occasion, I don’t feel inclined to remove it.

    I left reddit a little over a year ago now, and I don’t really care about what goes on over there. I made my statement of displeasure by simply ending all activity on the platform. I figure whatever legacy I left will eventually descend into irrelevance without my having to physically delete it all. At this point, that just sounds like work.


  • I started in C and switch to C++. It’s easy to think that the latter sort of picked up where the former left off, and that since the advent of C++11, it’s unfathomably further ahead. But C continues to develop and occasionally gets some new feature of its own. One example I can think of is the restrict key word that allows for certain optimizations. Afaik it’s not included in the C++ standard to date, though most compilers support it some non-standard way because of its usefulness. (With Rust, the language design itself obviates the need for such a key word, which is pretty cool.)

    Another feature added to C was the ability to initialize a struct with something like FooBar fb = {.foo=1, .bar=2};. I’ve seen modern C code that gives you something close to key word args like in Python using structs. As of C++20, they sort of added this but with the restriction that the named fields have to come in the same order as they were originally defined in the struct, which is a bit annoying.

    Over all though, C++ is way ahead of C in almost every respect.

    If you want to see something really trippy, though, have a look at all the crazy stuff that’s happened to FORTRAN. Yes, it’s still around and had a major revision in 2018.




  • tunetardis@lemmy.catoProgrammer Humor@lemmy.mlTrue Story
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    6 months ago

    There is an issue with templated code where the implementation does have to be in the header as well, though that is not the case here. C++20 introduced modules which I guess were meant to sort out this mess, but it has been a rocky road getting them to be supported by compilers.





  • 100g * 9.832m²/s

    That should be 100g * 9.832m/s², or better yet 0.1kg * 9.832m/s² to get a number in newtons (N).

    From a high school physics perspective, holding a 100g object steady for any length of time does no work, since work is force applied over a distance, measured in joules (J). What you do have is gravitational potential energy. Potential energy is the ability to do work, also measured in joules. Once you release the object, then you actually start getting numbers for work and power.

    Power, measured in watts (W), is work done per unit time. So 10W/hr would be (10J/s)/hr. I guess that would be the rate of change of power consumption, if that were useful to you?

    In theory, energy and work should be measured in joules. Simple as that. But this unit of kwh (kilowatt∙hour) has come into vogue, presumably because that’s what power utilities show on the meter outside your house? 1 kW∙hr = 1 kJ/s∙hr ∙ (1000J / kJ) * (3600s / hr) = 3.6MJ. So now we’re back from power to energy consumption.





  • #2 is certainly food for thought. So the idea is that from a journalistic fact-checking point of view, it is more important to convey the information exactly as it was presented than to verify its accuracy?

    This would explain why science/engineering-based articles are so commonly inaccurate or missing in critical details. The journalist can fall back on saying “I have a recording of an interview with the expert after we downed a few pints at the pub, and I’m just parroting back what he said. Don’t shoot the messenger!”