• forkDestroyer@infosec.pub
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 day ago

    Isn’t C++ built on top of C and able to do everything C can and then some? It’s been a while since I’ve coded in it but I remember that being a kind of neat feature in C++. (I’m not searching it to confirm - just chatting about it)

    • Mniot@programming.dev
      link
      fedilink
      English
      arrow-up
      7
      ·
      24 hours ago

      All C code can be compiled with the C++ compiler, though there’s some nuance (if you don’t mark the C code as C, it behaves slightly differently which could mean it doesn’t work).

      C++ adds a bunch of language features (object-oriented programming and templates are two massive ones). This can make it easier to describe a concept in C++ than in C. But it also enables a lot of unneeded complexity (if C++ wasn’t the best fit, or if the programmers aren’t excellent) and the compiler is slower because of all the extra stuff. And the resulting binaries are much bigger. And it’s harder to port the C++ compiler to other platforms. There’s still plenty of situations where it makes more sense to use C over C++.

      • forkDestroyer@infosec.pub
        link
        fedilink
        English
        arrow-up
        1
        ·
        12 hours ago

        Good points! It’s been a while since I touched either - my current job is mainly webdeb/fullstacky crap and I haven’t touched c/cpp for years. Miss it though.