| ▲ | jdw64 7 hours ago |
| It's surprising that C++'s development trend continues. When a game or program is made with C++, it's usually nice because performance is mostly guaranteed. But if someone told me to write C++ myself, I'd cry. There's too much to memorize, and the standards are too varied. When I go to a project site for maintenance and it's a C++ project, I instantly lose energy — because it's just too difficult. I'd be happy if someone else wrote it, but it's not a language I want to write myself |
|
| ▲ | bayindirh 7 hours ago | parent | next [-] |
| Personally I don't find programming with C++ that hard. The downside is it needs a brain warm-up, and this is per project, but once that flywheel is spinning, I find it almost effortless to write code. I have to go through the same warm-up more or less for any language I work with, so it's not that different than writing Python, Go or Java for me. |
| |
| ▲ | whstl 5 hours ago | parent | next [-] | | I find C++ not hard at all when working with familiar idioms, restrictions and toolings (familiar to me). But it's hard jumping into new codebases and adjusting yourself to new patterns. Recently I did a lot of programming using C++23 Modules and it was a breeze. There's basically dozens of very nice languages inside C++. That can be a blessing or a curse. I'm anxious for Herb Sutter's CPP2/CPPFront to become a standard. | | |
| ▲ | domenicd 5 hours ago | parent | next [-] | | What type of project actually uses C++ 23 modules in real life? What kind of toolchain enables that? When I worked on Chromium, they were indefinitely in the "maybe in 5-10 years the tooling will be ready" camp. | | |
| ▲ | bluGill 3 hours ago | parent | next [-] | | The tooling people have - as of about a year ago said they are ready. Now everyone who considers themselves early adopters is using then. Most are waiting for the early adopters to figure out what the best practices are so we don't make a mess | | |
| ▲ | maccard 19 minutes ago | parent [-] | | What early adopters are using them? Because my impression is the tooling still isn’t there |
| |
| ▲ | whstl 4 hours ago | parent | prev [-] | | YC startup. Toolchain was Clang and sh. Chromium is gonna be more conservative than that for sure. |
| |
| ▲ | tialaramex 5 hours ago | parent | prev | next [-] | | In February this year Herb tweaked a test case. That was his last commit to his "CPP2 syntax experiment". Don't expect it to "become a standard". https://github.com/hsutter/cppfront/commits/main/ | | |
| ▲ | whstl 4 hours ago | parent [-] | | That's a shame! It's a lovely language. | | |
| ▲ | Mond_ 30 minutes ago | parent [-] | | Is it really, though, or is it just in comparison to C++? Tbh I never expected that experiment to go anywhere. I guess that leaves Carbon (and large scale efforts to rewrite C++ in Rust). | | |
| ▲ | whstl 10 minutes ago | parent [-] | | I personally really like the syntax and the defaults, and I like it more than the C++ alternatives. |
|
|
| |
| ▲ | avadodin 5 hours ago | parent | prev | next [-] | | Looked up what C++23 Modules were and I must say I was not let down. | |
| ▲ | drysine 3 hours ago | parent | prev [-] | | >I'm anxious for Herb Sutter's CPP2/CPPFront to become a standard. Why? It doesn't remove complexity, it (partially) hides it and makes the whole thing even more complex. | | |
| ▲ | whstl 9 minutes ago | parent [-] | | I enjoy the syntax and the defaults he picked, and it matches the way I use C++. I prefer it to all the C/C++ alternatives. |
|
| |
| ▲ | rustyhancock 5 hours ago | parent | prev | next [-] | | I agree. You don't learn or know C++ in the way you learn or know C. You never have the total language spec in mind. Much of it you will never (and for some of it should never) come across. The way I think of it C is an abstraction of the machine, so thin it's nearly transparent. C++ is an abstraction over programming paradigms, letting you pick how you think. Everything else abstracts the machine away, replacing it with a VM, runtime, or model of its own. The same way a good project has a clear model of the problem it should have a clear C++ pattern in use. | |
| ▲ | jdw64 7 hours ago | parent | prev | next [-] | | There are so many standards and idioms that it gets confusing. There are still legacy codebases out there — some codebase still use C++98 as their standard, others use C++11... And with Unreal Engine, the modern C++ standard is C++14, right? There are things like smart pointers, but some places don't even use them. I feel like there are just too many features. When I saw template metaprogramming — that new feature — I realized I have no talent for C++. | | |
| ▲ | bayindirh 7 hours ago | parent | next [-] | | I have developed things with C++98, C++11 and C++14. Every of these standards are so vast, so remembering everything (even in a single standard) is not possible. Instead of knowing everything, I first fix the standard I want or need to work with. Then I design the thing I want to build. I always design what I want to build beforehand. This takes a couple of iterations from high level to low-ish level. That last design becomes a bit language dependent. Then I select some of the core tools that I'm going to use (which kind of pointers, classes or structs, etc.) With that design in mind, I go "library shopping" both for file formats (if any) or other stuff like vectors, etc. Armed with the reference docs of these, I write my code with the toolbelt I have built for the project. Some things are hard, but they are not impossible. I find thinking like compiler helps a lot. | |
| ▲ | flohofwoe 6 hours ago | parent | prev | next [-] | | > When I saw template metaprogramming — that new feature — I realized I have no talent for C++. It's not a new feature. And tbh, compared to Typescript, C++ templates are tame ;) (but yeah, deciding when to stop digging into the template metaprogramming rabbit hole requires some common sense and sanity, too much template complexity is almost never worth the hassle) | | |
| ▲ | bregma 2 hours ago | parent [-] | | It was a new feature. Over 30 years ago now. Template metaprogramming was even featured in the ARM. |
| |
| ▲ | justin66 2 hours ago | parent | prev | next [-] | | > And with Unreal Engine, the modern C++ standard is C++14, right? Unreal Engine depends on C++20 at this point. https://dev.epicgames.com/documentation/unreal-engine/epic-c... | |
| ▲ | maccard 6 hours ago | parent | prev [-] | | This is true of any language. Python with flask vs django, with/without type hints. JavaScript with anhular and vue. The varying standards are no different to major python versions or go versions - arguably there’s even less between most versions than there is in your average go release. The differences in apps and frameworks don’t matter for day to day - std::string, Unreal’s FString and QT’s QString all are similar enough that 99.9% of the time. Metaprogramming is one of those things; you either write it or you don’t. Knowing some basics is required but the vast majority of people use a handful of pre existing things without understanding the nuances of how it works under the hood. |
| |
| ▲ | lelanthran 6 hours ago | parent | prev [-] | | > The downside is it needs a brain warm-up, and this is per project, but once that flywheel is spinning, I find it almost effortless to write code. How is that different from other languages, which don't need the brain warm-up? | | |
| ▲ | bayindirh 6 hours ago | parent [-] | | The difference, if you split hairs, that the brain warm-up takes a bit longer. Maybe a couple of hours, or a day at most. Otherwise it's not different for me. I don't feel different while writing with any other language. I guess the main reason is I always think like the computer first and translate that thinking to the programming language at hand. |
|
|
|
| ▲ | flohofwoe 6 hours ago | parent | prev | next [-] |
| For games, C++ becomes a much simpler language since game code bases usually ignore the C++ stdlib (at least mostly, and for good reasons, e.g. see [0]). And without the stdlib C++ is actually kinda-sorta okay-ish. Related, the main problem with the C++ ecosystem is that everybody carves out their own language subset, so it's not one ecosystem but many ecosystems with contradicting styles and language/stdlib subsets. This makes code reuse via libraries much harder than it should be. [0] https://hftuniversity.com/post/the-c-standard-library-has-be... |
| |
| ▲ | herr_shield 6 hours ago | parent | next [-] | | I fully agree. In my personal project, I ended up using the STL to get off the ground, but in the end I replaced pretty much everything with custom-written code. Once you get rid of the STL, compile times get so much better. With modern c++23 features, templates actually become really convenient to write, and at the core there is a really useful and pleasant to use language. I try to avoid c++ libraries and instead rely on c-style APIs. Usually the c++ style libraries force you into using the STL, which comes with a heavy tax on compile times, without much benefit in comfort of use. | | |
| ▲ | GnarfGnarf 4 hours ago | parent [-] | | What, you rewrote std::deque? Whew! | | |
| ▲ | spwa4 3 hours ago | parent [-] | | Rewriting at least std::vector was a standard way to prep for a Google interview. And std::map if you wanted bonus points or a level up. Also, really interesting to do. |
|
| |
| ▲ | samiv 6 hours ago | parent | prev | next [-] | | If you don't use the STL you end up re-implementing it yourself. Usually poorly. | | |
| ▲ | flohofwoe 6 hours ago | parent | next [-] | | > Usually poorly. On the contrary. You can focus exactly on the features the higher level game code needs. The C++ stdlib is (for the most part) poorly designed, usually poorly implemented, the main reason for slow build times, and its complexity explodes because it needs to consider all edge cases that most code bases don't ever trigger. A specialized dynamic array class in a few hundred lines (at most!) and with just the required features is much more useful than the 20kloc monster that's pulled in with `#include <vector>` and which doesn't even do bounds checking in the 'idiomatic' usage. | | |
| ▲ | Chaosvex 6 hours ago | parent | next [-] | | Saying it doesn't even do bounds checking (in release builds) is to miss one of the major points of C++ - not paying for what you don't need. It's not a mistake, it's a feature. You complain about it not being suitable for game development in one comment but then expect bounds checking in release builds? You're sitting in multiple lanes at the same time. NIH implementations are usually grossly inferior because as it turns out, it's quite hard to get it right and those edge-cases aren't important until you start getting bitten by them when you'd rather be shipping features. | | |
| ▲ | flohofwoe 6 hours ago | parent | next [-] | | > bounds checking in release builds Bounds checking overhead is negligible for all but the absolutely hottest code paths (fwiw we shipped active asserts, including bounds checking asserts in all the PC games I was involved with - carefully monitoring the overhead of course). The main reason to not use the stdlib isn't so much about squeezing out the last bit of performance, but about control of what actually happens under the hood (and also compilation times). The overall runtime cost of all those active asserts (not just the range checks, everything) was somewhere in the 2..3% range, which is fine when budgeted for upfront. | | |
| ▲ | Chaosvex 5 hours ago | parent [-] | | That's your opinion, others won't agree and would much rather not pay the price at all. | | |
| ▲ | imtringued 4 hours ago | parent [-] | | Those asserts probably saved a lot of development costs and increased the robustness of the software, which is worth a lot more than a few percent on a benchmark. I personally am more conservative on those things. I'll pick the fastest thing that is reliable. | | |
| ▲ | bluGill 3 hours ago | parent [-] | | Are we talking about games or medical devices here? I expect different things from them. If a medical device needs to turn off bounds checking to get results I'm concerned enough to not want to let anyone use it. If a game can get a slight performance improvement I'm all for it, who cares if it crashes, it is just a game. |
|
|
| |
| ▲ | criddell an hour ago | parent | prev [-] | | Sometimes there are ways of getting runtime bounds checking. For example, both of these return the 3rd element of a std::vector: auto val1 = vec[3]; // no bounds checking
auto val2 = vec.at(3); // bounds checking
| | |
| ▲ | Mond_ 27 minutes ago | parent [-] | | Yes, with the trade-off of essentially requiring exceptions, which are also banned in some codebases. |
|
| |
| ▲ | samiv 6 hours ago | parent | prev | next [-] | | Yes I don't disagree that sometimes a specific container or a data structure is great for the problem. Problem is that most of the game code and related code (so tooling,editor, auxiliary engine code) does need a typical STL type functionality and then when the org has "omg no STL" blanket rule someone ends up implementing STL and that's almost always worse than the STL that ships with the tool chain. Even worse..it'll be missing features and data structures and then people have to write sub-optimal code to work around it's limitations. | | |
| ▲ | bluGill 3 hours ago | parent [-] | | Top tier game orgs are often large enough to have good people write their own library with the correct compromises. They also tend to need micro performance improvements enough to be worth it. Most of the rest of us STL is good enough. |
| |
| ▲ | demorro 6 hours ago | parent | prev | next [-] | | I find it hard to agree that the stdlib is poorly designed and implemented. In my entire career it has pretty much worked entirely to spec. Yes, it can exhibit non-optimal performance, and in some specific cases (regex's especially), extremely poor performance, but that's not the same as being poorly designed and implemented, especially given the breadth of the thing. | |
| ▲ | pjmlp 5 hours ago | parent | prev [-] | | Which is why one of the security measures in C++26 is to make bounds checking idiomatic, finally. |
| |
| ▲ | mixolydianagain 6 hours ago | parent | prev | next [-] | | some of the STL is easy to improve on. For example, std::unordered_map performs poorly due to pointer stability requirements in the standard. Most performance sensitive C++ codebases will use something like abseil's hash maps instead. | | |
| ▲ | spacechild1 5 hours ago | parent [-] | | Just a heads-up: if you're already using boost, boost::unordered now has open addressing containers (unordered_flat_map and unordered_flat_map) and they are among the fastest. | | |
| ▲ | ahartmetz 3 hours ago | parent [-] | | Seconding this - boost::unordered_flat_map was only added in December 2022 and many people don't know about it yet. |
|
| |
| ▲ | VoidWarranty 6 hours ago | parent | prev | next [-] | | Which is worse? std's mess or one you control? I'd take any random game engine's STL over std any day. | |
| ▲ | leonidasrup 6 hours ago | parent | prev [-] | | C+ Standard Template Library is the best designed part of C++ library. It was designed by Alexander Stepanov. https://en.wikipedia.org/wiki/Alexander_Stepanov | | |
| ▲ | tialaramex 5 hours ago | parent | next [-] | | So, a few things (aside from the whole nomenclature argument already in another reply) 1. Stepanov's generic programming is a good idea. Every language you've seen with "generics" that's his idea, to the extent "The STL" is generic programming, everybody agreed it's a good idea. 2. But the STL is very old now, so while the idea is good, this is one of the oldest (Stepanov had tried this in other languages before C++) implementations and so other implementations are often better, because they've learned from experience 3. As well as pretty good generic algorithms, the STL also provides a lot of container types (what Rust would call collection types) and these vary not between "excellent" and "mediocre" but between "mediocre" and "inexplicably terrifying". The most charitable explanation is that they're just intended for teaching. If you teach DS&A to a Computer Science class you want the Extrusive Doubly Linked List to teach in class. If you write software you almost certainly never need this type, but it's front an centre in the C++ STL. There's a single "I guess I would use this" container type, std::vector. It has an insane special case for bool, because WG21 are idiots, but it's otherwise a good enough growable array type and it's not worth building your own instead given the constraints. Everything else is silly, or bad, or both. std::unordered_map feels like a hash table I made in class in the mid 1990s, but it's actually the provided standard hash table container in C++ 11 onwards. std::list is just that extrusive linked list for some insane reason. The Microsoft standard library maintainer STL could not offer me any justification for what std::deque is actually supposed to be for. | | |
| ▲ | bernds74 4 hours ago | parent | next [-] | | I would argue that even the basic concept behind STL is misguided. The rationale I often see is "you only need N algorithms for M container type, instead of N*M". This ignores the fact that algorithms and data structures are not independent of each other, and also that most of the time these days you're operating on vectors, so M ~= 1. Case in point: list::sort. You don't want to try running quicksort on a linked list. Or remove_if: great we've abstracted the difficult task of removing things without erasing them, except we can't do it on maps. (C++20 seems to add an erase_if, apparently admitting that the two-step remove/erase is silly). Then there's the fact that C++ iterators are basically pointers into the data structure, where for vectors (your common case) you'd do much better with index/container pairs, both for stability and bounds checking. | |
| ▲ | ahartmetz 3 hours ago | parent | prev | next [-] | | AFAIK, std::map is also OK for what it is: an ordered, node-based (tree) map. These are (almost) always slower than hash tables. Of course, std::unordered_map, the std hash table, sucks because of unforced errors. For that, there is boost::unordered_flat_map. | |
| ▲ | einpoklum 4 hours ago | parent | prev [-] | | > There's a single "I guess I would use this" container type, std::vector. About that one... I would claim that in a majority of cases where an std::vector is used, what the author really wanted was a similar type, but whose size and capacity are fixed on construction and never change. The standard C++ library does not offer such a type - so people use vector because it's handy. Agree with your takes on most of the containers. I also dislike how optionals are never used with containers as they were standardized later (and even then, problematically w.r.t. references). Thus, for example, if I lookup an object in a map of T's, the result should IMNSHO be an optional reference to a T. | | |
| ▲ | Joker_vD 2 hours ago | parent | next [-] | | > a similar type, but whose size and capacity are fixed on construction and never change. There is std::array for that. Also, for a type with fixed capacity but variable (up to that capacity) size, we're getting std::inplace_vector soon™. | | |
| ▲ | einpoklum an hour ago | parent [-] | | std::array requires the size to be set at compile-time, while I was talking about arrays whose size is determined at construction-time. Of course std::array is also quite the useful class :-) |
| |
| ▲ | afdbcreid 4 hours ago | parent | prev [-] | | What operations could such frozen vector offer that std::vector does not? If there are none, it doesn't need a separate data structure. | | |
| ▲ | einpoklum 3 hours ago | parent [-] | | Oh, on the contrary, the separate structure is needed and useful because it offers _less_, not more: * APIs/function signatures explain more clearly what are the intended uses of the structure that's passed. * More potential for compiler optimization * Some potential for having these on the stack (if the compiler deduces the size already at compile-time) * More convenient for static analysis * No plethora of confusing constructors (including the infernal two-element ctors which can be misinterpreted super-easily) etc. |
|
|
| |
| ▲ | einpoklum 4 hours ago | parent | prev | next [-] | | It has some very useful principles, but also some super-annoying gaffes and mis-design aspects. One example: Allocators. What a mess! Or the fact that if a map lookup fails, an exception is thrown. I can't count the times I've had some app just bail out on me with an at() exception, because the author neglected to handle it (and the map/unordered map interface did not force them to). That does not detract from Stepanov's important work. | | |
| ▲ | ahartmetz 3 hours ago | parent [-] | | The kind of programmer who don't check (or think through so that they can't fail) their map lookups is also the kind of programmer who don't bother with const. What a non-const unchecked map lookup gives you is a default-constructed value that has just been inserted for the only reason that operator[] returns a reference, which must "point" to something. That's bad and can be confusing, but it doesn't crash. I see that problem much more often than crashes due to unchecked map lookups in production, which are very rare for me. Less than once a year. |
| |
| ▲ | pjmlp 5 hours ago | parent | prev [-] | | Nowadays also used by many of us (wrongly) to refer to the overall C++ standard library, instead of what was inherited from C. |
|
| |
| ▲ | jibal 4 hours ago | parent | prev | next [-] | | Your citation refers to the register keyword and trigraphs, among other language features -- the author seems to have forgotten his own point, among a number of other inconsistencies and contradictions, and at times seems to go out of his way to come across as a jerk, e.g., "This is what fifteen years of standards work on an eight-letter keyword looks like". People love to rag on the standards committee. I was on X3J11, the C Language Standards Committee, in 1989 ... in fact, due to alphabetical order I was the first person on the planet to vote to approve the C language standard -- the one that first standardized register and trigraphs. Standards work is hard and everyone hates you for it. | | |
| ▲ | flohofwoe 2 hours ago | parent [-] | | The C Committee is fine and doing great work! The C++ Committee could actually learn a thing or two from how things are done on the C side. |
| |
| ▲ | Chaosvex 6 hours ago | parent | prev [-] | | That article probably isn't the best source to cite. You can look at the discussions on it elsewhere, although I'd just dismiss it as slop. The standard library is mostly fine to use unless you have specific needs. The bit about libraries is nonsense, sorry. | | |
| ▲ | flohofwoe 6 hours ago | parent [-] | | The article might be slop, but the problems described in it are definitely real ;) | | |
| ▲ | Chaosvex 6 hours ago | parent [-] | | Grossly exaggerated or misunderstood in many cases.
Some of their arguments are just flat-out wrong. I mean, why are they blaming the standard library for inherent properties of linked lists? Yeah, you don't want to use them without good reason. That's just called picking the right data structure for the job, not a flaw with the standard library. Some of the other choices were tradeoffs between performance and usability. The standard maps have stable iterators, whereas third-party implementations almost never do because you can write faster implementations if you're willing to live without those guarantees. Was it the right choice in hindsight? Maybe, maybe not. I'd personally like to see a namespaced versioned standard library but like that's ever going to happen | | |
| ▲ | flohofwoe 6 hours ago | parent [-] | | As I understood the article, the main critique is that the stdlib has no concept of deprecation and breaking backward compatibility. E.g. the C++ committee is quick to add badly designed features to the stdlib but then can't roll them back when people actually realize that those new features are useless for most real-world code. | | |
| ▲ | domenicd 5 hours ago | parent | next [-] | | I'm not sure this is a winnable game for programming languages. - Keep a small stdlib, like JavaScript (especially earlier JavaScript): everyone complains about missing features, warring communities form around jQuery promises vs. Promises/A+ vs. callbacks, supply chain attacks, left-pad/is-even dependencies, etc. - Grow a big stdlib while keeping backward compatibility, like C++: lots of cruft left around that must never be used, sitting next to newer stuff with similar names. People complain about the bloat. - Grow a big stdlib and then break backward compatibility, like Python 2 -> 3: everyone is sad, the ecosystem churns for years. I admit there are probably better and worse versions of each strategy, e.g., it seems to me like JavaScript's slow-but-steady accretion of primitives over time has gone OK, and it seems like apart from Python 2 -> 3 some of the PEPs I see for deprecations and replacements are reasonable. But no language has ever hit on a strategy that everyone loves, as far as I can tell. | |
| ▲ | Chaosvex 6 hours ago | parent | prev | next [-] | | Yet they spend a lot of time complaining about features that were deprecated or removed. | |
| ▲ | zabzonk 5 hours ago | parent | prev [-] | | Badly designed things get replaced. For example unique_ptr replaced auto_ptr. I'm not sure if the language standard actually supports the term "deprecation" though. Edit: Also not sure what can possibly be downvoted here. | | |
| ▲ | 13 minutes ago | parent | next [-] | | [deleted] | |
| ▲ | bregma 2 hours ago | parent | prev | next [-] | | ISO/IEC 14882 contains many uses of the word "deprecation", including all the sections of Appendix D that explicitly lists all of the deprecated and removed features of the language and library. | |
| ▲ | johannes1234321 2 hours ago | parent | prev [-] | | auto_ptr is an exception. Not the rule. Regular expressions in C++ are an example "everybody" advises against using, but it's still there. vector<bool> will stay forever and so on. |
|
|
|
|
|
|
|
| ▲ | samiv 6 hours ago | parent | prev | next [-] |
| You're right that C++ has a lot of features. But like mentioned elsewhere most projects define their own conventions and the subset of features that they use. Also the nice thing about having a large set of features is that C,++ allows you to write very nice abstractions (or not) at both very low or at very high level. In other words you can be very low level with online ASM and bit operations and bit and direct memory manipulation or very high level almost like a script language. Whatever the problem domain needs C++ has got you covered. |
|
| ▲ | zerr 6 hours ago | parent | prev | next [-] |
| You can be pretty productive even with 70% of the language :) It is a common misconception that C++ is suitable only for game engines and similar domains. It is perfectly fine for applications domain as well. As a side note, regarding your profile info, unless you are based in North Korea, please at least add one 0 to your rate. You'll get more long-term and high-quality clientele. |
| |
| ▲ | fc417fc802 6 hours ago | parent | next [-] | | > You can be pretty productive even with 70% of the language Or even far less than that. I like to use it as C with lambdas and namespaces. Sprinkle in metaprogramming as needed. Even just not having to remember to call cleanup code thanks to dtors would alone be enough to sell me on it. | |
| ▲ | pjmlp 5 hours ago | parent | prev | next [-] | | Only by people that started working in Web during the 2000's. Back in the 90's, it was the main business language alongside Smalltalk, Delphi and VB. Hence the plethora of C++ frameworks to chose from, sadly most dead since .NET and Java took over most of the use cases. | |
| ▲ | jdw64 6 hours ago | parent | prev [-] | | Honestly, I don't expect to find clients here. Fundamentally, you have to trust me to give me work. The amount of money doesn't really matter much to me. | | |
| ▲ | zerr 6 hours ago | parent [-] | | I mean, the lower rates arouse suspicions. The higher you value your work, the more trustworthy you appear to clients. | | |
| ▲ | jdw64 5 hours ago | parent [-] | | Thank you for the advice. I'll think about it. Or maybe just remove the price altogether. |
|
|
|
|
| ▲ | pjmlp 5 hours ago | parent | prev | next [-] |
| Not really, despite all its warts, it is exactly because of them that many reach out to C++. Many of us don't like C, it was already too little and too unsafe, when the first C++ compilers started to hit the market in early 1990's, hence why all desktop OSes moved into C++ for their frameworks. The return to C has caused by the rise of FOSS, UNIX winning the server room, and early GNU coding standards to use only C as main compiled language. Additionally as many other programming language ecosystems have discovered, it is easy to beat C++ in version 1.0, and eventually all of them grow to get the complexity of their own. I reach for C++, because the language runtimes, compiler tooling, and GPGPU frameworks I care about are partially written in C++, and I am not in the place to be writing new ecosystems myself. |
| |
| ▲ | bregma an hour ago | parent [-] | | I work maintaining the toolchain and language runtimes for a commercial safety-certified embedded operating system. I am deeply familiar with C and C++ because I live it and breathe it every day and have done so for over 40 years. Most of our customers use C, probably for historic reasons but also because it is much much easier to reason about and that becomes very important when auditing for functional safety certification. If someone's life depends on your software, you really want to be able to reason about its correctness because orange jumpsuits enhance no one's complexion. Many of customers are now using C++. From the problems they have reported, well, they just shouldn't. It's not that it is a bad language (it isn't) or that it is inherently unsafe (it really isn't: exceptions are safer than propagating return values as long as you use them in exception conditions, because not catching one will return you to a designed safe state very quickly, and RAII is the best thing since sliced cheese). It's that cutting and pasting from Stack Overflow, and now vibe coding, makes for massive codebases that are next to impossible to reason about. I now see a lot of problems from customers where my first reaction is "don't write code like that" and "you can write bad JavaScript code in any language, can't you?". While it butters my bread and I enjoy the language, I really recommend against using C++ for safety-certified embedded software. Stick to C. |
|
|
| ▲ | tenderfault 6 hours ago | parent | prev | next [-] |
| funny, I think the same about rust. |
| |
| ▲ | tialaramex 4 hours ago | parent [-] | | (Safe) Rust is a lot better about the "Pit of Success" design than C++ There are fundamental technical choices to deliver that, but also ergonomic things like notice Rust's []::sort is a stable sort, whereas C++ std::sort is an unstable sort. If you don't know about sort stability in Rust what you wrote works and in C++ you get a nasty surprise. | | |
| ▲ | bregma an hour ago | parent [-] | | C++ has std::sort() and std::stable_sort(). You should write what you mean, and you should know and understand your tools. Blaming the tool for your ignorance marks you as significantly less than an artisan. | | |
| ▲ | Mond_ 22 minutes ago | parent | next [-] | | Sort specifically is kind of a weird example, but C++ is full of awful naming. std::map (which is not a hash map, which is what most people would expect), std::move (which doesn't move), std::vector (which is not a vector), and std::vector<bool> (which is not even a std::vector). | |
| ▲ | tialaramex an hour ago | parent | prev [-] | | Sure, both languages offer both generic comparison sorts†. But the defaults matter and as always in C++ the defaults are wrong, here it's reflected in naming. That's not actionable information, except in the sense that the correct action is "don't use C++". Because sure, I know about sort stability, and I know about pointer provenance, and about memory ordering, but there might be any number of things I do not know and unfortunately in C++ "you should know and understand" absolutely everything at all times, which is not viable. † The C++ standard library sorts are both much slower than in Rust, but hey, they're also both less safe so you're really getting the worst of both worlds | | |
| ▲ | patrick451 10 minutes ago | parent [-] | | > Sure, both languages offer both generic comparison sorts†. But the defaults matter and as always in C++ the defaults are wrong, here it's reflected in naming. Why, exactly, is the c++ std::sort "wrong"? There are tradeoffs both ways. You happen to prefer stable sorting to speed, but that is a preference not an objective fact. |
|
|
|
|
|
| ▲ | nnevatie 7 hours ago | parent | prev | next [-] |
| The language is fine, mostly, nowadays. The ecosystem isn't fine - just to get a project going requires picking a non-trivial set of tools and approaches, none of which the C++ standard enforces or guides to. For example, will you manage dependencies via packages? If so, with what? What will you use for building your project? The list goes on and on. |
| |
| ▲ | Davidbrcz 6 hours ago | parent | next [-] | | No it's not. The language keeps growing, with - new features overlapping old features from previous standards without replacing them or deprecating them (function::copyable_function vs std::function, std::less<> key for transparent lookup in maps) - new features not usable by the layman (coroutines ...) - Cryptic syntax (reflection...) - Stuff you are told not to use because of performance reason and that cant be fixed because of ABI (regex) - Compile errors that are 1km long (no, concepts are not helping here, the 'nicer' message is still buried into a hot pile of template instantiation callstack). | | |
| ▲ | bayindirh 5 hours ago | parent | next [-] | | I wonder how many programming languages would be able to devoid of all or some of these problems when they are 40 years old. It's easy to compare new and old languages, and saying older languages are wrinkly. Let's see how other shiny programming languages look like when they are 40 years old. | | |
| ▲ | bregma an hour ago | parent | next [-] | | There are two kinds of programming languages: the kind everyone complains about and the kind nobody uses. | |
| ▲ | Davidbrcz 4 hours ago | parent | prev [-] | | Python, Java, Lua, Ruby are ~30 years old, Ada being as old as C++. Sure, none is perfect and they have cruft and warts, but they are not such a mess as C++ is. |
| |
| ▲ | pjmlp 5 hours ago | parent | prev [-] | | So a bit like Python or any other language of similar age. | | |
| ▲ | whstl 4 hours ago | parent | next [-] | | Working occasionally with modern Python helped me love and respect C++ even more. | |
| ▲ | bregma an hour ago | parent | prev [-] | | Python3 is what, 15 years old? |
|
| |
| ▲ | bayindirh 7 hours ago | parent | prev [-] | | I personally find the lack of native package management in C++ as a blessing. Go, Python, Rust has it, and this always causes pulling in infinite number of packages for any trivial operation. sudo-rs was pulling in 1M+ LOC as its dependency chain at one point. I believe they removed the biggest offenders, but I didn't check it recently. | | |
| ▲ | nnevatie 6 hours ago | parent [-] | | That's one way to look at it, certainly. There are several OK options in that space, e.g. Conan (2) and vcpkg. |
|
|
|
| ▲ | 6 hours ago | parent | prev | next [-] |
| [deleted] |
|
| ▲ | logicchains 7 hours ago | parent | prev [-] |
| >There's too much to memorize, and the standards are too varied. When I go to a project site for maintenance and it's a C++ project, I instantly lose energy — because it's just too difficult. If you'd already been using it for 10+ years you wouldn't feel that way, because you'd already have memorized a lot of it. |
| |
| ▲ | Davidbrcz 6 hours ago | parent [-] | | Except the language keeps growing, with - new features overlapping old features previous standards without replacing them or deprecating them.
- new features not usable by the layman
- ... See function::copyable_function vs std::function, modules, coroutines, Reflection syntax is cryptic at best, ... | | |
| ▲ | VoidWarranty 6 hours ago | parent [-] | | You don't have to use them. There's a handful of nice to haves in modern releases but its totally fine and sane to just ignore whatever the committee is distracted by at the moment. Hell, if you wait long enough, they'll just deprecate it before you can care to bother. | | |
| ▲ | Davidbrcz 4 hours ago | parent [-] | | And that's the usual fallacy (just ignore the bad stuff). But if you work with C++ in professional context, you will encounter it somewhere (library, teamate's PR, legacy code, LLM output, book / blog / conference ...). | You actually need to know the bad stuff to be able to judge it and discard it. |
|
|
|