but the thing is, from a git standpoint, "high level" is exactly the wrong thing.
And there you have it. I am no git expert but I am pretty sure on of the reasons for it success is that it is pretty fast and compact compared to other VCS.
"Pretty fast and compact" also applies to Mercurial. The reason git is so big is that Git users can't stop promoting it and github and clapping themselves on the back for using it.
Git would be so much better if they could just shut up.
At least the insults within the C and C++ communities remain somewhat related to the topic at hand. The second poster is Linus telling that the opinions the other fellow expressed about C++ are shit, not that the poster himself is shit. An ad hominem attack is avoided.
Contrast that to the comp.lang.lisp community, for instance. They typically resort to labeling anyone they don't like as a "troll" or a "spammer". The ad hominem attack is the focus of the insult.
And I'll make a prediction: the comp.lang.lisp community members who also post here at Reddit will downmod my comment here because I have spoken nothing but the truth, and it hurts them dearly. I'm sure there'll be a few others who say "I'm not a Lisper, but I'm going to downmod you anyway!", but regardless, I'm still correct.
For the love of all that is holy, people, ad hominem is not Latin for "he insulted me". This internet-forum cliche is really starting to tick me off.
The structure of the fallacy is not even complex. A real ad hominem argument happens when:
Person A advances proposition P
There is something bad about Person A
Therefore, ~P.
In particular, Linus is not making an ad hominem argument here because he is not trying to claim that C++ is bad because Dmitry Kakurin, the author of the original post, is full of bullshit.
If I say "Linus is an asshole, C++ is awesome", the fact that I've insulted Linus does not make this an ad hominem argument. If, however, I said, "Linus likes C, and Linus is an asshole, therefore C is bad", I would be making an ad hominem argument.
Please, please, please stop throwing ad hominem around when what you mean is "it's juvenile to make personal insults in a debate."
The last time I explained that what people call "begging the question" is usually more appropriately said "begetting the question," I got viciously downmodded. Meh.
Are you illiterate? Before trying to refute me, read exactly what I wrote:
The second poster is Linus telling that the opinions the other fellow expressed about C++ are shit, not that the poster himself is shit. An ad hominem attack is avoided.
Yeah, that's right. I explicitly stated that Linus DID NOT make an ad hominem attack.
Jessica used the phrase ad hominem correctly. She points out that Linus never directly attacked the other guy to make his argument, so it wasn't an ad hominem attack. I don't see the confusion here.
It's subtle, because Linus does attack the guy personally, but he never uses it as an argument against C++. This is in contrast to some people who will say "you are just trolling, so you are wrong"
For the love of all that is holy, people, ad hominem is not Latin for "he insulted me".
Hahahaha... but it is. Your entire tirade is specific to an ad hominem argument.
Ad hominem is a Latin term meaning "to the man"
The OP used the term correctly - "ad hominem attack" - an attack to the man.
If you're going to be so pedantic, you'd better recognize that your tirade only applies to "argumentum ad hominem".
If you're going to colloquially refer to "argumentum ad hominem" as "ad hominem", then I suggest you accept other people using the colloquial definition of "ad hominem".
I certainly wouldn't call c.l.l. relaxing. However, there is a surprising amount of insightful feedback offered to those who post intelligent things and "do their homework". Trolls, or suspected trolls, are flamed to death without mercy. The resulting environment is somewhat harsh and dangerous, but at least a good S/N ratio is preserved, which is quite rare in usenet nowadays.
how should we call people who ask same question many times just to provoke replies and giggle reading them?
recently one guy claimed that PHP is a functional programming language (unlike Perl and Python) and that lexical closures are not related to functional programming. do you really believe that he was sincere?
somehow comp.lang.lisp attracts lots of trolls and idiots of different kinds, and this is a problem.
i do not mind cases when people bring up controversial issues. you know, like Richard Gabriel, he made controversial statements (like Objects Have Failed narrative) so he is sort of a troll, but a troll in a good sense of this word.
but most trolls on comp.lang.lisp are not, they are low-quality trolls, looking just to annoy people and nothing else.
But actually comp.lang.lisp is full of idiots who say idiotic things about the language so it is very useful to call them trolls or spammers so that people new to the group don't get misleaded about their postings.
I don't know much about programming--and I will admit that Linus is undoubtedly a very talented and intelligent person--but he can be a huge douche in these discussions. "You are full of bullshit" is a pretty worthless argument. If I hypothetically am full of bullshit, simply stating that I am is pointless because I clearly keep behaving as if I am full of bullshit. I need to know why I am full of bullshit, from the perspective of the person full of bullshit.
The STL is getting a lot of bashing, but we should remember that Alexander Stepanov, the original designer of the STL, is a great admirer of C:
"C was not a quick hack. As computers evolved to handle all kinds of problems, C, being the minimal model of such a computer, became a very powerful language to solve all kinds of problems in different domains very effectively. This is the secret of C's portability: it is the best representation of an abstract computer that we have. Of course, the abstraction is done over the set of real computers, not some imaginary computational devices. Moreover, people could understand the machine model behind C. It is much easier for an average engineer to understand the machine model behind C than the machine model behind Ada or even Scheme. C succeeded because it was doing the right thing, not because of AT&T promoting it or Unix being written with it. "
This ought to be good for karma at least annually.
I'll repeat what I said last time: You have to remember that Linus spends tons of his time reviewing code that other people have written. In C, it's hard to write obfuscated code that doesn't look obfuscated. There are well understood and accepted idioms. But in C++, so much can be going on under the covers that a lot of badness can be hidden in a few diff lines.
I've been reading some kernel modules in C, and I can tell you that any program is one #define away from being a horrible obfuscated mess. Try parsing through 7 levels of include files to track down the root functionality of some poorly defined macro and you'll understand.
In C, it's hard to write obfuscated code that doesn't look obfuscated.
I disagree. The text-based macro system alone invalidates that claim. Silliness with pointers is another easy way to break stuff. And practically all non-trivial data structures are unnecessarily obfuscated in C, because it doesn't provide tools for abstraction as just about every higher level language does in one form or another.
The text-based macro system alone invalidates that claim.
Sure, you can hide anything in macros. But if a macro is going to obfuscate code, rather than make it clearer, Linus probably shouldn't have accepted the patch that added it in the first place.
Compare to a simple C++ expression like:
buffer->clear(25)
which might involve either of two operator overloads, an implicit user-defined conversion, a function template instantiation... any one of which might be completely innocent as a feature of its associated class, but together make it impossible to say exactly how this line will be executed.
Abstraction is good when you trust the abstracter, but I think Linus has a suspicious streak.
I expect you're right about his view here, but what always puzzles me is this: how does it make sense to trust the maintainer of a project to block misleading macros (which can do essentially anything), but not to decline patches that define misleading operator overloads, inappropriate use of templates, or dangerous conversions? It's a bit like the people who object to operator overloading because it can be defined to do something silly, but don't mind that a function called Add really reformats your hard drive.
"You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap" - good comment, having an abstraction such as a list in a library is stupid, every time you need a list you should write one from scratch.
If Linux and git were complete failures, we could call Linus a fool, but they are not. I believe he's touched on an issue that very few programmers dare to admit.
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.
Even architect Christopher Alexander, the father of designs patterns (no it's not the GOF) has something to say about this issue.
In order for the building to be alive, its construction details must be unique and fitted to their individual circumstances as carefully as the larger parts.... The details of a building cannot be made alive when they are made from modular parts.
Now let's throw in Richard P. Gabriel's interpretation:
its modules and abstractions are not too big—if they were too big their size and inflexibility would have created forces that would over-govern the overall structure of the software; every module, function, class, and abstraction is small and named so I know what it is without looking at its implementation.
So maybe C++ (and languages in the same family like java and C#), do have a tendency to make us over design and make needless abstractions or abstractions that are too big? I am not saying that they can't be used properly. But it seems Linus is saying that they will most likely be used incorrectly. And I agree with him.
It sounds like you have read your Alexander in detail so you know it's all about the process of creating. This is where a lot of people get into trouble, especially with OO. I would have to say the fundamental OO design principle from an Alexandrian point of view is to treat abstraction like optimization - do it later, not first. If you have two things, make them both, and if there is a useful similarity for your purpose, then make an abstraction. If you do the reverse like almost everyone attempting to do OO design, you're bound for trouble.
The only reason C has less design insanity is that it lacks language-level facilities for it... Mixing a C language with OO is better done in something like Objective-C or even doing your OO work in Python and the low level details in some C libraries.
do have a tendency to make us over design and make the needless abstractions that are too big?
That is probably true. From what I have seen from languages not in a similar mold, typically in the functional realm, the programs have far less abstraction and are "more to the point". We can shake our finger at programmers and say "stop creating an API" but the languages have a tendency to come out like that even when you have the best intention not to.
From what I have seen from languages not in a similar mold, typically in the functional realm, the programs have far less abstraction and are "more to the point".
I think that's more because functional languages have a better type of abstraction, namely the function and parametric polymorphism, which more maps directly to mathematics, the undisputed king of abstraction. I think ad-hoc/OO polymorphism is fairly unnatural for many problems, and combined with the syntactic overhead of declaring classes, makes it hard to create abstract, but usable interfaces. First-class messages would fix many problems with OO languages.
I don't know, I've seen just as many incoherent disasters in C as in C++.
And pace Christopher Alexander, software is not a building. A building needs to be fitted elegantly with its site; software just needs to be compatible with its surroundings. That is, git's landscape of C and shell is perfectly sited for its Unix environment, but that doesn't mean that Mercurial (which is 100% (edit: 90%) Python) should be rejected as passé modernism, as a nicely engineered artifice that clashes with its surroundings.
Meanwhile, I will see your urban planner and raise you that Jane Jacobs dislikes the waterfall software engineering technique!
I think you shouldn't forget the "on a system level".
Abstraction and Object-Models work very well on higher levels, making the code more maintainable (can't speak about C++, because I don't use it, only in general).
Whatever. Linus is troll. A cave dwelling troll. The guy packs more bile than a fundamentalist neo-con at a gay voting rights parade.
That there's an OS named after him indicates nothing more than the fact that there was a need for a free OS to emerge that crystalized around him. Just like water needs at least one piece of crap in its vessel to be able to start forming crystals and turn to ice.
Linus is that dirt fleck.
Is he intelligent? Sure he is. But I think his bile spewing "I WILL KILLLL YOU AND EAT YOUR LIVER, BITCH!!!" attitude has driven more people against linux than it has driven them to linux.
Anyone who doesn't see linux as what it is: a cash cow for enterprise server works is gullible to say the least. Linux is nothing but self satisfying. It's a consortium of people with money that have formed a little club. There's nothing "free" about the spirit of linux anymore than the spirit of free oil gushing out of the ground.
Sure anyone can contribute, but at the peril of being branded and hazed by the lord and king of the realm: LORD LINUS. Reason is seldom, if ever part of the discussion. Gut feelings and bile often are.
You realize his rant about C++ is nothing more than "I WILL GODDAMN USE NAILS AND BROKEN BOTTLES BEFORE I SHARE A SPOON AND FORK WITH THOSE CUNTS THAT CALL THEMSELVES PROGRAMMERS. AS IF THEY COULD REACH ANY MAGNIFICENCE THAT I HAVE ACHIEVED WHILE IN THE WHOMB OF MY WRETCHED MOTHER"
Edit: I just want to make clear that there is no argument he says in that email which I find acceptable. The only time he comes near to making a valid argument is saying that Boost isn't stable and portable (and quite ironically, he says that using the same style as his original poster, quote: "Boost are stable and portable is just so full of BS that it's not even funny)". Right Linus, smart pointers are not deterministically correct. Riight. Actually, it is funny. Also, his assertion that C++ leads to poor design choice is... I mean, simply absurd. Guns lead to shooting, rm leads to sudo rm -rf. So what. End edit
Whatever Linus writes I dismiss out of hand, and I am a healthier person for it. I've seen many a brilliant person get chewed up by the "kill the morons" attitude that seems to emanate from his vicinity.
And before anyone goes on the FOSS crusade, let me make it clear that I think FOSS is great. But free software does not require colossal attitudes. Just look at the BSD crowd. Linus is a typical "elected tyrant". He usurped popular sympathy while he was the little guy, only to rise to become Stalinesque in his ruling. No other piece of software on earth has the kind of dictator at its helm. Certainly not BSD, nor many good OSS. Not even Java or Microsoft have such a dictator at their helm. Maybe Apple, but he's dying anyways.
Anyone who doesn't see linux as what it is: a cash cow for enterprise server works is gullible to say the least. Linux is nothing but self satisfying. It's a consortium of people with money that have formed a little club. There's nothing "free" about the spirit of linux anymore than the spirit of free oil gushing out of the ground.
You have some good points in your post, but this is ridiculous. You sound like a person with money because if you can't see that a free OS that will run on almost anything actually helps people with no or little money you are blind. Linux is opening up the computing world to people that couldn't afford it before. Saving $100(American) to someone can be a very big deal. Linus still may be an egomaniac, but that doesn't affect the zero dollars it takes to get a good OS these days.
Many people compile their own kernels using (heavily) modified linux sources which Linus is A.O.K. with. I don't see how he would be "lord" for these builds.
Raadt. And they do have some things in common. Both are talented and charismatic people with strong opinions. Ideal traits for someone at the centre of a free software project.
Unfortunately, this is an unfair smear of the FSF. Developing a kernel was never a priority for the FSF. In the 80s the priority was to build a free toolset that could run under Unix (emacs, gcc, etc), not a kernel, because the hardware world in those days was fragmented. The FSF did a terrific job in developing this set of tools. The kernel was to come much later (edit: and to fit in with the FSF's philosophy it would have to be portable).
In the 90s the FSF continued with this attitude, even as intel hardware was becoming ubiquitous. Linus at that point kicked off his kernel development (edit: using the FSF tools as a base) as a stop-gap measure until the GNU kernel became available. He went on record as saying that Linux wasn't meant to be portable or "professional", so its later success was not anticipated. (edit: without portability as a consideration, development was greatly simplified)
It is purely circumstantial that intel hardware is now everywhere, so Linux has been able to take a stranglehold in the free OS market, before interest in developing hurd gained momentum. Now that Linux is portable and is enterprise ready there is only specialist interest in continuing to develop hurd.
In any case: Linus himself has admitted that his role has primarily been that of coordinator: accepting or rejecting this or that contribution. Linux and FSF projects are all collaborative efforts, so to smear the FSF and give Linus all the credit for Linux is misleading.
And Microsoft (twice), and whoever made mach. And college kids in their dorm rooms. In fact, GNU seems to be one of the few entities in the world that is incapable of making a kernel.
Bravo. I remember listening to Linus' git presentation, when he was dumping on SVN and thinking "Damn, that's a little rough!". Sure the guy is smart, but that was a little rude. Like Linus has never made a mistake or done anything stupid. Cast the first stone, and all. Seriously, software development is a collaborative process. Stop acting like an asshole.
If I hadn't seen that presentation, I would have used git much sooner. Nothing beats winning people over to your product by insulting them for choosing their current solution.
Seriously though...I agree. I think Linus is brilliant. He's also an antisocial wanker. And yes, I run Linux...but this nonsense is tempting me to actually branch out and learn a little BSD for once.
What ruling? He's just some dude, and has never occurred to me to want to be taken as anything more than that. Sure he's a bit prickly, but it's not like he's an authority on anything. You can take what he says or leave it.
Linux has little to do with Linus Torvalds at this point. He maintains a tiny piece of what makes up modern distributions.
I take him about as seriously as I take the guy sitting next to me here. They both are guys that talk about programming and computers and sometimes I agree with them.
Almost all good projects I saw which were written in C more or less were manually implementing features C++ has. Difference is that in C it was design decision and came with price and a lot of thinking. In C++ they just come for free and most people just don't think before using them.
I worked most of my career on mostly OO, C++ code, and in the last 2 years I've had to work on a large C/C++ project (mostly C features, a smattering of basic C++).
I can honestly say that the large C codebase is an utter disaster area precisely because the the very basic features of C++ are not there, and coders were not familiar with the concepts that C++ provides. Top of that list is encapsulation, and controlled construction/destruction/copying.
Sure you can make structs and define the functions that work on them, but there's nothing to stop some bozo just deciding he's going to mess with the struct contents in his own code (unless you cast it to something opaque... ugh).
Sure, there are complex C++ features which get you in trouble if they're used inappropriately, but if you use features appropriately, then it's nothing but benefits.
Bad programmers make bad code in any language. Good programmers can make use of appropriate features of C++ to make simpler, better code than you can in C.
Do you really think that these same programmers would somehow magically understand encapsulation and proper life cycle management for entities in the system (which inevitably require memory and have a definite beginning and end)?
I hate to say it but by the time you are good enough in C++ to properly use most of its features you could be equally well versed in C. Well versed C programmers know how to accomplish proper memory management and encapsulation with ease. All of the basic constructs are there. I think I mostly agree with the original poster.
The real moral here is that good programmers understand abstraction and when and how to apply it. I have seen plenty of beautiful and horribly messy C and C++. You just can't judge the languages so easily when you see code written by those that know how to create it in the language.
C nor C++ are, in my opinion, inherently better in the hands of someone with experience in the two languages. I tell you this after reviewing hundreds of thousands of lines of code from some of the largest and most complex C and C++ code bases you can name.
The problem with C++ is its a high level of abstraction. Your "comes for free" is an opaque box which occasionally leaks out and doesn't match your opinion of what the box has inside. Its a classic problem for many higher-level languages. This may or may not be a problem for your particular application domain. It is apparently a problem for git, and after looking at many of its internals I can understand why. The "comes for free" portion simply wouldn't work for the git core.
I don't advocate against C++. I think there are some great C++ tools, toolkits, and software out there. But C++ is simply not universally better than C. C is compact, lean, mean, and easy to understand (when the underlying program is designed well). Each have their place.
Anecdotally: someone on the C++ specification committee told me that he was happy that Java was taking over from C++ as the language that most new programmers gravitate to. That meant the traffic on mailing lists and so on for newbs would die down and the bar of quality would be raised again.
No. I don't think Linus is talking about technology but actually social forces. C++ is bad for Linus's intention of running a successful software project because there is too much variance between good and shitty C++ programmers. He wants to deal with a social group of good programmers and in his opinion, that means using C.
In a recent talk I said something that upset a lot of people: that you could get smarter programmers to work on a Python project than you could to work on a Java project.
I didn't mean by this that Java programmers are dumb. I meant that Python programmers are smart. It's a lot of work to learn a new programming language. And people don't learn Python because it will get them a job; they learn it because they genuinely like to program and aren't satisfied with the languages they already know.
no, his argument is, c++ by design often produces bad programmers. also he says that the few decent c++ programmers don't mind programming in C instead, leaving only those bozos he doesnt want to work with in the first place.
i know too little about programming and programmers language choice to agree or disagree, but those are his arguments.
His arguments are correct. A lot of "programmers" in C++ stay away from C because it's too hard for them to master, or to cover up their terrible coding practices. C is much less forgiving and therefore bad programmers, and bad programming practices, tend to stand out in a much more obvious fashion.
For every language l in the set of languages there exists a member p of the set of bad programmers such that uses(p,l). The set of bad languages is defined as the subset of languages such that there exists a programmer p in the set of bad programmers that uses(p,l). The set of languages and the set of bad languages can be proved to be equal.
But I think Torvalds is suggesting that the cardinality of the set of bad programmers that use C++ but refuse to use C is much higher than that of the set of bad programmers that use C.
Wait, that doesn't sound right. Now where's my installation of LaTeX...
I wrote a camera calibration library as a set of C++ classes, which turned out to be a big mistake. If I did it again, I would write it as a C library.
The problem with C++ for me is that it encourages creating functionality in terms of abstractions which too frequently prove to be inflexible down the road.
On the other hand, I think something like the heavily templated C++ antigrain library is a very good argument for C++, and seems somehow to partake of the minimality and elegance of C.
There are some things I would be very reluctant to part with in C++, RAII and compile-time duck-typing for starters.
You were the one creating the inflexible abstractions not the language. You could create inflexible abstractions in C too. Design is a skill just as much if not more so than writing code.
No doubt my limitations as a programmer played a role. I'm just saying that I've come increasingly to value the concreteness and simplicity of C over the abstractions purveyed by C++.
I also think that we tend to overestimate the benefit of language features (and software features in general), and underestimate the costs of language features, in complexity, in mutual compatibility, in breaking backwards compatibility. The complexity costs tend to be combinatorial.
I also think the whole private/protected/public thing is way over-sold. How many times have you seen a class library with a wild profusion of friend declarations, which end up causing problems when you try to compile on different compilers. And speaking of the combinatorial complexity of language features, I'm still not sure how the template system interacts with friend declarations.
The longer I use C++ the more I'd like to go back to C but in a more "pure functional" style. A really good design doesn't break a program down into "families of objects" but into smaller and smaller families of functions. I think I adhere to the bottom-up design philosophy where you build yourself up a virtual machine of functions (pure, without any side-effects if possible) that make your task easier. Grouping together data structures may also have some value, but not as much as having a cogent and coherent function base available. This is why I think functional programming will eventually take off, when more and more people recognise these profound truths I am sharing with you. :)
They're trying to produce a strongly typed functional language that can fill the same role as c (ie low level hardware/memory control) but is easier to reason about, both for humans and automated checking.
From the site:
"As a litmus test, it is possible to write a MPEG decoder or SHA-1 hash algorithm in BitC that is fully safe, but performs competatively with the C implementation. Today, that can't be done in SML, O'Caml, or Haskell."
Linus vs. Bjarne: an EPIC battle. I've got my money on my hometown boy Bjarne. Then again, I hate C++ with a passion. Screw you, Bjarne! You have made me hate strings!
I'd be willing to bet that if the target of Linus' rant said Java or Ruby or Perl or Lisp or whatever, we'd have a rant against those languages on our hands as well.
Programs written in C have a different feel to them from programs written in C++. You can sort of taste the flavor just when using the finished product.
I think the culture of the language chosen has an effect on the programmer's design choices. Or vice-versa.
It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it.
Just because a bunch of idiots use it to produce crap doesn't make it an inherently bad language....that is a flawed argument.
The results in language X are better than language Y. It does not matter if this is because the communities are different or the languages are different.
I've decided the problem I have with OO is that all its fundamental founding principles are mistakes.
Modeling the real-world structure of the problem is the easiest sort of design, but it's generally a really bad solution. This is essentially the same paradigm as the great realism GUI mistake - make a desktop look like a wooden desk, etc. The strength of a mathematical device like a computer is abstracting well above the problem, first, and then designing an abstract machine that tersely implements the math. This is the true meaning of "optimize the algorithm first".
Data hiding and encapsulation are really fundamentally bad ideas. Getters and setters are a long-winded way of asking for this misfeature to please go away. If you cannot access the implementation, the capabilities of the object are a closed set. If the op you need isn't in that set, you are going to have to resort to dirty hacks. (Hence YAGNI - fighting the coder's fear of being boxed in, and resulting over-engineered objects, by stepping outside the limits of the language and into the refactoring code editor. This sorta works, unless as often happens there are parts of the code you can't alter.)
Inheritance itself is a dirty hack, extending "has-a" by cutting a hole in encapsulation. As a means of mixing together the descendant class with the capabilities and interface of the ancestor, it has its uses but they aren't common. It's easily simulated when needed (cf Lua), and it's nearly always misused where interface abstraction ("type classes") would be appropriate. Inheritance doesn't deserve its central place in OO and it certainly is not a useful mechanism of code reuse.
Code reuse itself is a poorly considered concept. Concieved back when most reuse was manual cut-and-paste, OO originally thought of classes being shared between projects and extended when needed with inheritance. It turns out they are too fine-grained for that, and the mere attempt causes hopeless tangles of version dependency. Modern OO answers that at two levels. In the large, libraries. In the small, refactoring common code into methods or tool objects (recognizable by a name that's a nominalized verb). This last is really nothing more than getting the compiler to do the cut-and-pasting for you. It results in "ravioli code". The very words "code reuse" lead the coder astray. The right word is "abstraction". (Yes, even libraries are abstractions - something I wish more lib designers would notice.) A good OO programmer instinctively seeks natural abstractions. He then generally has to fight the language and the closed-set nature of objects to implement them. Worse, he might bump up against an immutable library and just have to stop. When libraries don't try to be abstractions, they give you reusable code but at the expense of poor fit. (This is why hooking together frameworks in Java feels so stifling: each one is freedom lost.)
Finally, objects themselves, keeping the code with the data. Again, the problem of the closed set - in this case, one part of the code is privileged over others simply because of its location. In reality except in the simplest designs, the code is not kept with the data. Hooks are added to the object to open its encapsulation and support code abstracted elsewhere. So this privileged position becomes occupied by nothing but encapsulation openers, a mockery of the original idea.
Getters and setters are a long-winded way of asking for this misfeature to please go away.
Most languages give you the ability to make a member public, so you don't have to work around it that way. The point of accessors is to be able to trigger important side effects when a value changes, so that the program's state remains consistent. The point of putting them in from the beginning is to leave that option open in the future. Nice languages give you the ability to automatically synthesize accessors until/unless a more specific implementation is necessary.
A lot of people misinterpret the point of OO, and pay lip service to the model without understanding how to take advantage of it. Code reuse is widely overstated as a goal of OO. The point of encapsulation is not merely "data hiding" but "implementation hiding". The idea is to be able to go back and change the means by which an object works without breaking all the code that uses it. Being able to do this is extremely useful if you don't like rewriting projects from scratch.
What are the strengths of the structures you use when laying out a program in C? I'm always uncomfortable about the global namespace, because I'd be inclined to make a function that had a name that worked in one context, but not in another. Scenario where it would be bad: you create a function but somewhere else is in the program there's a similar concept and it's tempting for maintenenace programmers to use that function and therbey skip a step or something?
Another one is the way that you need to do things in a particular order. Say you have a structure for representing a block of data and you need to random verbs over it in a particular order. In OO it's pretty straightforward because you can use typing to take some args, do your businses logic and spit it out, but there's the possibility that - if the functions are fine-grained - it will be difficult to know what order they're supposed to be called in to tweak the data.
Another thing - libraries. Say I want to sit down and hack something out as a proof of concept. Do I have to roll all my own datastructures every time, etc? If not - then what libraries are standard, and what are not if I want to do portable things? (I tend to be unix based, so not so interested in Windows answers, although that's where most of what little experience I have has been)
And how do you differentiate easily between C libraries that are safe, and all the crud that's still in the unix kernel but which you shouldn't use?
Are there maintenance problems with C based on these things? I suspect there are tricks I don't know about and hope to learn from the answers :)
Global namespace can be worked around. A function can be declared "static" so it can only be seen in the current translation unit. You can share a function between translation units in a .so/.dll and make it private to the library. Exported symbols should always use prefixing to simulate namespaces. It's not perfect but it's workable. There's a great book on modular programming in C, but I can't remember the title at the moment.
Do I have to roll all my own datastructures every time, etc?
This is a real problem that always exists in lower-level languages like C (or even C++). Interoperating between code which use different representations of everything is a pain. C programmers tend to stick to simple data structures for straightforward programming (arrays, structs, lists and trees). When sophisticated data structures are needed, they tend to roll-their-own, optimising to the specific problem being solved (instead of using generic but slower libraries). There are great libraries out there, but you have to look for them. Java/C#/etc. tend to hold your hand and give you everything by default, which has spoilt a lot of programmers.
A significant portion of this seems to boil down to: "I don't like the thinking of programmers who prefer C++."
Although Mr. Torvalds gives a few reasons while he doesn't like their thinking -- aside from essentially calling them stupid -- he fails to support these abstractions to any useful degree.
Not only that, he should know better, and I think he is lying, and intentionally at that.
anybody who tells me that STL and especially Boost are stable and portable is just so full of BS
Well, I don't know about git, but... How many compilers compile Linux kernel? One: gcc. Oh, and Intel's (or so MSDN told us somewhere). Another thing: how many compilers without non-standard extensions to C compile Linux? 0. Yep, that's right, 0. Check it out, it's true: kernel code is using gcc-specific language extensions.
How many compilers compile STL and Boost? Well, more than two, check it out.
(Yes, I know there's the other kind of portability where my argument breaks, but my purpose is to show his BS, and is irrelevant if we speak about git - hardware taht will run git will run compilers that support STL and Boost).
And he dares speaking about portability? Puh-lease!
Also... What is not stable about STL and Boost, e.g. compared to git (nothing is ultimately stable, anyone with half a brain gets that)? No, really, I would like to see the example, because I am convinced he doesn't have it ( hey, just like he is convinced these are not stable :-) ).
In fact, in the interest of intellectual honesty, I would like to see a comparison of issue/code size ratios in two cases. Then we could talk. Otherwise, stability argument is utter BS.
And WTF is this about abstractions that are inefficient down the road!? Language is certainly not forcing anyone to create any abstractions. Yes, it is easy with C++ and hard with C. But it does not follow that they will be created. That argument is hollow.
Here's what I think: the issue here is not that C++ is bad. The issue is that:
Linus is afraid of abilities of it's own team/community to work with it well.
introducing C++ into the code base would mean a rewrite. This is not realistic, nor needed. (IMO, that is the only acceptable argument, but lookey here, he didn't pull it at all!)
So... He was simply being dishonest. Perhaps because he is an ass, or perhaps he just wanted to shut up the other guy in order to avoid detraction.
I agree. He is also wrong about the language being that bad, IMHO. C++ has a bit of a kludgy syntax, but it's very good for providing powerful abstractions without sacrificing close-to-the-metal performance.
Me, I could not imagine coding anything with a lot of state without objects. What a mess!
Also: once you get good at templates, you can do some amazing things with templates. Let me give you an example:
I wrote a VM. A simple VM, big switch statement in the middle, etc. It's for genetic programming. Well guess what I was able to do?
Template it on its data type.
Write a class that wrapped the SSE 128-bit data types.
Vectorize my VM with no changes to the VM core by plugging in my SIMD vector class as the VM's template parameter.
So now I have:
Program< SIMDVector<double,2> >
Program< SIMDVector<float,4> >
Program<float>
Program<double>
No changes to Program.hpp. Do that in C!
In C you'd have one of: a clone-and-hack model with different duplicates of the VM for different data types -- change the VM and you have to change them all! -- or you'd have a bunch of if's in your VM to manage different data types. Indirections are expensive; on modern processors an 'if' can cost as much as a half-page of hard-core math. So you've just slowified your VM to support multiple data types. Nice.
You can write faster and more maintainable code in C++ if you know what you're doing. Templates are IMHO a feature that's more powerful and more indispensable than objects. I find myself writing fairly shallow object hierarchies (if there's a hierarchy at all!) in C++ but using templates a lot.
But in Torvalds' defense: he does very very bare-metal programming. I'm not sure that I would use C++ for an OS. It produces too much object code bloat.
There are good coders in any language. There are also the kind of coder that you have to clean up after. I have seen bad C code. I have seen bad C++ code.
But I have also seen beautiful, artistic, amazing code in both languages
Well do you know who used C++? Hitler! His entire strategy system was coded in it. Why do you think he lost the war? (Go ahead, Godwin me. I don't care)
Dunno.. the one we wrote in my compilers class was pretty good. It only worked with 3 keywords, but hey, whoever needs any more is having a really bad day... :P
"I never saw a project for which C was better than C++ for any reason but the lack of a good C++ compiler. " -- Stroustrup
And since the set of "really good C++ compilers" is empty, the set of projects for which C++ is better is thus also empty, and therefore Linus is right. QED. Bravo! You've hit the nail right on the head! :-)
People do write code in an object oriented style (think GTK libs) in C, so his object model rant is not totally correct. You can still have to substantially change your design with C.
Anyone else find it ironic that Linus is a huge fan of KDE and that whole project, along with the gui toolkit it depends on, is written in C++?
There is a very, VERY small silver of wisdom to his rant in that object oriented design principles are taught to novice programmers in the hope they'll somehow magically become ace programmers, when, as the saying goes, you can write fortran in any language? Doesn't matter if it's object oriented or not.
From my personal experience, while bad object oriented programming is a wreck, when it's done right (and Qt is an excellent example of "doing it right") it's a thing of beauty.
I was under the impression that Linus just preferred KDE over GNOME, not that he was a huge fan in particular. It is still ironic, though. After all, KDE (and Qt) certainly benefit from C++'s strengths.
It really depends on the application. I think for what Linus does he does not need much inheritance, so structs and function pointers are enough, and he doesn't want any code duplication from templates, so he uses void pointers or whatever. At that point, C++ doesn't offer much, although operator overloading and smart pointers and destructors are still kind of nice.
Full OO seems to be really nice for some business and simulation applications, but unnecessary for a lot of systems and compilers and other low-level CS junk. Something like OCaml or D would probably be nice, except that the compilers aren't mature enough, or the runtimes lack some grotty feature or whatever. And the part about porting the existing system.
he doesn't want any code duplication from templates, so he uses void pointers or whatever. At that point, C++ doesn't offer much
Well, except that with C++ and a little planning and insight, you can get the type-safety of templates without much code duplication at all.
Just make a non-template implementation (that deals in void *, just as you would in C), then wrap that in a "thin template" that does the casts to and from void *for the client. Since only the wrapper is templatized, you get very little code duplication (possibly close to none if your compiler is decent at inlining stuff). Since the error-prone casts are encapsulated in the template-wrapper, you can get them right once, at the time when you want to focus on that issue, instead of the time when you're trying to write client code.
Not really. Remember that even if there were a suitable language (perhaps the D language), there needs to be a compiler for every platform you intend to support.
The best thing to do is probably to move as much code as possible to a higher-level language like Python or Lua, and keep the core in C/C++.
Linus can shout whatever he want, but he is actually shouting to bad PROGRAMMERS, not the language. There is nothing wrong with the basics of C++, it's the use of it. C++ gives you much more control over your code, and therefore much more ways to fuck up.. . some people simply don't know how to handle power when they get it.
Yet another one who talks about C++ without knowing anything about it. He's not the first, nor the last.
He does have a point though: it's so hard to make a working program in C (without buffer overflows and stuff like that) that bad programmers give up early, and only good programmers stay. The low barrier of entry has given C++ and PHP their bad reputation.
C++ has probably the highest barrier to entry of all the languages. It takes an extremely long time to go from beginner to intermediate level and the number of experts are in the hundreds in the world. That isn't a compliment to C++ though, it's obviously a negative thing. We, as C++ developers, want as many competent engineers as possible to develop libraries for us and so that we can hire them.
Writing good OO code in C++ is tough. Writing mediocre code in C++ isn't really all that tough, though. If you do your best to always use std::string, and std::vector, etc, you can almost pretend that there's no memory management involved.
I know all about it and I agree with him point for point. C++'s landscape is populated for the most part with people unable to come to grips with the collection of true complexities and subtleties that is C++.
Its not hard to make a working program in C without buffer overflows and stuff if you are really a good C programmer. Like it is not hard to make a good C++ program if you are a really good C++ programmer. The bar is lower for C programmers (the language and model is simple).
The bar is impossibly high for most programmers in C++ because of the level of complexity introduced by the language. I don't seek C++ work anymore for the same reasons Linus did not choose it. I'm sick of cleaning up after idiots and idiots abound.
That's precisely his point in a nutshell. C++ attracts bad programmers because they can't cut it in C; their bad programming practices stand out too much. Switching git (or the kernel) to C++ would encourage the losers to try to get in on the act, making the job of Linus (and everyone else on the kernel crew) a hundred times harder than it already is.
code and prejudice. c++ is just a language. this offensive approach is so silly (language wars). anyway he's not an authority for me. freetards made him famous, not his words/code.
Funny how everyone takes Linus's word as gospel. Just because Linus Torvald doesn't like C++ or the numerous great features it offers (outside of the OO paradigm) you're now going to see a mass of wanna-be linux "hackers" claiming C++ is a HOARABLE language. What a bunch of idiots (linus included).
Sorry ... I don't agree with Linus on this one. I've written C/C++ for going on 18 years and I personally find C++ to be a really superb language ... and I also think the Linux kernel is a mess organizationally.
Case in point ... the one and only kernel code project I tried was to use Linus's "extensible file systems" to add a new file system primitive ... good luck doing that.
It was only possible with custom kernel compile re-writes and by directly violating Linus's horrifically clunky #ifdef structure related to proper permissions as to what should and should not be a properly authorized kernel module. To add a new file system as a third party and to do so in a consistent manner would require substantial chaining modifications to virtually all of the kernel files ... just to add a file system.
In C++ you would simply derive an object from the file system object and it would be over.
All of this crap is because Linus doesn't like object-oriented design. There are issues with C++, primarily related to code invisibility and optimization cases but these can always be improved in real-world testing and optimization where the cases affect performance.
Linus is trashing object oriented design, but what is his real world experience in a fully OO architecture? He doesn't have any. He's never tried to design an OO project and he doesn't want to be forced to so he resorts to these sorts of profanities rather than a more clear description of -WHY- he hates OOD so much.
Linus has done a great service to the world and computer science at large, and he's been a personal hero of mine for many years, but after having read that ... I think it's time for him to be replaced. There are smarter OS architects out there than him ... and yes, they use object-oriented design.
Bullshit. File systems are added to the kernel all the time. You basically have to create one C file and edit some Makefiles. I don't know what you wanted to do, but your filesystem must be very different from everybody elses if you have to change files all over the place.
I don't think C++ would have helped in that case. If the structure of your design doesn't allow for some feature, you will have hard time implementing it in any language.
Given that Linux has already weighed in on the matter, no one is going to care that I, a lowly engineer at a major game developer, completely agree with him.
I started out with just C. After perhaps five years I could architect and implement major systems, I understood the language inside and out, I stuck to good coding standards, layout guidelines, etc. I made sure everything was const correct. And so on.
I had learned C++ and object orientated programming and knew what it was all about, but didn't feel the need for it in any of the things I was working on.
After about five years, I began to want to use some of the features of C++, and at the company where I now work we use a small subset of C++ features, very carefully. We don't use any STL (we develop for the Xbox 360, so it's a terrible idea to do runtime memory allocation), we hardly ever use complex class hierarchies, we don't use Boost, we hardly ever use templates.
I consider myself a far, far better programmer for having done it this way. I have learned WHY C++ is necessary, and what problems it is trying to fix. I didn't jump straight in and try to use all the really rather complex constructs from the start, instead I waited until I needed them.
It seems he's just a micro-managing masochist. Just because he is programming "great" doesn't make him right 100% of the time. I don't doubt his ability, but I'd rather work alone than with somebody who can't understand the need to be able to have your code communicate with other people as well as the computer.
I think C++'s issue is that you have to manage the use of the language as much as the actual code. There isn't much to C compared to C++. So to use C++ on a project you can't have developers submitting all different styles/Boost/STL/strings junk.
i was inclined to downvote this based on sheeple falling into the trap of following via cult of personality, you know, those who admire linus torvald so much... but i kinda agree with him over this.
I thought the guy in the comments made some good points, as do the folks here at reddit. Yes, Linus has a valid point but he sure is vitriolic about it.
Realistically, C is probably still the most practical systems programming language but that doesn't mean that C++ doesn't offer advantages, even for building operating systems and other software. I actually think that in a lot of ways both C and C++ are outdated, even as approaches to systems programming. Which is not to say that I think that there are a lot of popular and well supported alternatives but here are a couple of things that are at least moving in the right direction (forward): the D systems programming language and House, an operating system written in Haskell.
Which I found whilst googling and was the first time reading it. What are the chances that two people would submit the same article in 10 hours of eachother, the same 14month old article.
If you avoid crap like STL and MFC, many C++ features really are an improvement over C.
I find C++ very useful for lots of things. But I am NOT one of those who insists on absolutely strict encapsulation with an endless maze of const declarations and getter-setter functions.
In short, I am basically a C programmer who uses, and loves, SOME of the extensions provided by C++.
And yes...I also love strong opinion, it drives my wife crazy.
Yeah, how dare someone suggest using something as nonportable as the STL or Boost on a project like git*!
* Of the three mentioned pieces of software, finding the one that until very recently ran only on Linux-like Unix variants and has large blocks of functionality implemented in bash is left as an exercise for the reader.
30
u/gregK Dec 17 '08 edited Dec 17 '08
don't miss his other reply where he elaborates more on this.
And there you have it. I am no git expert but I am pretty sure on of the reasons for it success is that it is pretty fast and compact compared to other VCS.
59
u/lyontamer Dec 17 '08
Linus ranting? No way!
228
u/[deleted] Dec 17 '08 edited Dec 17 '08
I enjoy the directness of programmer conversations.
17
u/kefex Dec 17 '08
The STL is getting a lot of bashing, but we should remember that Alexander Stepanov, the original designer of the STL, is a great admirer of C:
"C was not a quick hack. As computers evolved to handle all kinds of problems, C, being the minimal model of such a computer, became a very powerful language to solve all kinds of problems in different domains very effectively. This is the secret of C's portability: it is the best representation of an abstract computer that we have. Of course, the abstraction is done over the set of real computers, not some imaginary computational devices. Moreover, people could understand the machine model behind C. It is much easier for an average engineer to understand the machine model behind C than the machine model behind Ada or even Scheme. C succeeded because it was doing the right thing, not because of AT&T promoting it or Unix being written with it. "
16
u/oldbasara Dec 18 '08 edited Dec 18 '08
No opinions only experience here
Have worked on a speech synthesizer, an IP-PBX, and an analysis tool for petroleum engineers.
All were written in "using minimal C subset of C++".
Difficult to trace memory leaks, spaghetti code, unclear logic, very difficult to correct bugs and/or add features were the norm.
Moved to full featured C++, STL and BOOST against almost all developers' wishes (most prevalent excuse was "C++ is too complex").
Memory leaks went away, code became much concise, logic became more clear, bugs were easily removed and features were easily added.
And 2 of the 3 were cross-platform on Linux and Windows (we also made a Solaris release of the TTS for one customer)
For me, refusing to work with C++ has only the following reasons: -
As for system level programming, I suppose BeOS was C++ and I have only heard praises about its capability and design.
49
u/twoodfin Dec 17 '08
C++ is a horrible language, says Linus Torvalds.
This ought to be good for karma at least annually.
I'll repeat what I said last time: You have to remember that Linus spends tons of his time reviewing code that other people have written. In C, it's hard to write obfuscated code that doesn't look obfuscated. There are well understood and accepted idioms. But in C++, so much can be going on under the covers that a lot of badness can be hidden in a few diff lines.
11
u/Gupie Dec 18 '08
"You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap" - good comment, having an abstraction such as a list in a library is stupid, every time you need a list you should write one from scratch.
35
u/43P04T34 Dec 17 '08 edited Dec 17 '08
The one thing about Linus that bothers me is that he always beats around the bush.
Thank you for the karma, folks. I haven't had a good karma day in weeks.
86
u/gregK Dec 17 '08 edited Dec 17 '08
Bravo.
If Linux and git were complete failures, we could call Linus a fool, but they are not. I believe he's touched on an issue that very few programmers dare to admit.
Even architect Christopher Alexander, the father of designs patterns (no it's not the GOF) has something to say about this issue.
Now let's throw in Richard P. Gabriel's interpretation:
So maybe C++ (and languages in the same family like java and C#), do have a tendency to make us over design and make needless abstractions or abstractions that are too big? I am not saying that they can't be used properly. But it seems Linus is saying that they will most likely be used incorrectly. And I agree with him.
7
u/thesinker Dec 17 '08 edited Dec 17 '08
Linus is in good company:
(older comments)
88
u/easlern Dec 17 '08
Can't wait for the next blog post: "You kids get the hell off my lawn."
23
u/sitq Dec 17 '08
Almost all good projects I saw which were written in C more or less were manually implementing features C++ has. Difference is that in C it was design decision and came with price and a lot of thinking. In C++ they just come for free and most people just don't think before using them.
49
u/rbobby Dec 17 '08
C++ is bad because bad programmers use it? Huh? A hammer is bad because bad carpenters use it? Not the soundest logic I've ever read.
5
u/generic_handle Dec 18 '08
It's like the unholy meeting of comp.sys.linux.advocacy and comp.lang.c++.advocacy.
I agree with Linus's general points, but I swear, he has to spend hours crafting these for maximum troll impact.
34
u/kefex Dec 17 '08 edited Dec 17 '08
The longer I use C++, the more I like C.
I wrote a camera calibration library as a set of C++ classes, which turned out to be a big mistake. If I did it again, I would write it as a C library.
The problem with C++ for me is that it encourages creating functionality in terms of abstractions which too frequently prove to be inflexible down the road.
On the other hand, I think something like the heavily templated C++ antigrain library is a very good argument for C++, and seems somehow to partake of the minimality and elegance of C.
There are some things I would be very reluctant to part with in C++, RAII and compile-time duck-typing for starters.
9
u/cranktheguy Dec 17 '08 edited Dec 17 '08
Linus vs. Bjarne: an EPIC battle. I've got my money on my hometown boy Bjarne. Then again, I hate C++ with a passion. Screw you, Bjarne! You have made me hate strings!
18
u/[deleted] Dec 17 '08
WebKit is a really big C++ project with good code. It's not impossible sheeple!!
49
u/chedabob Dec 17 '08
Is there anything he doesn't bitch and moan about?
4
u/[deleted] Dec 17 '08
I'd be willing to bet that if the target of Linus' rant said Java or Ruby or Perl or Lisp or whatever, we'd have a rant against those languages on our hands as well.
4
u/raldi Dec 17 '08
Programs written in C have a different feel to them from programs written in C++. You can sort of taste the flavor just when using the finished product.
I think the culture of the language chosen has an effect on the programmer's design choices. Or vice-versa.
7
u/Omikron Dec 17 '08
Just because a bunch of idiots use it to produce crap doesn't make it an inherently bad language....that is a flawed argument.
15
u/JulianMorrison Dec 18 '08
I've decided the problem I have with OO is that all its fundamental founding principles are mistakes.
Modeling the real-world structure of the problem is the easiest sort of design, but it's generally a really bad solution. This is essentially the same paradigm as the great realism GUI mistake - make a desktop look like a wooden desk, etc. The strength of a mathematical device like a computer is abstracting well above the problem, first, and then designing an abstract machine that tersely implements the math. This is the true meaning of "optimize the algorithm first".
Data hiding and encapsulation are really fundamentally bad ideas. Getters and setters are a long-winded way of asking for this misfeature to please go away. If you cannot access the implementation, the capabilities of the object are a closed set. If the op you need isn't in that set, you are going to have to resort to dirty hacks. (Hence YAGNI - fighting the coder's fear of being boxed in, and resulting over-engineered objects, by stepping outside the limits of the language and into the refactoring code editor. This sorta works, unless as often happens there are parts of the code you can't alter.)
Inheritance itself is a dirty hack, extending "has-a" by cutting a hole in encapsulation. As a means of mixing together the descendant class with the capabilities and interface of the ancestor, it has its uses but they aren't common. It's easily simulated when needed (cf Lua), and it's nearly always misused where interface abstraction ("type classes") would be appropriate. Inheritance doesn't deserve its central place in OO and it certainly is not a useful mechanism of code reuse.
Code reuse itself is a poorly considered concept. Concieved back when most reuse was manual cut-and-paste, OO originally thought of classes being shared between projects and extended when needed with inheritance. It turns out they are too fine-grained for that, and the mere attempt causes hopeless tangles of version dependency. Modern OO answers that at two levels. In the large, libraries. In the small, refactoring common code into methods or tool objects (recognizable by a name that's a nominalized verb). This last is really nothing more than getting the compiler to do the cut-and-pasting for you. It results in "ravioli code". The very words "code reuse" lead the coder astray. The right word is "abstraction". (Yes, even libraries are abstractions - something I wish more lib designers would notice.) A good OO programmer instinctively seeks natural abstractions. He then generally has to fight the language and the closed-set nature of objects to implement them. Worse, he might bump up against an immutable library and just have to stop. When libraries don't try to be abstractions, they give you reusable code but at the expense of poor fit. (This is why hooking together frameworks in Java feels so stifling: each one is freedom lost.)
Finally, objects themselves, keeping the code with the data. Again, the problem of the closed set - in this case, one part of the code is privileged over others simply because of its location. In reality except in the simplest designs, the code is not kept with the data. Hooks are added to the object to open its encapsulation and support code abstracted elsewhere. So this privileged position becomes occupied by nothing but encapsulation openers, a mockery of the original idea.
9
u/berlinbrown Dec 17 '08 edited Dec 17 '08
I am guessing that Linus won't like anything but C.
I am scared what he will say about Java.
6
u/cratuki Dec 17 '08
What are the strengths of the structures you use when laying out a program in C? I'm always uncomfortable about the global namespace, because I'd be inclined to make a function that had a name that worked in one context, but not in another. Scenario where it would be bad: you create a function but somewhere else is in the program there's a similar concept and it's tempting for maintenenace programmers to use that function and therbey skip a step or something?
Another one is the way that you need to do things in a particular order. Say you have a structure for representing a block of data and you need to random verbs over it in a particular order. In OO it's pretty straightforward because you can use typing to take some args, do your businses logic and spit it out, but there's the possibility that - if the functions are fine-grained - it will be difficult to know what order they're supposed to be called in to tweak the data.
Another thing - libraries. Say I want to sit down and hack something out as a proof of concept. Do I have to roll all my own datastructures every time, etc? If not - then what libraries are standard, and what are not if I want to do portable things? (I tend to be unix based, so not so interested in Windows answers, although that's where most of what little experience I have has been)
And how do you differentiate easily between C libraries that are safe, and all the crud that's still in the unix kernel but which you shouldn't use?
Are there maintenance problems with C based on these things? I suspect there are tricks I don't know about and hope to learn from the answers :)
6
u/[deleted] Dec 17 '08 edited Dec 17 '08
A significant portion of this seems to boil down to: "I don't like the thinking of programmers who prefer C++."
Although Mr. Torvalds gives a few reasons while he doesn't like their thinking -- aside from essentially calling them stupid -- he fails to support these abstractions to any useful degree.
29
u/Gotebe Dec 18 '08
He is wrong.
Not only that, he should know better, and I think he is lying, and intentionally at that.
Well, I don't know about git, but... How many compilers compile Linux kernel? One: gcc. Oh, and Intel's (or so MSDN told us somewhere). Another thing: how many compilers without non-standard extensions to C compile Linux? 0. Yep, that's right, 0. Check it out, it's true: kernel code is using gcc-specific language extensions.
How many compilers compile STL and Boost? Well, more than two, check it out.
(Yes, I know there's the other kind of portability where my argument breaks, but my purpose is to show his BS, and is irrelevant if we speak about git - hardware taht will run git will run compilers that support STL and Boost).
And he dares speaking about portability? Puh-lease!
Also... What is not stable about STL and Boost, e.g. compared to git (nothing is ultimately stable, anyone with half a brain gets that)? No, really, I would like to see the example, because I am convinced he doesn't have it ( hey, just like he is convinced these are not stable :-) ).
In fact, in the interest of intellectual honesty, I would like to see a comparison of issue/code size ratios in two cases. Then we could talk. Otherwise, stability argument is utter BS.
And WTF is this about abstractions that are inefficient down the road!? Language is certainly not forcing anyone to create any abstractions. Yes, it is easy with C++ and hard with C. But it does not follow that they will be created. That argument is hollow.
Here's what I think: the issue here is not that C++ is bad. The issue is that:
So... He was simply being dishonest. Perhaps because he is an ass, or perhaps he just wanted to shut up the other guy in order to avoid detraction.
3
u/GotEmLookin Dec 18 '08
VICTORYYYY!!!!!!!!
3
u/[deleted] Dec 18 '08
I continue to assert that every new feature added to C++ is designed to fix the previous new feature added to C++
Gime Delphi anytime (grin)
17
u/[deleted] Dec 17 '08
There are good coders in any language. There are also the kind of coder that you have to clean up after. I have seen bad C code. I have seen bad C++ code.
11
u/nat1192 Dec 17 '08 edited Dec 17 '08
Well do you know who used C++? Hitler! His entire strategy system was coded in it. Why do you think he lost the war? (Go ahead, Godwin me. I don't care)
27
u/diet_c0ke Dec 17 '08
I would have just replied with this:
"I never saw a project for which C was better than C++ for any reason but the lack of a good C++ compiler. " -- Stroustrup
6
u/yesimahuman Dec 17 '08
People do write code in an object oriented style (think GTK libs) in C, so his object model rant is not totally correct. You can still have to substantially change your design with C.
7
u/clipmann Dec 17 '08
GO LOLCODE
4
u/[deleted] Dec 17 '08
Let's just cut to the chase here. Why don't they both just whip it out and measure up? Then we can all move on with our lives.
4
u/peabody Dec 17 '08
Anyone else find it ironic that Linus is a huge fan of KDE and that whole project, along with the gui toolkit it depends on, is written in C++?
There is a very, VERY small silver of wisdom to his rant in that object oriented design principles are taught to novice programmers in the hope they'll somehow magically become ace programmers, when, as the saying goes, you can write fortran in any language? Doesn't matter if it's object oriented or not.
From my personal experience, while bad object oriented programming is a wreck, when it's done right (and Qt is an excellent example of "doing it right") it's a thing of beauty.
20
u/velco Dec 17 '08
Managing a successful kernel project makes you an authority on all things even remotely connected to computing.
5
u/catxors Dec 17 '08 edited Dec 17 '08
It really depends on the application. I think for what Linus does he does not need much inheritance, so structs and function pointers are enough, and he doesn't want any code duplication from templates, so he uses void pointers or whatever. At that point, C++ doesn't offer much, although operator overloading and smart pointers and destructors are still kind of nice.
Full OO seems to be really nice for some business and simulation applications, but unnecessary for a lot of systems and compilers and other low-level CS junk. Something like OCaml or D would probably be nice, except that the compilers aren't mature enough, or the runtimes lack some grotty feature or whatever. And the part about porting the existing system.
2
u/_martind Dec 18 '08 edited Dec 18 '08
It's funny to note that the url reddit yield for this thread ends in "linus torvalds rant against c"
2
u/EvilPigeon Dec 18 '08
Asking an honest question here. For games programming, is there a better language than C++ to maximise performance and manage complexity?
3
u/skizmo Dec 17 '08
Linus can shout whatever he want, but he is actually shouting to bad PROGRAMMERS, not the language. There is nothing wrong with the basics of C++, it's the use of it. C++ gives you much more control over your code, and therefore much more ways to fuck up.. . some people simply don't know how to handle power when they get it.
13
u/Fabien3 Dec 17 '08
Yet another one who talks about C++ without knowing anything about it. He's not the first, nor the last.
He does have a point though: it's so hard to make a working program in C (without buffer overflows and stuff like that) that bad programmers give up early, and only good programmers stay. The low barrier of entry has given C++ and PHP their bad reputation.
10
u/ntrifunovic Dec 17 '08
Not the first time Linus makes a fool of himself (remember threads?) and probably not the last time either.
6
u/yabcok Dec 17 '08
code and prejudice. c++ is just a language. this offensive approach is so silly (language wars). anyway he's not an authority for me. freetards made him famous, not his words/code.
6
u/akcom Dec 17 '08
Funny how everyone takes Linus's word as gospel. Just because Linus Torvald doesn't like C++ or the numerous great features it offers (outside of the OO paradigm) you're now going to see a mass of wanna-be linux "hackers" claiming C++ is a HOARABLE language. What a bunch of idiots (linus included).
4
u/treetrouble Dec 17 '08
You're not wrong Linus, you're just an asshole
4
u/Siraf Dec 17 '08
Hey people, let's cool down and remember that at least it's not Java.
4
u/atc Dec 17 '08
OLD news. This is from Sep 2007!
4
u/[deleted] Dec 17 '08 edited Dec 18 '08
Sorry ... I don't agree with Linus on this one. I've written C/C++ for going on 18 years and I personally find C++ to be a really superb language ... and I also think the Linux kernel is a mess organizationally.
Case in point ... the one and only kernel code project I tried was to use Linus's "extensible file systems" to add a new file system primitive ... good luck doing that.
It was only possible with custom kernel compile re-writes and by directly violating Linus's horrifically clunky #ifdef structure related to proper permissions as to what should and should not be a properly authorized kernel module. To add a new file system as a third party and to do so in a consistent manner would require substantial chaining modifications to virtually all of the kernel files ... just to add a file system.
In C++ you would simply derive an object from the file system object and it would be over.
All of this crap is because Linus doesn't like object-oriented design. There are issues with C++, primarily related to code invisibility and optimization cases but these can always be improved in real-world testing and optimization where the cases affect performance.
Linus is trashing object oriented design, but what is his real world experience in a fully OO architecture? He doesn't have any. He's never tried to design an OO project and he doesn't want to be forced to so he resorts to these sorts of profanities rather than a more clear description of -WHY- he hates OOD so much.
Linus has done a great service to the world and computer science at large, and he's been a personal hero of mine for many years, but after having read that ... I think it's time for him to be replaced. There are smarter OS architects out there than him ... and yes, they use object-oriented design.
2
u/[deleted] Dec 17 '08
Some one should send the link to: bs@cs.tamu.edu
2
u/[deleted] Dec 17 '08
If you take out C++ and replace it with GCC you have an excellent observation.
2
u/maxd Dec 18 '08
Given that Linux has already weighed in on the matter, no one is going to care that I, a lowly engineer at a major game developer, completely agree with him.
I started out with just C. After perhaps five years I could architect and implement major systems, I understood the language inside and out, I stuck to good coding standards, layout guidelines, etc. I made sure everything was const correct. And so on.
I had learned C++ and object orientated programming and knew what it was all about, but didn't feel the need for it in any of the things I was working on.
After about five years, I began to want to use some of the features of C++, and at the company where I now work we use a small subset of C++ features, very carefully. We don't use any STL (we develop for the Xbox 360, so it's a terrible idea to do runtime memory allocation), we hardly ever use complex class hierarchies, we don't use Boost, we hardly ever use templates.
I consider myself a far, far better programmer for having done it this way. I have learned WHY C++ is necessary, and what problems it is trying to fix. I didn't jump straight in and try to use all the really rather complex constructs from the start, instead I waited until I needed them.
2
u/[deleted] Dec 18 '08
If you want to alienate people, take a page out of Torvald's book.
2
u/karlgluck Dec 17 '08
It seems he's just a micro-managing masochist. Just because he is programming "great" doesn't make him right 100% of the time. I don't doubt his ability, but I'd rather work alone than with somebody who can't understand the need to be able to have your code communicate with other people as well as the computer.
2
u/[deleted] Dec 17 '08
I think C++'s issue is that you have to manage the use of the language as much as the actual code. There isn't much to C compared to C++. So to use C++ on a project you can't have developers submitting all different styles/Boost/STL/strings junk.
1
u/[deleted] Dec 17 '08 edited Dec 17 '08
i was inclined to downvote this based on sheeple falling into the trap of following via cult of personality, you know, those who admire linus torvald so much... but i kinda agree with him over this.
1
u/[deleted] Dec 17 '08
I thought the guy in the comments made some good points, as do the folks here at reddit. Yes, Linus has a valid point but he sure is vitriolic about it.
1
u/ithkuil Dec 18 '08 edited Dec 18 '08
Realistically, C is probably still the most practical systems programming language but that doesn't mean that C++ doesn't offer advantages, even for building operating systems and other software. I actually think that in a lot of ways both C and C++ are outdated, even as approaches to systems programming. Which is not to say that I think that there are a lot of popular and well supported alternatives but here are a couple of things that are at least moving in the right direction (forward): the D systems programming language and House, an operating system written in Haskell.
1
u/Svenstaro Dec 18 '08
Doesn't anybody else think that language wars look like Punch-and-Judy shows from a little objective distance?
1
u/nmcyall Dec 18 '08
http://www.reddit.com/r/programming/comments/7k4iz/linus_torvalds_rant_against_c/?already_submitted=truehttp://www.reddit.com/r/programming/comments/7k4iz/linus_torvalds_rant_against_c/?already_submitted=true Damn I found this thread by submitting:9/2007 Linus email blasting C++ and also monotone VCS.
Which I found whilst googling and was the first time reading it. What are the chances that two people would submit the same article in 10 hours of eachother, the same 14month old article.
1
u/Enlightenment777 Oct 18 '09 edited Oct 18 '09
All Hail Xenu!
Too much serious talk :)
1
u/MpVpRb Dec 17 '08
I beg to disagree.
If you avoid crap like STL and MFC, many C++ features really are an improvement over C.
I find C++ very useful for lots of things. But I am NOT one of those who insists on absolutely strict encapsulation with an endless maze of const declarations and getter-setter functions.
In short, I am basically a C programmer who uses, and loves, SOME of the extensions provided by C++.
And yes...I also love strong opinion, it drives my wife crazy.
1
u/reddy4luv Dec 17 '08
C+- (reddit version). Vote it up or down. :P
-1
u/BobKelsoCox Dec 17 '08
he's one arrogant ass but DAMN is he right!!!