🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Linus Torvalds and C++

Started by
149 comments, last by Anon Mike 16 years, 5 months ago
When we will compare C without standard library, C++ without standard library, and Java without standard library. Java wins, because it's simpler language with more restrictions. More restrictions means compiler is less confused, less confused static compiler could create better optimization... programs are faster without silly macros that should unroll code and similar things.

What is faster, C or C++ depends on compiler and platform. A platform with a static optimizing Java compiler, or C#, or CAML, or whatever like compiler would leave C/C++ in dust when C/C++ compilers are experimental/have problems with compatibility. Don't forget, it's not only language, it's also compiler revision xxxxx with bugfix xxxxxxx.

Now C is probably less bitch to write compiler for... so Linus likes C more. (I'd rather write it in macro assembly, and create a converter between assembly of different platforms, or I'd use Java, and static compilation with asm infusion.)
Advertisement
Quote: Original post by Raghar
Now C is probably less bitch to write compiler for... so Linus likes C more.

Let me get this straight. You think Torvalds prefers C because it's easier to write a compiler for. Despite the fact that the two software projects mentioned in this thread that Torvalds has worked on, the linux kernel and git, are not C compilers. Nor has he listed that as a reason in any of the quotes posted in this thread. Nor is Torvalds listed as a contributer to gcc, yet somehow the difficulty of writing a compiler for the language somehow factors into the reason why he uses it. By that reasoning why don't you think Brainf*ck is his favorite language?
Quote: Original post by SiCrane
By that reasoning why don't you think Brainf*ck is his favorite language?


This comment has inspired me to one day learn Brainf*ck and write a bootable OS in it. Just to say that I've done it.
Quote: Original post by SiCrane
Quote: Original post by Raghar
Now C is probably less bitch to write compiler for... so Linus likes C more.

Let me get this straight. You think Torvalds prefers C because it's easier to write a compiler for. Despite the fact that the two software projects mentioned in this thread that Torvalds has worked on, the linux kernel and git, are not C compilers. Nor has he listed that as a reason in any of the quotes posted in this thread. Nor is Torvalds listed as a contributer to gcc, yet somehow the difficulty of writing a compiler for the language somehow factors into the reason why he uses it. By that reasoning why don't you think Brainf*ck is his favorite language?


I don't really care why he chooses C. It's just another language war that really won't get anywhere. But one thing I've noticed, is that while X years supposedly make people an expert in a language, X years also introduces many bad habits. Almost everyone I know who has been programming for over 20 years seems to write absolutely horrible code imho. I don't think they mean too, and at the same time, I realize that many of their conventions that they use they picked up from when they had to write code like that, as it was the best at the time.

I've already stated my opinion on this whole language war debate going on in this thread. But let's be honest. Even if you dislike C, you cannot deny that C++ doesn't ingrain multiple bad habits. Heck, probably C# and many newer languages do the same thing. 40 years from now, when half of us are retired, or close to retiring, we're probably going to be thought of as crazy for half of the bad code that we right. Not that Linus Torvalds is that old, but I think he was from an era that led to what several people here have called "incompetence" in his programming ability.
For me it heavly depends on what you need...just like the many questions about scene managment in a 3d engine.

I develop mainly in C at work for the NoMachine company, and we cannot use C++ only because we have our XServer that use a Xorg XServer to perform some operations.
Now we're moving something to C++...things can be easier to code, there is OOP (that is more difficult to achieve in C) but the many complexities added from the base that resides the C++ compiler/libraries let our application runs very slowly.

But what if you want to develop something about AI? Using OCaml or other functional languages is faster...

I am curious about the opinion of someone like John Carmack, that used C for many great games...
---------------------------------------http://badfoolprototype.blogspot.com/
I'm really surprise that Linus Torvalds actually hates C++, but it seems (by only reading that particular post), he just try to flame the other guy.
For the C and C++ part, IMHO it depends on how complex/big the application will be. Personally, I don't know why we still need C (other than legacy reason), because basically C++ have all every C features (as far as I know), so probably the discussion are more to "use OOP or not". CMIIW.
Quote: Original post by Oberon_Command
Quote: Original post by SiCrane
By that reasoning why don't you think Brainf*ck is his favorite language?


