Why is C++ hated so much here in /prog/? Many good software are written in C++.
I'm aware that there are some problems in the language and it is considered "hard" to master it, but why do so many people hate it? What harm has it done?
Software can be written much quicker when using some scripting languages like Python. Software can be writte slightly quicker when using some managed language like Java. But when using those languages, the resulting program will require more resources to run. So there is place for C++.
For example, I bet the web browser of 99% people browsing /prog/ is written in C++. It's not perfect language, but it is the best language for complex program with relatively small CPU and RAM requirements.
Name:
Anonymous2012-01-09 14:00
>>73
templates are a very bad solution for generic programming.
they have inconsistent implementation across compilers (even today, 20 years after templates have been "standardized"), horrible compile-time implications, absolutely impossible to debug (try debugging a boost class, I dare you) - even the compilation errors they cause require some skill and experience in order to decipher.
there are much better attempts at generic programming - .NET generics / dynamically-bound languages like python, and in some cases - even C macros are a better choice.
Name:
Anonymous2012-01-09 14:10
>>76
they also cause serious code bloat, which leads to more RAM consumption,paging and cache misses
here's a nice example: compile hello world using printf, and using cout. you'll see that iostream example results in a 10-20 times larger binary
I mean, what's keeping someone else from just choosing a random tripcode and use the name kodak_gallery_programmer? I'd believe it was you (I'm assuming the person I'm talking to actually is you, kodak) as long as they regularly called people mental midgets and told them to scrub another toilet.
C++ programs are larger by definition mainly because of static initializations and exception frames. In ELF targets, these things go on separate code sections, which enlarge the binary a bit further because of headers and alignments. Usual GNU-produced ELF targets are ridiculously bloated when compared to the average PE executable (just take a look at the number of sections generated for a simple Hello World C program).
If one strip out exceptions (-fno-exceptions in GCC) and avoid static initializations, the final executable has about the same layout any C executable would. The C++ boot code is also more complex, since it needs to walk through the initializer list and perform the forementioned static initialization, which is non-existent in C. This adds a bit more in its size.
The worst problem in C++ is the toolchain and the utterly ridiculous standard library. The language design is ok, put apart a number of warts (such as the need for three damn cast operators).
Once you get rid of the fat standard library, C and C++ programs are as slim as assembly-language programs to a great extent. Putting apart the standard C++ library is not a great loss, and it is rather easy to implement the necessary things in freestanding C++, both in Windows and Linux. (In Windows, by the way, the freestanding environment is actually the default one.)
Name:
Anonymous2012-01-10 3:59
>>81 .NET generics
Not as powerful as C++ templates.
C macros
They are powerful, but harder to read (for humans) compared to C++ templates. C++ templates are slightly safer.
>>15
I only read some random part a while ago, which turned out to be the part about why operator overloading in C++ is broken. Such utter BS. Didn't bother to read anything else after that.
Name:
Anonymous2012-01-10 4:52
Actually I made up the term ‘object-oriented’, and I can tell you I did not have C++ in mind.
— Alan Kay
“There are only two things wrong with C++: The initial concept and the implementation.
— Bertrand Meyer
"Fifty years of programming language research, and we end up with C++ ??" - Richard A. O'Keefe
"C++ is an insult to the human brain." - Niklaus Wirth
"Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said, 'OK, we'll do them both'. So the language is too baroque for my taste." - Donald Knuth
"C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it." - Linus Torvalds
Usual GNU-produced ELF targets are ridiculously bloated when compared to the average PE executable
Is there a gcc option to link and merge all sections into one? This is easy with MSVC and the /merge option.
>>96
Are you saying that it results in large binaries? Otherwise I don't see what you mean.. How would you avoid this bloat when implementing the same functionality (or the subset you need) in C++?
``As dinosaurs (who code exclusively in C) are becoming extinct, you will soon find yourself alone with attitude like this.''
- dude's reply to torbals
>>102
I quoted:
- Alan Kay, inventor of Smalltalk, object-oriented programming and colaborator on the first GUIs at Xerox
- Bertrand Meyer, inventor of Eiffel
- Richard A. O'Keefe, computer scientist author of researching and books on logical programming and Prolog
- Niklaus Wirth, inventor of Pascal and Modula/Modula-2 languages.
- Donald Knuth. What should I say about this man? He've won a fucking Turing Award and he's written The Art Of Computer Programming. I bet you don't even know this book existed.
- Linus Torvalds, creator of the Linux kernel and git.
Maybe you didn't know these people or what they've done. But you should at least listen to what these people have to say. Because they have actually archieved something in computer science and engineering.
Name:
Anonymous2012-01-10 12:00
C++ introduces more problems to software development, it has a low quality standard library that nobody uses in large projects, it's slow, because the only thing it brings from object-oriented languages is Vtable dispatch, so you end up with a language that is as slow as a native/JIT-compiled high-level object-oriented language without the features of a true high-level object-oriented language, can't even define pure virtual/interface-like methods without a "virtual ... = 0;" weird syntax, no big OS brings a C++-base API (Windows uses C, Apple uses Objective-C, GTK+ uses C, only Qt uses C++ but without using the standard C++ library, and take a look at how full of bugs KDE releases are sometimes).
C++ is the main culprit of how big projects like Firefox need constant updates and bugfixes to fix memory leaks and security holes.
Name:
1022012-01-10 12:11
>>110
I knew 3 of those people (and now I know all of them). Yeah, they are smarter than me. That does not mean they are correct when they're saying C++ is horrible. Many smart people C++ is good (or at least ok) language.
I bet you don't even know this book existed.
I do know it. I bought the first chapter few months ago. I've just read maybe 50 pages (trying to figure out at least some of the exercises... ok it's fucking collecting dust in the shelf, too 'busy' right now).
C++ is not perfect. But there is no real alternatives to it, high level, compiling to native code and fast runtime (GC is too slow for some cases). Maybe Ada? Maybe not.