• Advertisement
Sign in to follow this  

Wow such hatred towards C++

This topic is 2997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Please look up Linus on Gamedev.net and sse that this post has been discussed a lot already.

Share this post


Link to post
Share on other sites
We've discussed that, or at least Mr. Torvald's dislike of C++, before somewhere on this website. Ah, here it is. I suggest you and anyone else reads that before we create huge discussion.

Share this post


Link to post
Share on other sites
Its not the first time Linus displays he's anti-social qualities.
He's probably fed up with suggestions about C++, hehe

Even though the thread seems to be about Git, they soon start talking about how C++ is useless for low level OS programming (See a couple of replies later)

Share this post


Link to post
Share on other sites
I didn't read the whole thing, but it appears that there was already some kind of heated confrontation, and perhaps the spirit with which he bashed C++ was used as a way to get someone angry/upset.

Share this post


Link to post
Share on other sites
He likes to go an throw all his toys out of his cot every now and then.
That's his loss.

Share this post


Link to post
Share on other sites
Hmm, attacks on C++ have come from the other side, too - no encapsulation, no modules, no reflection et al. Linus seems to touch on something along these lines further down, too.

It's definitely an eyesore of a language in some several ways. I tend to think of it as a bit of the programmers' kitchen sink, a general wastebucket of 40 or so years of programming legacy - within which are plenty of powerful and quirky constructs with which you can flesh out your designs and generally experiment, but it attracts bugs, and makes bad habits and obfuscated idioms very easy to form.

Anyway, I think C++ is straddling a divide which is about to become a lot more pronounced in the next few years. It will probably eventually fall completely within the systems stream where Straustrup sees it, even if Torvalds is less-than-accepting of it - I seriously don't see C++ holding its own in application programming when apps are just about set to cut themselves loose of the iron entirely.

EDIT: I should say that I don't agree with Linus's idea of what a systems language is, in general, but then again I've always found the GNU/Linux scene's insistence that C is the only choice a bit obtuse.
Also, I find myself becoming more of a fan of Walter Bright.

Share this post


Link to post
Share on other sites
I'm not a programmer, but all I can see is C++ a f*cking hard language, and people should not learn it as a first language (or second), because it leads to tons of programmers, who can't solve an easy, or even trivial programming task, because they are sweating with classes/whatever, instead of the real problem, which could be solved with a humble global variable which isn't included in any classes for example.
We can see a lot of threads about these 'problems' here on Gamedev too.

C is a lot easier and straightforward.

But if someone's a professional in C++, C++ is better than C.

But that's only my humble opinion.

Share this post


Link to post
Share on other sites
Quote:
Original post by szecs
because they are sweating with classes/whatever, instead of the real problem, which could be solved with a humble global variable which isn't included in any classes for example.

The problems of the C++ language are not classes (a concept included in quite any modern language). In addition, global variables are there available if you want to use them, but are most often the bad answer to the problem. Other languages (i.e. Java or C#) don't allow G.V :-)

Quote:

C is a lot easier and straightforward.


You can use C++ just as you used C (in fact, often a C program will compile with a C++ compiler). The fact that C++ offer evoluted tools (template metaprogramming, just to name one) does not mean you have to use it :-)

Note that I don't mean to argue, I just want to clarify a couple of sentences.

About the linus statements, that's perhaps why linux is still based on C, just like unix was 30 years ago :-)

Share this post


Link to post
Share on other sites
Quote:
Original post by szecs
I'm not a programmer, but all I can see is C++ a f*cking hard language, and people should not learn it as a first language (or second), because it leads to tons of programmers, who can't solve an easy, or even trivial programming task, because they are sweating with classes/whatever, instead of the real problem, which could be solved with a humble global variable which isn't included in any classes for example.
We can see a lot of threads about these 'problems' here on Gamedev too.

C is a lot easier and straightforward.

But if someone's a professional in C++, C++ is better than C.

But that's only my humble opinion.
OK, sorry, a million people have said this a million times already. (I posted before reading the other threads.)

Share this post


Link to post
Share on other sites
Quote:
Original post by cignox1
Quote:
Original post by szecs
because they are sweating with classes/whatever, instead of the real problem, which could be solved with a humble global variable which isn't included in any classes for example.

The problems of the C++ language are not classes (a concept included in quite any modern language). In addition, global variables are there available if you want to use them, but are most often the bad answer to the problem. Other languages (i.e. Java or C#) don't allow G.V :-)

Quote:

C is a lot easier and straightforward.


You can use C++ just as you used C (in fact, often a C program will compile with a C++ compiler). The fact that C++ offer evoluted tools (template metaprogramming, just to name one) does not mean you have to use it :-)

Note that I don't mean to argue, I just want to clarify a couple of sentences.

About the linus statements, that's perhaps why linux is still based on C, just like unix was 30 years ago :-)
I told you I'm not a programmer. I don't even know the terms. And I know I can program in C style, and I do that (VS 2008).

I know that global variables are not so good, but if it solves the problem, then be it. You have to solve the problem first, then you can go find a better solutions (like millions have said this a million times already)

Share this post


