| ▲ | coldpie 7 hours ago |
| I have a theory that the reason people like C++ is because it's challenging to use. It's like a puzzle or a riddle or a Dark Souls game. It feels good to get something done in C++ because there's so, so many ways for it to go wrong that when you do it right(-ish...), it feels like you're a master of a complex skill. This makes it a terrible language for actually getting things done, of course, but people like that feeling of overcoming the challenge, so they keep using it. |
|
| ▲ | cogman10 7 hours ago | parent | next [-] |
| Here's the thing. I'd say that C++ is a great language for getting things done. It gives you one of those fat swiss army knives I had as a kid with a spoon, fork, knife, toothpick, saw, nail trimmer, etc. The problem is it's easy to get dirty and the spoon would get locked in place after one use. But it was there, and it worked (once). C++ is extremely malleable. I think the reason people like it is very similar to the reason people like lisp. That ability to do horrors like make a lisp interpreter with macros or templates is the charm of C++. And if you are the only one writing it, it can be a joy because there are few limits to what you can or can't do. It's only when you have to share a codebase with others that things can get out of hand fast without some committee established usage code and pledge. |
| |
| ▲ | tcfhgj 7 hours ago | parent | next [-] | | > Here's the thing. I'd say that C++ is a great language for getting things done. my productivity sky rocketed when I switched to Rust. | | |
| ▲ | cogman10 7 hours ago | parent | next [-] | | Probably, particularly in terms of writing correct code. But C++ allows me to really easily write multithreaded code which I can convince myself is safe :) (and most of the time, is correct, just not on the edge cases). Rust makes that painful. | | |
| ▲ | tcfhgj 6 hours ago | parent [-] | | > Probably, particularly in terms of writing correct code. package management, build system, compiler errors, language simplicity (yes, it adds life times, but removes so many other things), Rust macros, language ergonomics (e.g. match, macros, enums, async, if let, etc.), not having to think about certain things going wrong (including not debugging why things went wrong) > Rust makes [multithreaded code] painful. Andreas Kling is switching away from C++ to Rust in Ladybird, because of exactly the reversed experience. I have been using asynchronous multithreading via tokio - something I never dared to in C++.
Alone from the compiler errors I have got doing that, I would assume that I would have been dealing with an unbearable amount of debugging of subtle memory issues. | | |
| ▲ | cogman10 4 hours ago | parent [-] | | > Alone from the compiler errors I have got doing that, I would assume that I would have been dealing with an unbearable amount of debugging of subtle memory issues. Well, that's the thing about rust and async. It's far more restrictive (necessarily) than the bounds of safety. The hard problem rust runs into is that async functions can be executed outside of lexical and the lifetime tracking of the rust language. To be absolutely safe, rust ends up needing to assume that async can be executed with no respect to the surrounding lifetimes. Rust would really benefit from something like structured concurrency in terms of the lifetimes of async functions. | | |
| ▲ | tcfhgj 2 hours ago | parent [-] | | > Well, that's the thing about rust and async. It's far more restrictive (necessarily) than the bounds of safety. I obviously was not talking about things illegal in safe Rust, which are actually safe, e.g. you cannot send types which are not allowed to be moved across threads across threads in C++ either. > To be absolutely safe, rust ends up needing to assume that async can be executed with no respect to the surrounding lifetimes. seems to work with surrounding life times? https://play.rust-lang.org/?version=stable&mode=debug&editio... |
|
|
| |
| ▲ | pjmlp 7 hours ago | parent | prev [-] | | Game developers can't say the same though. |
| |
| ▲ | cozzyd 4 hours ago | parent | prev [-] | | Yes, C++ is an omnibus language where all things are possible. | | |
| ▲ | simonask 4 hours ago | parent [-] | | All things... except non-nullable pointers, movable values, type punning, ergonomic sum types, and the list is frankly much longer. The only way you could think that C++ lets you do everything is if you've never tried anything else. |
|
|
|
| ▲ | materielle 7 hours ago | parent | prev | next [-] |
| It definitely has to be more complicated than that. I know the stereotype is that the C++ language lawyers are up in their ivory towers and don’t “get stuff done” like us pragmatic JavaScript or Python developers. But the reality is a ton of domains like graphics, video games, and cloud infrastructure is built on C++. I think the Spanner and Chrome devs “got stuff done” for instance. I could go on a tangent about the whole “maker vs coder” debate that has sprung up around AI. It feels similar to the C++ idea you’re talking about. The idea is that people who actually understand code and computer science concepts deeply are too busy yak-shaving to be productive like us “makers”. That ivory tower type definitely exists. But this false dichotomy seems to be defense mechanism more than anything. There are smart people that are basically better at everything. They understand C++ deeply, but can code in Python too, build massive pieces of infrastructure like Spanner, and now they are better at driving AI, too. Not that I’m defending any of the horrible language design decisions of C++. But, you see what I’m saying. People who have skills beyond is in one area aren’t necessarily deficient in another area. Maybe they are just smarter and more skilled than us in a ton of ways. |
| |
| ▲ | coldpie 7 hours ago | parent [-] | | > But the reality is a ton of domains like graphics, video games, and cloud infrastructure is built on C++. Yeah, legacy reasons. C++ was a decent-ish improvement over C in the early 90s when many of those APIs were being built out. It's the core language for the Windows API. We didn't get a decent, well supported replacement for C++ until like ten years ago. There's a lotttttttt of legacy C++ code that will stay in use for decades more. I never said people can't be productive in C++, I'm saying the reason they like it is because it's so hard to use. Just like people can get really good at Dark Souls, people can get really good at C++, too, and they have fun doing it. But I still think that's a con of the language, you can get the same or even better code quality with many modern languages with a much lower bar to mastery. |
|
|
| ▲ | pjmlp 7 hours ago | parent | prev | next [-] |
| Nope, I like C++ because it was already Typescript for C in 1993, coming from Turbo Pascal. Followed by the great developer experience of using Turbo Pascal alongside Turbo C++, later Delphi and C++ Builder on RAD Studio. An experience that many languages still fail to reproduce nowadays, with exception of Java and .NET tooling. You don't need to master every single feature. |
|
| ▲ | trealira 5 hours ago | parent | prev [-] |
| IDK, I just like C++. I don't think that's the reason. It doesn't feel that good to get something done in C++, and it doesn't feel like a puzzle; it just feels mostly straightforward. The language which is actually like a puzzle and which feels good to write is Haskell, in my opinion, but it's not always as easy to get stuff done in Haskell. I suppose this is why many Haskell coders moved to Rust. |