11 ms·
C++: Is It Really a Cruel Joke? (2003)
- a_bonobo 8y agoI feel compelled to note that this page is from 2003-05-13, so I have no clue how much of its gripes are still valid in 'modern' C++ :)
- trimbo 8y agoAnd smart pointers had been a thing for a while at that point (though not part of the library) https://www.boost.org/doc/libs/1_61_0/libs/smart_ptr/smart_ptr.htm#History https://www.boost.org/doc/libs/1_61_0/libs/smart_ptr/smart_p...
- colanderman 8y agoYa this is a whiny garbage post that looks like something I would have written when I was 18 had I been forced to use C++ for a school project (and probably could have been, given its year of publication). I'm not sure it adds anything to human discourse. It certainly isn't applicable to modern C++, or even the modern zeitgeist of pre-modern C++.
- xfer 8y agoYou can still do all those things in modern C++ in addition to all the stuff that get added every 4 years. The only thing that has improved dramatically is the tooling: compilers, static/dynamic analyzers. > And, as I said before, every C++ programmer feels bound by some mystic promise to use every damn element of the language on every project.
- jgalentine007 8y agoI wonder how things have progressed from a security/stability standpoint - my OS definitely crashes a lot less, I'm guessing because there is less C in it now...
- pjc50 8y agoWhich OS? Linux and Darwin are still entirely C in the kernel, I believe. Windows is C++.
- makapuf 8y agoIt seems that windows kernel is C also : https://www.reddit.com/r/cpp/comments/4oruo1/windows_10_coded_in_c_or_assembler/ https://www.reddit.com/r/cpp/comments/4oruo1/windows_10_code...
- jgalentine007 8y agoThere was a post in that thread that I think confirms my suspicions - that most 'new' code outside the kernel is being written in C++/98 or 14.
- jcelerier 8y agothe kernel is compiled in C++ mode and has a few classes AFAIK. Has been for a very long time - Win3.1 kernel already had some C++ in it. The macos kernel driver interface, IOKit, is C++ too.
- jgalentine007 8y agoI use windows 10. Kernel is still Win32 C calls but I bet a lot of the services on top aren't.
- ygra 8y agoJust because it's a C API doesn't mean it's not C++ underneath. Heck, Microsoft's C runtime is written in C++ nowadays.
- _xzxj 8y agoThe author didn't really complain about too much specifically, just generally complaining about the language. I guess it's hard to say whether or not the situation is better in the latest versions of C++ (though as someone who uses C++ an awful lot I would assert that it has gotten much much better). That said, I think the complaint maybe comes down to coding style and architecture of the thing they're coding. They seem to make a joke we'd maybe more closely associate with Java than C++ these days. Also Microsoft's C++ style is awful. So if that's the only experience you have with C++ I would be hard-pressed to blame you for hating it.
- jasonmaydie 8y agoThe only joke here is somehow this author thinks the success of your project is dependent on the language you pick
- macintux 8y agoFunny how many people believe that language choice influences success. I guess they're all wrong? Sure, there are an uncountable number of other factors, but picking the wrong platform/language can be fatal.
- ythn 8y agoAnytime I see someone bashing Java/PHP/JavaScript on /r/programmerhumor (reddit) I challenge them to a coding contest. I use the language they just bashed, they use their ideal language. No takers yet. I think, more often than not, language choice is like golf club choice. Different pros have their preferences, but a pro can play a good game with any set of clubs. A novice will blame the clubs for a poor game.
- paulie_a 8y agoTo be fair I don't understand why anyone would bother. I am commenting on a forum, I don't expect to be given homework.
- swebs 8y agoAnd you can perform carpentry using a big rock instead of a hammer. That doesn't negate any downsides of choosing the rock.
- ythn 8y agoI would say it's more like people are pooh-poohing certain brands of hammers as being inferior to TrendTech Hammers (R) which are "obviously" superior.
- AnimalMuppet 8y agoThe winner will be the one who gets to pick the task for the programming challenge.
- _d9hm 8y agoThat (fake) interview at the end is hilarious.
- jcelerier 8y agoI think it's from cat-v : http://harmful.cat-v.org/software/c++/I_did_it_for_you_all http://harmful.cat-v.org/software/c++/I_did_it_for_you_all
- leajkinUnk 8y ago> There was this Oregon company - Mentor Graphics, I think they were called - really caught a cold trying to rewrite everything in C++ in about '90 or '91. I felt sorry for them really, but I thought people would learn from their mistakes. I've talked to some of the people at Mentor Graphics who were there during that period. The company basically went from #1 in the industry to #3 or so during the course of the C++ refactor (and the EDA industry isn't exactly big). Bjarne Stroustrup showed up at the company now and then because the company was such a major early adopter. Inheritance chains were 5 or 10 classes deep. A full build took a week. The company hosted barbecues on weekends and invited the employees' families so they could see each other. I only worked there somewhat later, so I just heard the stories from people who were there at the time, and only after I had been there a while. Take some old-timers out to lunch now and then, you'll learn a lot. I ended up leaving, I was more than a bit frustrated by the organizational culture and the build system my team used was by far the worst I have ever seen in my entire life. But Oregon is an awesome place to live, the salary was good, and the hours were normal.
- bunderbunder 8y ago> Inheritance chains were 5 or 10 classes deep. 30 years later, I still run into the same problem regularly. I'm not sure why, but this seems to be an anti-pattern that everyone needs to learn about the hard way.
- DerDangDerDang 8y agoI blame java
- bunderbunder 8y agoDon't blame Java. Blame programming instruction. If it's anything like when I was in school, as soon as the curriculum trots out its first object oriented language, you get a lecture about how is-a relationships are the greatest invention since the compiler, and deep inheritance hierarchies are both the most practical and the most morally righteous way to organize your abstractions. (Meanwhile, ironically enough, I'm not sure I've ever heard a CS instructor even mention the Liskov Substitution Principle.)
- nf05papsjfVbc 8y agoDr. Stroustrup took a lot of pain to ensure the language was useful and did not break backward compatibility. He also always maintained that if you don't use a feature you shouldn't pay for it (in terms of performance). Eventually, it became even more popular and there is now a whole organisation behind the international standards for the language. The book "The Design and Evolution of C++" helps one understand why some things are the way they are and sometimes it helps understand why some things exist in the language in the first place. The language takes a lot of flak but I think it is quite good given the constraints it has and the modern version is an amazing leap forward in ease of use as well.
- Underqualified 8y agoI always felt that if you wanted the same functionality as c++ in terms of performance, flexibility and power of abstraction, you'd end up with something as complex as c++. Modern c++ shows there was/is room for improvement, but it does not fundamentally simplify the language imo.
- unrealhoang 8y agoOnly if it need to have backward compatibility. Rust doesn’t so it can be vastly simpler.
- okasaki 8y agoHow is Rust simpler than C++?
- virtualritz 8y agoAre you talking about grokking the language and its more excotic concepts or writing code on it? I have almost 30 years of C++ experience and about 6 months of Rust. My gut feeling is that the languages are equally difficult to understand but that the experience of writing code in them is very different. I'm sure Rust will have its own set of surprises as I keep using it. But I can't believe they will be nearly as bad as those that C++ comes with. ;)
- ythn 8y agoModern C++ is WAY better than C, IMO. I can never go back to C, having tasted C++14, and I work on embedded systems.
- red75prime 8y agoFortunately, there are more choices today. I use Rust for embedded systems.
- shrimp_emoji 8y agoSeconded. I'd even go so far as saying that C++ is my favorite lang; it's C with the lavish furnishings of Java. C is a space ship, Java is a plane, and C++ is an amphibious SSTO. It's messier in design and trickier to pilot, but you can do more with it!
- Espressosaurus 8y agoType safety, constexpr, template metaprogramming: I don't know why anybody does anything in C in embedded systems when C++11 is right there. Compile time programming is what it's all about. Support has been slow, but even the non-GCC embedded toolchains have been improving substantially over the last few years.
- olly67 8y agoI used to do a lot of C++ programming, but over time I found that using either C or a real high level language (Python, Ruby, etc) works better for most tasks.
- jcelerier 8y ago> It is sufficiently fascist that it more or less "forces" students to program with a certain discipline. Never mind that no real coder EVER writes programs with that particular discipline once they get out of diapers... I wonder what would be the author's opinion of Rust
- kibwen 8y ago>> Never mind that no real coder EVER writes programs with that particular discipline once they get out of diapers... This line appears to be a snide remark at class-based OOP, for which a regular criticism is that real-world projects rarely slot neatly into the sort of "Cow is-a Mammal is-a Animal" taxonomical hierarchy that is used to teach class-based OOP in school. Rust doesn't have classes or taxonomical hierarchies, and encourages struct-first POD design (similar to C), augmented by traits which provide shallow has-a relationships (composition) rather than deep is-a relationships (inheritance).
- DonHopkins 8y agoNo joke! No joke! You're the joke! http://www.stroustrup.com/whitespace98.pdf http://www.stroustrup.com/whitespace98.pdf Generalizing Overloading for C++2000. Bjarne Stroustrup. AT&T Labs, Florham Park, NJ, USA.
- pjc50 8y ago2001ish? Besides, it's a really tired debate/joke. Yes, it's hard to learn and has a bunch of misfeatures. But, like Javascript, it's widely adopted and in use on so many real projects that you're not going to get to rewrite.
- thestoicattack 8y agoFrom the "interview" of "Stroustrup": > ... You know, when we had our first C++ compiler, at AT&T, I compiled 'Hello World', and couldn't believe the size of the executable. 2.1MB > Interviewer: What? Well, compilers have come a long way, since then. > Stroustrup: They have? Try it on the latest version of g++ - you won't get much change out of half a megabyte. So, for grins, I did, with the gcc7 port from macports, which is GCC 7.3.0. -rwxr-xr-x 1 ssta staff 8968 Jul 5 10:40 hello The C version, using printf instead of (gasp) std::cout, clocked in at 8432.
- abhishekjha 8y ago#include<stdio.h> int main(){ printf("Hello World"); return 0; } >5649591 -rwxr-xr-x 1 user user 8288 Jul 5 21:49 a.out What am I doing wrong?
- fesoliveira 8y agoDid you use -O3 or some other optimizations?
- abhishekjha 8y agoNo, just `gcc a.c`.
- jacob019 8y agoHaving spent the past decade working with python, I've always considered C to be a mystical black box for hardcore systems guys. I recently needed to write some high performance networking code so I decided to give it a shot. At first I found it painfully verbose and confusing, with the simplest operations requiring lines of code. After a couple days I found it to be rather refreshing, it encourages you to look at memory from a more basic perspective and efficiency just falls in place. Pointers are confusing and strict typing takes some getting used to, but they are awesome. It's great to be able to use the same memory with different types and structures, so better than copying things around. I still love Python, but I will be using C again when performance matters.
- adrianN 8y agoIf you liked it you should try a language with actual strict typing like Ada or Rust.
- gtycomb 8y agoI stumbled into Nim recently and this thing "just works". Python-like syntax, performance like C. This is what C should have been, I'd say. https://nim-lang.org/ https://nim-lang.org/
- mlthoughts2018 8y agoI would encourage you to use Cython instead of Nim if you're looking for Python-like syntax combined with C performance.
- dom96 8y agoWhy is that?
- gtycomb 8y agoThis is just my situation, but I gave up on Cython when I started moving forward with it (distributed graph algorithms). I found that I had more things to learn. With Nim, it took me half a day (after seeing the language for the first time) to get a basic numerical process going and another few days for distributed data communication involving messaging and postgres/mongo (Nim has a modern JavaScript (ES6) promise/async/await like concurrency model that is powerful and succinct like the language itself)
- martincmartin 8y ago"There are only two kinds of languages: the ones people complain about and the ones nobody uses." -- Bjarne Stroustrup [1] [1] http://www.stroustrup.com/bs_faq.html#really-say-that http://www.stroustrup.com/bs_faq.html#really-say-that
- krylon 8y agoThis has got to be one of my favorite quotes about programming languages. ;-)
- kibwen 8y agoWhile the OP article is indeed unhelpful and unconstructive, it's a pet peeve of mine to see people reference this quote (in the context of any language, not just C++) as a way of deflecting criticism. Not all languages that are used get complaints in equal proportion, and finding the constructive complaints is how we work towards making all languages gradually better.
- yogthos 8y agoThere are plenty of languages in use that people genuinely enjoy using [1]. A lot of complexity in languages tends to be completely incidental. It's often not inherent in the problem the language solves, and it's just a design decision somebody made based on their aesthetic and experience at the time. A lot of people seem to take pride in memorizing these quirks, but they're just that. There's nothing fundamentally interesting about them, and they're just mental clutter at the end of the day. We should strive to have well designed languages that are optimized for developer experience. Accepting poor design decisions just keeps perpetuating the problem. [1] https://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted https://insights.stackoverflow.com/survey/2018/#most-loved-d...
- ebbv 8y agoWhy do we as developers feel a need to constantly trash the things we don't like? If you don't like something, don't use it. Talk about the things you do like instead.
- ben509 8y agoBecause talking trash is fun. Maybe the discussion will identify some problems with a thing. There's an infamous piece "PHP is a fractal of bad design" that I found very insightful. But, honestly, it's mostly because it's entertaining.
- nocman 8y agoWhile I agree that it is good to not always dwell on the negative, there can be a lot of value in pointing out the deficiencies of programming languages. Some folks will just use a language without thinking about its downsides. If you use language X for a long period of time, you can become blind to areas where it is wasting your time. Again, I do agree that the tone could often be much more civil, but I would hate for experienced programmers to stop pointing out things that bother them about their programming languages. Much of the time it is not just about personal taste -- it is about real problems with the language that have a real cost.
- ebbv 8y agoI wasn't saying there's no place for constructive criticism or critiques. Those are definitely useful and important. But that's not what this article is, and I think we all know the tendency I'm talking about for people to spend more energy and feel more comfortable trashing things than talking about what they like.
- ben509 8y ago> C++ is more insidious -- because it IS a superset of C, it sucks you in, and (like Pascal) it has been embraced by computer science departments everywhere I've heard of this, but does it happen? I did my degree back in the '90s at Drexel, I don't recall there being any prescribed language... I did some systems stuff in C, some AI courses in LISP, a concurrency course in Java, some stuff I don't recall in Perl, some math courses used Maple, and there was a bit of shell and some familiarization with the Solaris boxes, etc. I don't think I ever actually took a course on a specific language, you were just supposed to RTFM and figure it out.
- cogs 8y agoI know C++ isn't really dying off, but what is the best platform-agnostic compiled object-orientated language these days? I liked Borland Pascal, and I know Delphi is kind of ticking along, but I'd rather invest in a language that is growing. Swift looks nice but still seems too Apple focused. Don't want to start a war, just open to some tips on the ecosystem..
- systems 8y agoD has potential
- red75prime 8y agoYes, it is having potential for 11 years and will probably continue doing so.
- unrealhoang 8y agoRust definitely is a good choice, if you can give up inheritance.
- MrBuddyCasino 8y agoWouldn’t classify Rust as OO though.
- 11235813213455 8y agoHe said the opposite
- bluejekyll 8y agoWhy? It specifically chooses to drop one piece of OO, object inheritance, but it does have functional inheritance. It even has Deref which gives back a form of object inheritance. It supports polymorphic functions like other OO languages. While I find functional patterns more useful in Rust, that doesn’t prevent OO design where it’s desirable.
- 8y ago
- con22 8y agoIt is a shame that HN now is totally the mic-phone of Mozillia. All is task is to help Mozilla to slander their competitors, for example, Chrome vs firefox, c++ vs rust,...
- sctb 8y agoSince it seems you won't post anything else, we've banned the account. We're happy to unban accounts if you email hn@ycombinator.com and we believe you'll start commenting substantively. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- Raphmedia 8y agoIf you only want to read the joke interview, here's a website with a better layout: http://harmful.cat-v.org/software/c++/I_did_it_for_you_all http://harmful.cat-v.org/software/c++/I_did_it_for_you_all
- abhishekjha 8y agoI think there should be a separate course for memory management w.r.t any language so that people can get a better perspective of what they are doing. A few books explaining the modern memory management principles would help as well.
- htor 8y agoyes, c++ is the cruelest most insane joke, on the same level of perhaps embedding malware inside a compiler and distributing it to the developers. no really, it was a nice try making an object-oriented language on top of c, but then why not build on top of the superior oo features of smalltalk or lisp?
- vinayms 8y agoMy biggest gripe with the language is the template thing. Templates are wonderful, but it often gets out of hand, especially with library code (I'm looking at you boost). While the interview is clearly a satire, it seems that templates were designed, or ended up upgraded, specifically to create a class of 'experts'. Being able to deal with highly nested templated code seems to be the mark of an expert, more than any other aspect of the language. Then, the whole template meta programming is just nuts and a circlejerk of sorts. A week back I had to parse some Unicode text that had a BOM on Windows. I was using fstream. The code to be able to read the BOM was so incredibly contrived, with all the templated codecvt stuff, that I said fuck it and went back to FILE* and manually skipped the first two bytes.