4 ms·
At someone who professionally works with relatively modern C++ (eg: C++14/17) and originally learned C++98, it's not as difficult once you get into the headspac
by danbolt 8y ago
At someone who professionally works with relatively modern C++ (eg: C++14/17) and originally learned C++98, it's not as difficult once you get into the headspace of it.
I'd definitely prefer writing in OCaml every day if I could, but I can understand why a lot of C++ is the way it is, and having the newer features is an improvement on the day-to-day.
- notacoward 8y ago> it's not as difficult once you get into the headspace of it. The same could be said of APL, PHP, or Brainfuck. Having to get into the headspace of C++ is one of the language's weaknesses. A true high-level language doesn't force programmers to spend half their time thinking about how the compiler internals deal with lvalues vs. rvalues, move semantics, decision trees for choosing which promotion or operator overload to do, and so on ad nauseam. Compilers are supposed to be assistants, there to relieve programmers of some drudgery, but C++ compilers are always like malicious assistants determined to do the opposite whenever they can. It's often more work getting them to do the right thing than to do it yourself in Plain Old C - which is what I'd rather do if I can't use a better high-level language than C++.
- danbolt 8y agoI agree that the act of submerging oneself into C++ is really a frustration about the language. It's a lot like using APL or Brainfuck as you mention and getting into gear. Still, I wouldn't say that C++ is a "true high-level language" or tries to be based on the reasons you mention. It's purpose is wide-ranging, but being closer to the metal than something like Ruby, C#, or Julia. And regardless, I think there are a lot of contexts where C++'s features can give productivity benefits over the time spent working through the hard spots. That's going to be pretty subjective though. Based on what you mention though, I'd encourage you to use "Plain Old C" (ANSI, C99, or C11?) if it helps you be more productive. I can imagine with more and more languages fitting the that semi low-level space (eg: Rust and Zig) coming on the scene, there's a lot more opportunity to find the right tool than ever before.
- notacoward 8y agoI've been writing Plain Old C for ~25 years, and only within the past year switched to C++ because that's the language of the project I'm working on. So I get to work on interesting problems in a domain I care about, and the language is the price I pay. Rust or Zig would certainly be preferable, as would a half dozen other languages. Still, it could be worse. Apparently PHP is still a thing. ;)
- v_lisivka 8y agoYou can mix Rust and C++. I use mainly Rust on my project, while other developers are using C&C++.
- dmix 8y agoSounds like the perfect recipe for programmer ‘busy work’ where you obsess over how it’s written vs accomplishing the goal (writing software people use). JavaScript does this with the endless development tooling options and configurations. So it’s not limited to the language but I see adding to the mental load of a programmer - while they are programming - to be a far worse issue. Context switching is hard enough without all that.
- danbolt 8y agoYou're touching on a really interesting point that I think both C++ and JavaScript have in common. Their specifications are very general-purpose (eg: ECMAScript, ISOC++) and generally decorated with a specific runtimes and standard libraries provided by another party (eg: browser, nodejs, host OS, bare metal, etc.) and often a few different build systems (eg: webpack, gulp, makefiles, CMake, MSVC, etc.). There's also a lot of oppurtunities to "just include" libraries like Boost or an npm dependency. I feel like Rust (eg: `cargo build`) or Ruby gems provide a very different, standardized experienced compared to the two.
- paulddraper 8y ago> A true high-level language I doubt you'll find many people who are would say "C++ is intended to be a true high-level language".
- notacoward 8y agoThe whole point of C++ from day one was to add objects and classes which are supposed to be higher-level than C's structures and functions. Perhaps even more to the point, most people talk about "modern C++" as something different and higher-level even than day-one C++. I'm even inclined to agree. Collections and RAII and lambdas do provide higher levels of abstraction. They just still fall well short of what other languages do in terms of letting programmers focus on their domain-specific problems instead of low-level mechanisms.
- paulddraper 8y agoIDK how coarse the classification of "high-level languages" is, but there's just no way that C++ is even playing the same sport as Python/Ruby/JavaScript.
- notacoward 8y agoI think we're kind of agreeing. Proponents like to portray C++ as a high-level language. That's why they insist on using it instead of C. "No more manual memory management" they say, except that having to manage the compiler's handling of copies and scope exits is every bit as bad. "No more dangerous bare pointers" except that null-pointer exceptions occur just as often in C++ code as in C. That's why I distinguished it from real higher-level languages at the start. Anyone who has worked in such knows C++ doesn't meet that standard, but its proponents make the claim anyway.
- paulddraper 8y agoWe are agreeing, except my statement "I doubt you'll find many people who are would say 'C++ is intended to be a true high-level language'". If that is actually how C++ is being sold that is indeed wrong. Same if that's how Rust were hypothetically being sold. Both make you think really hard about ownership for purposes of faster memory management. They're not "true high-level lanaguages". They are systems languages with zero-cost abstractions where possible.