Torvalds on C++

Torvalds Post 1
https://lwn.net/Articles/249460/ Torvalds on C++ mess. So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also off people who cannot see that is just a big additional advantage. If you want a VCS that is written in C++, go play with Monotone. Really. They use a "real database". They use "nice object-oriented libraries". They use "nice C++ abstractions". And quite frankly, as a result of all these design decisions that sound so appealing to some CS people, the end result is a horrible and unmaintainable mess. But I'm sure you'd like it more than git.

https://web.archive.org/web/20080304231021/http://article.gmane.org/gmane.comp.version-control.git/57961 On Thu, 6 Sep 2007, Dmitry Kakurin wrote: > > As it is right now, it's too hard to see the high-level logic thru > this endless-busy-work of micro-managing strings and memory.

The string/memory management is not at all relevant. Look at the code (I bet you didn't). This isn't the important, or complex part.


 * > IMHO Git has a brilliant high-level design (object database, using > hashes, simple and accessible storage for data and metadata). Kudos to > you! > The implementation: a mixture of C and shell scripts, command line > interface that has evolved bottom-up is so-so.

The only really important part is the *design*. The fact that some of it is in a "prototyping language" is exactly because it wasn't the core parts, and it's slowly getting replaced. C++ would in *no* way have been able to replace the shell scripts or perl parts.

And C++ would in no way have made the truly core parts better.

> > and comparing C to assembler just shows that you don't have a friggin idea > > about what you're talking about. > > I don't see myself comparing assembler to C anywhere.

You made a very clear "assembler -> C -> C++/C#" progression nin your life, comparing my staying with C as a "dinosaur", as if it was some inescapable evolution towards a better/more modern language.

With zero basis for it, since in many ways C is much superior to C++ (and even more so C#) in both its portability and in its availability of interfaces and low-level support.

> I was pointing out that I've been programming in different languages > (many more actually) and observed bad developers writing bad code in > all of them. So this quality "bad developer" is actually > language-agnostic :-).

You can write bad code in any language. However, some languages, and especially some *mental* baggages that go with them are bad.

The very fact that you come in as a newbie, point to some absolutely original author doesn't like, is a sign of you being a person who should be disabused on any idiotic notions as soon as possible.
 * trivial* patches, and use that as an argument for a language that the

The things that actually *matter* for core git code is things like writing your own object allocator to make the footprint be as small as possible in order to be able to keep track of object flags for a million objects efficiently. It's writing a parser for the tree objects that is basically fairly optimal, because there *is* no abstraction. Absolutely all of it is at the raw memory byte level.

Can those kinds of things be written in other languages than C? Sure. But they can *not* be written by people who think the "high-level" capabilities of C++ string handling somehow matter.

The fact is, that is *exactly* the kinds of things that C excels at. Not just as a language, but as a required *mentality*. One of the great strengths of C is that it doesn't make you think of your program as anything high-level. It's what makes you apparently prefer other languages, but the thing is, '''from a git standpoint, "high level" is exactly the wrong thing. (Linus)'''

Post 2
https://www.realworldtech.com/forum/?threadid=104196&curpostid=104225

Linus Torvalds (torvalds@linux-foundation.org) on 6/6/10

> Many negative things about C++.

My complaint with C++ is the complexity. My job is coping with complexity getting the details just right so a dumb machine can do a job people care about. I find the enormous number of features in C++ along with the way it makes understanding this piece of code depend intimately on understanding vast quantities of other code at the same time a distracting burden which takes attention away from the real problem I want to work on, the problem my employers are paying me to solve. Yes, those features are intended to reduce complexity and hide dependencies but they just don't seem to work out that way in practice. Yes, I read the reasonable opinions of a great many credible and knowledgable people who don't agree, who say C++ has helped them, but my own direct experience is to the contrary.

>Now, that's not what you always want. I understand very >well why people want less system-oriented languages with >more built-in functionality. As mentioned, support for >both garbage collection and concurrency are quite real >problems, and they are both things you can do in C, but >that you cannot do well with library interfaces, >which is how you normally would extend on C. > >And garbage collection and concurrency are way more than >just syntactic extensions. You can still do them very >badly, of course, so it's not a trivial path to go down, >and I'm not saying hat a language magically becomes "good" >just from supporting one or the other.

I think the chief limitation on C as an application tool is its scope. If you write a standard conforming C program it can read and write files but can't talk on the network or interact with a user in a GUI or do any event based or concurrency based work at all.

C simply doesn't go that far. It is the system and the libraries which complete the picture. By the time you have written anything which is actually useful as an application a great deal of libraries, frameworks and system provided services are involved. Compare to Java. Garbage collection and hiding pointers are small time on the scale of differences between Java and C as Java comes with large quantities of libraries necessary to making a finished application which actually does something. They makes the Java language environment enormous compared to C which is just a language with a tiny standard library.

Language gets far too much attention in this business. It is libraries and system interfaces which matter most to application code. I was tempted to write frameworks just now but frameworks are a mixed blessing at best. What is the difference between a framework and a library? Simple, a library attempts to coexist with other libraries while a framework dominates a program excluding all others forcing the program to fit its organization. If a library doesn't serve all your needs you may be able to write more code or add another library. Like as not a framework will actively get in the way. We have all this work on languages but it is the libraries that really need the attention.

threading
https://web.archive.org/web/20071026005249/http://enfranchisedmind.com/blog/archive/2006/10/21/163 from https://web.archive.org/web/20071021014108/http://www.artima.com/cppsource/threads_meeting.html

https://web.archive.org/web/20071221171327/http://radio.weblogs.com/0103955/categories/stupidHumanProgramming/2006/12/25.html#a229 erlang

https://web.archive.org/web/20071021014108/http://www.artima.com/cppsource/threads_meeting.html

links
https://news.ycombinator.com/item?id=3641212

https://www.reddit.com/r/programming/comments/1szncc/how_much_of_this_is_true_c_vs_c_by_linus_torvald/

https://cppdepend.com/blog/?p=418

https://insights.dice.com/2015/03/10/linus-torvalds-was-sorta-wrong-about-c/

oop inheritance

noun

oop

C coding

cpp