4 ms·
Tried C++ once and only once. After the compiler spit pages and pages of alien and incomprehensible errors I discovered that the language was not for me (I felt
by liendolucas 3y ago
Tried C++ once and only once. After the compiler spit pages and pages of alien and incomprehensible errors I discovered that the language was not for me (I felt like I was battling against the language and the computer). Never looked back nor regretted about it. In my opinion is way way better to learn modern C (and good C practices) a zillion times.
I think that Ken Thompson nailed it on C++: https://en.wikiquote.org/wiki/Ken_Thompson#%22Coders_At_Work%22,_2009 https://en.wikiquote.org/wiki/Ken_Thompson#%22Coders_At_Work...
Also Linus Torvalds is a huge detractor of C++: http://harmful.cat-v.org/software/c++/linus http://harmful.cat-v.org/software/c++/linus
But in the end everyone should pick whatever programming language feel comfortable with. Sometimes if you're pursuing a career in certain directions (e.g: game development) you have literally no choice but to knee down and learn whatever the industry is pushing to use.
- HarHarVeryFunny 3y agoThe GNU g++ compiler generates notoriously bad error messages, although they have gotten a little better, and you do get used to them (a bit like reading the entrails of a sacrificial victim to divine the future). The clang++ compiler, much more modern and built on the LLVM inftrastrucure, has much better error reporting. Occasionally, in desperation, I've compiled something with clang++ just to see the error message in cases where g++ was just too unhelpful.
- angiosperm 3y agoYou just read the first error message, and find where it says "at line #N" to see where the problem is. You can ignore everything after, however many pages you get, which is usually just a list of the functions you might have been trying to call, and can be long if there were lots of possibilities. Linux Torvalds has not looked at C++ since the '90s. C++ is a wholly different language now. The experience coding in it now much more fun, and it is easy now to write code that works the first time it is run (as is also seen with Rust).
- ljm 3y agoI'd say this is the typical case for most languages, especially if they try to compile the entire codebase and only report errors at the end. Take TypeScript, for example: if you bugger up a type definition or function call in one file, you'll have to wade through the errors of everything depending on it. Oftentimes you can go from 30 errors to just 2 or 3 with one simple change. The alternative is they fail at the first error but you don't get the root cause and end up fixing shit one by one if the problem isn't obvious. Especially with a new project in an unfamiliar language - start small and compile small, incremental changes. You won't end up with something you can't fix, which can't be said for installing dozens of dependencies up front and hoping for the best.
- f1shy 3y agoWhen working with code with multiline macros, or complex templates, it is impossible to understand some errors. OP is gold right in that. C++ is so complicated, it is just impossible to make an efficient compiler that gives goos error messages. Also having to ignore the pages after one error, to me, is a shittines indicator.
- angiosperm 3y agoMultiline macros and complex templates are rare in modern C++. What you describe is workarounds for features the language used to lack.
- f1shy 3y agoI describe working with real life code, where there are many old libs and code, often in plain C, with which you have to interface with.
- 3836293648 3y agoI wish. I had an issue where I accidentally passed a double literal instead of a float literal and the error was longer than my terminal history (so more than 10k lines) and even when I actually got the full message by piping it into less it didn't point at the correct line. (Clang did though so clangd could spot it)
- fsloth 3y agoI think in any case you need to learn C before C++. As a language C++ is a footgun. Unless you really want to learn it or need it for a job, it’s not something you pick up for fun. If you want to do computer graphics or computational geometry it’s best to learn the language - not for it’s own sake but because so much of the domain works in it.
- angiosperm 3y agoNo. Starting with C is the way to lock in bad habits and buggy coding. Writing fully modern C++ eliminates myriad sources of bugs and security holes.
- f1shy 3y agoAnd adds many other problems. No silver bullet.
- angiosperm 3y agoNew features pass a very strict gauntlet; they have to solve common, serious problems. Using the new features eliminates exactly those problems.
- uecker 3y agoOne can write very nice code in C and modern tools also eliminate a myriad sources of bugs. Modern C++ can be nice but adds a lot of complexity. I am much happier with C.
- commandersaki 3y agoA real solution to those voluminous inscrutable compiler diagnostics is to paste it into ChatGPT; I've found it works absolute wonders, really distills the exact issue at hand.