This comment has inspired me to one day learn Brainf*ck and write a bootable OS in it. Just to say that I've done it.
Don't be like the rest of the herd, write a UTM bootstrapper.

All the bells and whistles of this modern Brainf*ck mumbojumbo eats the minds of promising young programmers like a pack of small dogs. If binary was good enough for Turing, it ought to be good enough for everyone.

[Edited by - Naurava kulkuri on January 7, 2008 3:42:38 PM]
---Sudet ulvovat - karavaani kulkee
Quote: Original post by SiCrane
Quote: Original post by Raghar
Now C is probably less bitch to write compiler for... so Linus likes C more.

Let me get this straight. You think Torvalds prefers C because it's easier to write a compiler for. Despite the fact that the two software projects mentioned in this thread that Torvalds has worked on, the linux kernel and git, are not C compilers. Nor has he listed that as a reason in any of the quotes posted in this thread. Nor is Torvalds listed as a contributer to gcc, yet somehow the difficulty of writing a compiler for the language somehow factors into the reason why he uses it.


Yes when you write something multiplatform, like kernel of heavily multiplatform OS, you need to look at compiler availability, and efficiency. Doesn't have GCC special extensions for Linux kernel only?

While a kernel could be hypothetically written in C++, name mangling, compilation times, and other niceties of C++, might result in somewhat poor code. Yes C results in bad code as well, when compared to assembly. However the said kernel is supposed to be multiplatform, so C is somewhat reasonable choice.

If you'd use C++, how would you prevent usage of the STL, and other unsafe C++ features? By forcing programmers into some restrictions? You'd end with C with classes.

BTW I'd guess the C code would result in quite a lot less lines of code than that simpler language. Just because something is Turing complete doesn't mean that something is efficient.
Quote: Original post by Naurava kulkuri

All the bells and whistles of this modern Brainf*ck mumbojumbo eats the minds of promising young programmers like a pack of small dogs. If binary was good enough for Turing, it ought to be good enough for everyone.


I don't think a behavior of a person that was killed by eating poisoned apple by accident, should be taken without grain of salt.

~_^
Quote: Original post by Raghar
Quote: Original post by SiCrane
Let me get this straight. You think Torvalds prefers C because it's easier to write a compiler for. Despite the fact that the two software projects mentioned in this thread that Torvalds has worked on, the linux kernel and git, are not C compilers. Nor has he listed that as a reason in any of the quotes posted in this thread. Nor is Torvalds listed as a contributer to gcc, yet somehow the difficulty of writing a compiler for the language somehow factors into the reason why he uses it.


Yes when you write something multiplatform, like kernel of heavily multiplatform OS, you need to look at compiler availability, and efficiency.

GCC consists of front ends and back ends. When porting to a new platform, only a new back end needs to be made. The difficulty of parsing and compiling a particular language depends on the front end, which does not need to be touched for new platforms. In other words, the difficulty of a given language has nothing to do with platform support by GCC.
Quote: Doesn't have GCC special extensions for Linux kernel only?

Name them.
Quote:
While a kernel could be hypothetically written in C++, name mangling, compilation times, and other niceties of C++, might result in somewhat poor code.

Compilation times do not affect code quality. Name mangling increases code quality by ensuring type safe linkage, and doesn't even show up at all in the final binary unless you leave debugging information in.
Quote: Yes C results in bad code as well, when compared to assembly. However the said kernel is supposed to be multiplatform, so C is somewhat reasonable choice.

C does not result in bad code compared to assembly. In any meaningful metric of code quality, C fares quite favorable over assembly in areas such as readability, code complexity metrics and ease of maintenance.
Quote:
If you'd use C++, how would you prevent usage of the STL, and other unsafe C++ features?

STL containers are not unsafe C++ features. STL containers have strict exception handling guarantees and are implemented by subject matter specialists that make them quite safe.
Quote: BTW I'd guess the C code would result in quite a lot less lines of code than that simpler language. Just because something is Turing complete doesn't mean that something is efficient.

Has exactly nothing to do with your argument; in fact, directly contradicts it. You said the simplicity of the compiler was his driving motivation, but more expressive languages lead to more complicated compilers. Not to mention that C++ tends to produce fewer lines of code than C, so by that logic, he should be using C++.

This topic is closed to new replies.

Advertisement