![]() |
Everything wrong with C++.
Funny and to the point video on C++. 2 hours long. Glad that I'm not the only one that has gritted my teeth while using it.
https://www.youtube.com/watch?v=7fGB-hjc2Gc |
Itching c++
https://port70.net/~nsz/16_c++.html
- too many features (but abstractions and expressivity is not that good) - missing useful features (safety, concurrency, closures, module system,..) - implementation is difficult (language tools and compilers are bad) - feature X is broken, dangerous, has too many special cases, noone understands the semantics. - feature X is good, but it is abused in c++ or does not work well with other features. - not enough compatibility: code gets broken because of language changes, compiler fixes, deviations from c99, posix. - senseless compatibility: c design (preprocessor, type system,..) is unsuitable for the feature set of c++. - complexity: difficult to maintain, debug, fix, understad and reason about code (..written by others). - complexity: learning and using the language requires too much effort. - c++ is hideous (errors in implicit runtime mechanisms cannot be handled, encourages breaking abi,..) - c++ is slow (compile, link and run time), big (language tools, src code, compiled code) and ugly. ... and more A little bit old, but quite interesting, C++ Frequently questioned answers: https://yosefk.com/c++fqa/ In particular, Defective C++: https://yosefk.com/c++fqa/defective.html C++ programmer's guide to undefined behavior, part 1 of 11: https://pvs-studio.com/en/blog/posts/cpp/1129/ Encyclopedia of things considered harmful, about C++: https://harmful.cat-v.org/software/c++/ Linus Tordvals' opinion of C++ is to enjoy: https://harmful.cat-v.org/software/c++/linus |
Quote:
Just because you can do something, it doesn't necessarily mean you should. You can jump off a cliff too, are you going to? You should repeat the same value used in more than one place? I hope you never have to change it, god forbid it's the version of your app or library... Clearly they prefer Java instead, whata rant if there ever was one... Linus has gotta be insanely jealous if he watches that... :shrugs: |
Is it bad? maybe
Is the developer experience worse than Python? Yes. But it is not the "The worst programming language of all time". I can think of a few worse languages. Also my favorite language is objectively worse https://en.wikipedia.org/wiki/Brainfuck This is how you print "Hello World!" (you can use an online compiler to confirm): Code:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. |
I watched the first two minutes.
The problem with C++ is that it is trying to do too much. C++ should not try to compete with Rust or Python. C++ is already extremely good at what it does. The trick is to use a subset. I write C++98 with select C++11 features, and libraries that cover my needs. I have not experienced breakage when compiling with the current language standard. Ed |
There is only one thing wrong with C++ - or rather one root cause of all these problems and annoyances - it is an unnatural and unworkable hybrid of two clashing principles. C is a highly flexible and efficient language giving a programmer the most intimate control over the code. It was designed for writing operating systems - and in the good old days when they still cared about such things as code size and efficiency. But there is a price to pay: C code is not easy to read and maintain and it offers ample opportunities for shooting oneself in the foot. OOP is a technique to develop reliable code faster at the expense of its performance and efficiency. The result, of course, is the language which is both inefficient and difficult to work with - and all because there was a huge base of C fanatics who'd rather cut off their penises than use Delphi and won't accept OOP unless it had C in it.
|
Quote:
https://en.wikipedia.org/wiki/Unix_Philosophy Quote:
Quote:
|
Quote:
Python was not even conceived of until 1989. Rust started as a side project no one heard about until 2010. Who is trying to compete with whom now? Quote:
I have worked Perl (and Pascal, for that matter) the same way, ignoring modules that exist for a specific function but that complicate my use case under the hood. Better to code an explicit and direct solution myself, that is more correct for my specific needs. |
Quote:
Quote:
Although, I'm not sure Linus would agree that C was never meant for large projects, as I really don't think you could call the Linux kernel a small project by any means. I do find the part: Quote:
Quote:
They're wrong in the video linked in the OP when saying you must have a header for every source code file, you're not actually required to have one. You could put everything into the same source code file if you wanted to and the compiler wouldn't complain and would let you do it. Don't get me wrong, I'm not advising people to do it that way, and I certainly wouldn't be doing it that way. As personally, I don't think the preprocessor is a bad thing, but it's like any other feature of the language, you need to be sensible about it. I for one favor using a #define preprocessor directive over a const or a variable when you are using either a default value or, and particularly the same value in multiple places in your code. Whereas, Java, C#, etc, you would be forced to use a const or a variable instead as far as I know, and variables take up memory, whereas a #define preprocessor directive doesn't take up any memory, therefore there's no overhead. All that said, I do have to agree with EdGr in only using a subset of it, which was my point in making the comment in my post #3 quoted below: Quote:
|
We have an application at work that the programmer used as much c++ features as possible. It is a problem to maintain for people down the road. He didn't adhere to the 'KISS' principle which is my motto. I use the basic constructs and ignore all the 'fancy'/'clever' ways. Readability over cleverness anytime. That said, I am currently coding a home SDL3 project in straight 'C'. What fun to use simple syntax to get the job done without all the overhead of C++/Rust. I apply the KISS principle to Python as well. I don't use many of the advanced language features either as I feel they aren't intuitive to someone else looking at the code. Again readability over cleverness unless there is a 'really really' good reason for it.
|
Quote:
It is Turing-complete and you can think of it kind of an implementation of a Turing machine, at least when it comes to loops, (which I love as a Math person). Its real value lies in learning how to build a compiler. Writing a compiler for a language with only eight basic instructions is way more simple (and can easily be done in a weekend) than trying to build a compiler for a language with a complex syntax like Python, C++, etc. |
It's an interesting question considering its complexity, that is, the number of functions it contains (let's say, how rich it is, how easy it is to express yourself in it).
The problem is that the richer a language is, the more complex is it, the harder it is to learn and use, and the fewer people who can use it professionally. And the question is, why, what and for whom do you create (a programming) language? For dummies? For professionals? For the average user? How can you achieve anything? By exploiting all the available power of the language, or by using only a few basic commands (and creating inefficient solutions)? By the way, AI will eliminate the need of the languages sooner or later. |
Quote:
Pascal and Modula-2/3 were designed for TEACHING concepts, and are excellent at expressing those concepts. C was designed for construction of operating system tools, and fit that use case perfectly at the time. FORTRAN was designed for mathematics and matrix mechanics, and is STILL the best tool for that use case. COBOL was designed for managing document paperwork and mathematics, and is hard to beat at what it does best even today. C++ was created to express a form of C enhanced to use objects and inheritance. It also served as a bridge between OS and OS Tool coding and application coding. (The success of C++ and SMALLTALK inspired the insertion of OOP structures and logic into other languages, including Pascal and COBOL.I am not sure that was any improvement.) Automated Incompetence (AI) has no creative component. A human coding community will always be required to feed the back end database with new logic and creative structures. If we ever achieve real Artificial Intelligence that may change, but I estimate that we are at least a century away from that point. |
Do any of these cover the pseudo-smart "C++ grammar is not context free!" complaint that I used to hear all the time on Slashdot? Or have people forgotten about that?
|
Quote:
Quote:
|
| All times are GMT -5. The time now is 05:43 PM. |