Link to post
Share on other sites
Quote:
Original post by cignox1
global variables are there available if you want to use them, but are most often the bad answer to the problem. Other languages (i.e. Java or C#) don't allow G.V :-)

Java has public static variables. How is System.out any different from std::cout?

Share this post


Link to post
Share on other sites
C++ lacks the elegance of more modern language. I still like it though because it's familiar and it gives me the ability to do anything I want.

Share this post


Link to post
Share on other sites
I think that he is saying that C++ is useless, because its too low level for it to be classifies as a high level language, and its not low enough for it to be a low level language. Therefore its somewhere in between. I think this is one of the
reason why he hates C++. But I still don't get why he feels that using C will make a better structured and well designed application than using C++?

Share this post


Link to post
Share on other sites
Quote:
Original post by Concentrate
But I still don't get why he feels that using C will make a better structured and well designed application than using C++?


The actual post seems to be more aimed at the legion of terrible C++ programmers who can't use the language safely and tend to OO everything to the Nth degree. Indeed, the main point is that the rigid OO interfaces are more harm than good if they're not well made interfaces and for big/long lived applications, he feels that they can never be well made.

That said, the entire argument is rather silly. C++ has enough faults, but allowing people to misuse programming methodologies with it, or that it's programmers are (by and large) skill-less poo flinging cowboy programmers aren't really of great concern...

Share this post


Link to post
Share on other sites
Crotchety old Linus again.

I already lost all respect for his programming opinions when he came out against (kernel) debuggers. And yeah, this is not new either.

I mean, it's one thing to bash on C++ (a very valid thing to do), it's entirely another to try and pass off C as the better option.

Share this post


Link to post
Share on other sites
Quote:
Original post by MaulingMonkey
I already lost all respect for his programming opinions when he came out against (kernel) debuggers.
I recently had the 'honour' of collaborating with several debugger-oriented programmers (who's names will be withheld to protect the innocent), and my overall impression is along the same lines as Linus'. They jump in, write naive code, spend hours in the debugger tracing why it doesn't work, and miss obvious problems that the debugger isn't equipped to notice (such as garbage results).

Now, I am not saying that debuggers are bad, but I would strongly suggest that the 'debugger culture' among inexperienced programmers is a very bad thing.
Quote:
I mean, it's one thing to bash on C++ (a very valid thing to do), it's entirely another to try and pass off C as the better option.
From a certain perspective, C++ is a hideously opaque language. I can read my system C headers in my sleep, but to read the C++ standard library headers requires careful concentration and a stack of reference materials.

This isn't a fault of the C++ language per se, but it is a complex language, 20 years of hacks and compiler workarounds don't help, and the 'modern C++' of preprocessor and template meta-magic popularised by boost only makes things worse.

And again, I wouldn't advocate that we abandon C++ in favour of C (though maybe in favour of C#), but if you need to write large quantities of bullet-proof, transparent, accountable code (i.e. an OS kernel), C may well be a better choice.

Share this post


Link to post
Share on other sites
I only wanted to comment that the thread linked above contains a great deal of short-sighted generalizing, equating Torvalds opinion with the entirety of the OSS community. Which is complete nonsense of course. Doing a couple quick searches on Sourceforge I found the ratio of Python to C# to C to C++ to Java is pretty close to 1:1:2:3:4.

But yes, Mr. Torvalds is notorious for strongly-worded, heated arguments. Most of the time he's right, but he has been wrong on a couple important arguments that cost the Linux community some talented folks (see Con Kolivas and Alan Cox).

Share this post


Link to post
Share on other sites
Quote:
Original post by Concentrate
What do you guys think about his comment : Linus

I ask because you guys are more knowledgeable(i.e more experienced).


Wow, he's right on the money. I encourage everyone to read his reasons, rather than just assuming that he has some blind hate for C++. And keep in mind that he's really an OS developer, not a game developer. I prefer straight C for many of the same reasons as he does, but for apps that deal with lots of objects (such as games), C++ can make sense to use instead. However, a competent C programmer can do everything that you can do in C++ without much more effort, and the resulting code tends to be easier to optimize for speed and memory.

Programming is one of those things where there is no single "right" answer. It's an interesting mix of science and art. Lots of people will ramble on about "proper design", OOP languages being the answer to everything, and so on. Lots of people also write crappy bloatware code that I want nothing to do with. The quality of modern software is rather horrible, and I blame lazy and/or incompetent programmers, and companies that have so much bureaucracy that real programmers can't do good work.

An experienced programmer knows more than one language, will select the right one for the job, and will break the design "rules" and do things unconventionally when it makes sense to do so. For example, someone who gets offended by the very mention of a "goto" statement is someone that you probably shouldn't take very seriously... While I happen to agree that you should usually avoid them, they definitely do have a time and a place. Preferences are good and fine, but blind hate against such things is indicative of someone who is intellectually blind. The same goes for blind hate against a language, just as it does for blind support for it.

Learn a few languages, learn them well enough to really understand them and use them, and choose the one that is most natural for your project. I share Linus' frustrations with having to deal with things getting screwed up by people who "know" C++ (or in my case, Java) but don't really know how to program, so they just make a mess of things, and often choose a poorly suited language for what they're doing.

Share this post


Link to post
Share on other sites
You'll always have people on both sides of the fence, as this argument isn't exactly a new one. A good open-minded programmer familiar with the C family of languages knows that there are times to use one over the other. Generally, the closer you get to the hardware, the more you should be using C, and visa-versa.

Share this post


Link to post
Share on other sites

This topic is 2997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement