11 ms·
Linus Torvalds on C++ (2007)
- mnm1 8y agoI think what he says about C++ to a lesser or greater extent applies to most OOP languages, especially if speed is a concern. After a quarter century of OOP, including years with C++, I still do not understand why it exists or what problems it actually solves. I understand the problems it tries and pretends to solve but that's not the same thing. I still do not see the advantages (as opposed to "advantages") and the disadvantages of the approach are huge and glaring. I think the rise of OOP has led to a lot of programmers who don't know what they're doing because the languages themselves are created in such a way as to encourage bad practices like inheritance and make good practices like composition not obvious or intuitive.
- staticassertion 8y agoEncapsulation. Hope this helps.
- opless 8y agoI'm not sure you know what you're talking about here. If you want to see what OO-in-C might look like, look at golang's object model. You lose some bits of OO design, but many folk just don't need/want them. Exceptions, deep inheritance, etc. Don't get me wrong, I'm well versed in C++/C#/Java, but you can quite easily paint yourself into a corner if you're not careful. C programming requires much more careful thought, and that's probably why Linus isn't too keen on the OO crowd, as that's where, in his opinion, the sloppy programmers have wandered off to.
- staticassertion 8y agoWhy are you even talking about C let alone OO-in-C? > After a quarter century of OOP, including years with C++, I still do not understand why it exists or what problems it actually solves. This is what I was responding to.
- waynecochran 8y agoAny decent GUI API will be OO. It is the right paradigm for that. Abstract Syntax Trees for language translation is another problem where OO is a great choice. Simulation is another good fit.
- pjmlp 8y agoI leave it here, https://subsurface-divelog.org/ https://subsurface-divelog.org/
- sleavey 8y agoTorvalds explains in the original link that C++ is not appropriate for kernel modules. User space programs are another matter.
- ori_b 8y agoThe core logic is in C, and that's not changing. The fact that QT is one of the few sane cross-platform UI choices did force some C++ code into there. http://lists.subsurface-divelog.org/pipermail/subsurface/2013-March/005365.html http://lists.subsurface-divelog.org/pipermail/subsurface/201...
- bb88 8y agoI'll quote the relevant part here, since that's a long email: A word of warning: Linus has very strong feelings about all the things that are wrong with C++ and at times has been known to be less diplomatic than me when explaining his point of view... :-) But he made a clear statement that he is interested in seeing this port happening, as long as most of the program logic that is not UI code stays in (quote) "sane C files". So please keep that in mind as we drive this further. If you read emails around that point of time, GTK+ development had really gone off the rails in everyone's viewpoint, and was frustrating Linus and everyone else.
- posharma 8y agoThis has been posted here several times before. No point discussing the same thing over and over again.
- tosh 8y agoimho as time goes by ‘old’ posts gain new context & meaning
- tosh 8y agorelated: https://en.wikipedia.org/wiki/Monotone_(software)#Monotone_as_Git_inspiration https://en.wikipedia.org/wiki/Monotone_(software)#Monotone_a...
- kristianp 8y agoThe last time it had discussion here was two years ago[1]. Perhaps its time for those who haven't seen it before to take a look? [1] https://hn.algolia.com/?query=Linus%20Torvalds%20on%20C%2B%2B&sort=byDate&dateRange=all&type=story&storyText=false&prefix&page=0 https://hn.algolia.com/?query=Linus%20Torvalds%20on%20C%2B%2...
- projectramo 8y agoWait, so does he like C++ or not?
- webreac 8y agoAround linux 0.99 pl10 or 12, Linus wanted to compile the kernel using C++ compiler. I do not remember exactly the purpose. He has discovered many bugs in g++ and many slowness that were "impossible" to solve because of the existence of exceptions handling. g++ developpers were also not very cooperative.
- bb88 8y agoHe does not. See the other comments in this post.
- cprecioso 8y agoAt least for me it's really fun reading Linus rant; but I wonder what his unkind ways mean for contributors to Linux. I guess it's important to maintain a strong grip on the product when there are so many people touching the code, each one with different interests. But this kinds of attacks on (sometimes clueless) random would-be contributors just leaves me with a bad taste. And a community which is lead by someone who does this will only replicate that behavior. I know I will probably never try and contribute anything to the kernel because of this toxicity; how many more people have taken this decision?
- deleted 8y ago[deleted]
- MrBuddyCasino 8y agoStrongly held beliefs, supported by well-reasoned arguments, are a positive signal for every project leadership. It shows that they care deeply and have a consistent vision about the direction. I'll take a passionate, driven and unfiltered position over pleasant mediocrity any day of the week. Great projects (Python, Linux, OpenBSD, Apple) don't just have an idea what they want to be, but also what not to be. If you have no idea what not to be, you become C++ / Scala / Microsoft. Strong tribes win.
- bb88 8y agoAt different phases of a project, you need different styles of leadership. While I think that was very funny at the time, 11 years later, I think with the maturing of linux, a very different style of leadership is needed than the brashness that won him fans over Microsoft over a decade ago.
- majewsky 8y agoHow would a different type of leader improve the state of the Linux kernel? Honest question, I'm not that much into kernel development, just a happy consumer of their work.
- cprecioso 8y ago
- alexkcd 8y agoDifferent programming domains require different tools. Language wars stem from programmers incorrectly extrapolating the requirements of their domain to other domains that they're unfamiliar with. C is a good choice for kernel development. C is a bad choice for numerical computing. JavaScript is a good choice for web development. JavaScript is a bad choice for kernel development. Some high profile C++ projects: LLVM, Webkit, v8 JavaScript engine, Chromium, Tensorflow, PyTorch, Eigen, OpenCV, Skia, Unreal Engine. C++ is a good fit for those projects: the right mix of expressiveness, portability & performance. It's not a good fit for other projects. Pick the right tool for the job. Move on with your life.