TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A response to Linus Torvalds on C++ (2007)

20 pointsby geekamabout 12 years ago

12 comments

jnazarioabout 12 years ago
i had been a C++ hater for a long time, partly because of the environment i was in (strongly C, anti-C++) and partly because most of the C++ hackers i knew enjoyed abusing language features.<p>i'm reading a bunch of C++ lately and i have to say i like it, i like it a lot. it's something i may have to dive into and actually learn.<p>some of this is due, i think, to solid standards coming in, but also a lot of growth on my part as a coder.<p>plenty of things are done better in OOP than not, where re-use through inheritance, design by composition, and modularity are needed and well executed.<p>my bigotry against C++ has ended.
评论 #5835606 未加载
评论 #5835614 未加载
grogersabout 12 years ago
Ah this old chestnut... Clearly the author believes in fighting flames with a flamethrower. Anyone could write the exact same arguments against this piece, just as he does against Linus. His arguments aren't well backed, and his tone is even more inflammatory than Linus...<p>Sad to say that a lot of people's bias against c++ is rooted in their experience with it 10-20 years ago. Poor compilers, poor stdlibs, poor portability, etc. If that is you, I would encourage you to check out what modern c++ is like. C++11 fixes a bunch of things, c++14 will fix some things that the committee missed. Yeah, c++ is big and complicated, but so is every language, even C. Yeah the C core language is small, but any large project starts either rolling their own library for data structures, algorithms, string processing, etc, or linking in behemoths like glib. C++ just comes with a lot of the basics included, and learning the best practices and modern idioms of using the language isn't that bad. Consider:<p><pre><code> unique_ptr&#60;foo&#62; bar(); // c++ foo* bar(); // c. </code></pre> The C++ version conveys way more information (and is almost impossible to screw up its use accidentally), without the need for comments, and compiles to the same code. This is just one example, but they abound.
rikkusabout 12 years ago
I've written a _lot_ of C++. I'd rather not go back to using it, if possible.<p>Recently I found this: <a href="http://yosefk.com/c++fqa/" rel="nofollow">http://yosefk.com/c++fqa/</a><p>It explains most of the reasons I disliked C++ and, if you've ever used it, you might recognise the issues dealt with.
评论 #5837294 未加载
smegelabout 12 years ago
What a bad article. Instead of discussing the big ideas in depth it first starts with a caricature of what is referred to as a "C-hacker"...then delves into an logical analysis of Linus' sentence structure including the implication of his use of a comma.<p>It looks and feels exactly like the kind of defensive article you would expect from a insecure C++ programmer. Maybe he should have just tweeted "Everything Linus said is wrong! WRONG!" instead.
EternalFuryabout 12 years ago
Originally, I disliked C++ because it was poorly supported across platforms. You had this level of standard support on one platform, but only that level of standard support on that other platform. From STL to every other useful library. It made things difficult to port. But that was long ago, before I stopped using C++. Things may have changed since then. Platforms have become fewer and far in between at least. C is widely implemented on all platforms and in fact, most platforms have large chunks implemented in C.<p>The other thing is about class-based languages. They are great for implementing <i>hierarchies</i> of concepts, like GUI toolkits and a few other things. But, they do promote bulk and it's not rare to have a lot of object thrashing. That's not specific to C++, though.<p>Third, system-level library are often exclusively exposed via C libraries. Core things like BSD sockets, POSIX threads, memory management. Yes, you can wrap them in C++ or use C++-based libraries that add sugar on top, but more often than not you end up wondering "why don't I use the system APIs directly?" You often feel like you have to jump through unnecessary hoops when you don't.<p>Just my opinion, of course. I would use C++ if there was a good reason for any particular job. It is just not my natural inclination.
robot314about 12 years ago
First off, with regards to calling strlen multiple times in the loop, the author is just plain wrong. Gnu C has something called __builtin_strlen which is a compiler extension that can replace the function calling a statically allocated string with just its length[1] making it essentially zero overhead. Second, strlen is defined with __attribute_pure__, which means that the compiler can optimize to just one function call in all other cases[2]. With these two compiler optimizations, C is at least as efficient as C++ in worst cases, and much better otherwise.<p>[1] <a href="http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html" rel="nofollow">http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html</a> [2] <a href="http://ohse.de/uwe/articles/gcc-attributes.html#func-pure" rel="nofollow">http://ohse.de/uwe/articles/gcc-attributes.html#func-pure</a>
评论 #5835978 未加载
kylloabout 12 years ago
C++ is painful, but language wars are more painful and divisive in the long run. This is from six years ago, why bring it back from the dead? C vs. C++ squabbling should have ended in the 90s IMO.
niraiabout 12 years ago
Turns out it is also quite easy to generate total and utter crap by writing about C++.<p>It is reasonable to speculate that C++ is more popular with beginner programmers than C, and that this may significantly affect the characteristics of a software project developed by a big team or community, as opposed a single particular programmer.<p>It is also reasonable to assume that trovalds speaks out of his experience and doesn't merely speculate.<p>As for me, his observation perfectly matches my personal experience.
icebrainingabout 12 years ago
I don't see what's so extraordinary about Linus' claims that bad programmers make the language worse and easier to produce crap with.<p>I think it's clear that Linus isn't talking about the language as the syntax and semantics that get accepted by a compiler, but in a broader sense, relevant to the Real World, which includes a social context.<p>There's a culture and social context around a language, that includes things such as idioms, best practices, libraries, learning material, etc, which are fundamental to the practice of programming in it.
McUsrabout 12 years ago
I don't code a line of C++ if I don't have to.<p>Apple uses C++ in their kernel in a nice way, they don't use virtual methods and templates.<p>I agree totally that C++ looks good and all, and that there might be bright sides to it. But to me, it is not as discernible as C at least. And I do enjoy programming in C, I need to feel I am in control, and C gives me that.
icebrainingabout 12 years ago
The author seems to assume that Linus is against objects. I think this makes it pretty clear: <a href="https://lwn.net/Articles/444910/" rel="nofollow">https://lwn.net/Articles/444910/</a>
MostAwesomeDudeabout 12 years ago
This article cherry-picks and attempts to bang on the table, probably because banging on the facts would not turn out so well.<p>He claims that C was designed by committee, which I can only assume is a defensive projection meant to hide that C++ was designed and is maintained by committee. He points out mplayer as an example of C code that is supposed to be good but is actually bad, which is a low blow. (mplayer's code quality has always been awful and this is well-known in the community.)<p>The railing against C++ object models being bad is similarly defensive, and I get the feeling that the author is deliberately trying to make people forget that pImpls ever happen.<p>C++ is an <i>incredibly</i> obtuse language, full of so many misfeatures and fancy whirligigs that it's difficult to be certain that even repeated reads through a file are giving you the correct impression of structure and flow.