110 ms·
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. Bu
by jdw64 5mo 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
- tenderfault 5mo agofunny, I think the same about rust.
- tialaramex 5mo ago(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 5mo agoC++ 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.
- tialaramex 5mo agoSure, 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 5mo ago> 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.
- tialaramex 5mo ago> Why, exactly, is the c++ std::sort "wrong"? It's silently an unstable sort, which is surprising, and then to add insult to injury it's also slower. Yeah, I know, the C++ unstable sort is so slow it's slower than Rust's stable sort. YMMV for input types, sizes etc but generally that's what the numbers look like and though it's not universal it's actually quite common. "I bet the C++ is faster" is the wrong instinct, sometimes by a large margin.
- bregma 5mo agoSo C++ is "wrong" because it doesn't work like something that came along 40 years later and you used first? The problem does not appear to be in C++.
- tialaramex 5mo agoNo? One of the giveaways of how unserious such responses are is that I spent many years getting paid to write C. The home where I'm writing this was bought† with money made writing C years ago. Rust wasn't even a twinkle in Graydon's eye when I started that job, let alone when I first wrote C last century. The choice to provide the unstable sort and then add a stable sort as an afterthought smells of the New Jersey approach to me. It was easier to do this, and too bad for the users, they weren't the priority. It's the wrong choice because if you don't know about sort stability this outcome is surprising, so this means that although a beginner probably thinks they know what "sorting" means they actually mustn't use the sorting APIs in such a language until they've learned extra material. † For cash, I don't like to owe people money, including having a mortgage
- Mond_ 5mo agoSort 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).
- bayindirh 5mo agoPersonally 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.
- jdw64 5mo agoThere 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 5mo agoI 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 5mo ago> 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)
- nnevatie 5mo agoThe 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.
- bayindirh 5mo agoI 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 5mo agoThat's one way to look at it, certainly. There are several OK options in that space, e.g. Conan (2) and vcpkg.
- Davidbrcz 5mo agoNo 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 5mo agoI 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.
- logicchains 5mo ago>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 5mo agoExcept 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 5mo agoYou 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 5mo agoAnd 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.
- VoidWarranty 5mo agoWe're talking about different things. Im talking about your own personal coding. You dont have to use the new things. You dont have to know them to decide to discard them. In fact, the criteria to discard something is to not know it. You generally shouldn't be using things you dont know anyway. The fact that other people use things you do not know is not a reason to stress out about the dumb pace and direction c++ is moving in. It is possible to enjoy a life free from fomo about the c++ standards goalposts.
- zerr 5mo agoYou 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.
- jdw64 5mo agoHonestly, 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.
- fc417fc802 5mo ago> 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.
- CupricTea 5mo agoI once wrote a pure C project years back that made heavy use of complex numbers and 2D/3D vector math. At one point I got so fed up debugging my expressions under an endless parentheses-hell of `vadd(vmul(vadd(...), vadd(vmul(...))))` that I threw my hands up and changed the file extensions to .cpp just to use std::complex<T> and enough operator overloading to type vector expressions like a human being.
- flohofwoe 5mo agoFor 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-been-walking-itself-back-for-fifteen-years-and-the-receipts-are-public https://hftuniversity.com/post/the-c-standard-library-has-be...
- Chaosvex 5mo agoThat 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 5mo agoThe article might be slop, but the problems described in it are definitely real ;)
- Chaosvex 5mo agoGrossly 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
- samiv 5mo agoYou'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.
- deleted 5mo ago[deleted]
- pjmlp 5mo agoNot 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 5mo agoI 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.
- pjmlp 5mo agoIf only C actually had fat pointers as Dennis Ritchie, one of the authors, proposed to WG14. It is quite relevant to note that the C authors, were keen to explore Alef as alternative on Plan 9, and based on the learnings reduced C's role on Inferno, and eventually took part in Go's design. Even though they were not keen into using C++ (Plan 9 doesn't even support it), they were also aware C wasn't to be used for everything.
- randusername 5mo agoOne of my hobbies is rummaging around thrift stores appreciating tacky things from bygone eras, sifting through ill-conceived modern junk, and delighting in simple, solid tools where I can find them. That's what it's like to be a C++ programmer.
- kllrnohj 5mo ago> But if someone told me to write C++ myself, I'd cry. There's too much to memorize, and the standards are too varied If someone tells you to write a web app, do you also cry? Surely there's more JavaScript frameworks than subsets of C++ at this point, no? Do you also go memorize all of them? Or do you just quickly pick one, and then only learn that one, and forget the rest exist? Because that's kinda how you approach C++. You pick a subset (like, say, just modern C++, only caring about C++17 & later or whatever), and just use that. And move on with your life. There's absolutely no reason to learn how std::auto_ptr works because it's dead in the same way you aren't learning how PHP & CGI works if you're making a modern web app. They're dead relics of the past that you can just pretend don't exist.
- fasterik 5mo agoI don't really understand this perspective. You don't need to memorize anything to learn a new programming language. You choose a medium-sized project you've already done in another language, start with "Hello world," and add one line of code at a time until the project is done. When there's something you need that you don't know how to do, you look it up. You'll end up with a strong understanding of the subset of the language that's actually useful for the thing you want to build.
- jviotti 5mo agoYou get used to writing C++, just like you get used to writing any language. I've been writing C++ for quite some time already, on a daily basis, and it became second nature. Though I remember how much of a pain it was when I initially move into it
- rewgs 5mo ago> 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've been feeling this way about web dev for a while now, and sometimes look at C++ devs with jealousy, wishing that the crazy amount of memorization/varied standards/rough maintenance/high difficulty I experience were only limited to the language that I write.
- epinephrinios 5mo agoIt's truly baffling. I was very frustrated with C++ (pre-LLM era) to the point I actively left a good job just so I can work on Rust.