News for hackers. Stuff that matters.
Re:Learn Modern C++ by liendolucas on Tuesday December 26, 2023 @12:48PM (#38773973)
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...

Also Linus Torvalds is a huge detractor of C++: 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.

Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @01:42PM (#38774590)
You 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).

Re:Learn Modern C++ by 3836293648 on Tuesday December 26, 2023 @03:20PM (#38775648)
I 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)
Re:Learn Modern C++ by ljm on Tuesday December 26, 2023 @02:12PM (#38774917)
I'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.

Re:Learn Modern C++ by f1shy on Tuesday December 26, 2023 @02:34PM (#38775177)
When 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.
Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @02:55PM (#38775403)
Multiline macros and complex templates are rare in modern C++. What you describe is workarounds for features the language used to lack.
Re:Learn Modern C++ by f1shy on Friday December 29, 2023 @03:37AM (#38802869)
I 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.
Re:Learn Modern C++ by HarHarVeryFunny on Tuesday December 26, 2023 @01:11PM (#38774229)
The 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.

Re:Learn Modern C++ by fsloth on Tuesday December 26, 2023 @02:09PM (#38774880)
I 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.
Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @02:19PM (#38775005)
No. 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.
Re:Learn Modern C++ by uecker on Tuesday December 26, 2023 @04:25PM (#38776227)
One 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.
Re:Learn Modern C++ by f1shy on Tuesday December 26, 2023 @02:35PM (#38775191)
And adds many other problems. No silver bullet.
Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @02:57PM (#38775424)
New features pass a very strict gauntlet; they have to solve common, serious problems. Using the new features eliminates exactly those problems.
Re:Learn Modern C++ by commandersaki on Tuesday December 26, 2023 @11:56PM (#38779231)
A 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.