14 ms·
Every time I read a "scathing" attack on C/C++ for being the worst language the author ever heard of, I hear Jack Sparrow's reply in my head "Ahh... but you hav
by chetanahuja 13y ago
Every time I read a "scathing" attack on C/C++ for being the worst language the author ever heard of, I hear Jack Sparrow's reply in my head "Ahh... but you have heard of me".
Somehow despite the litany of crippling deficiencies, C/C++ have managed to be the foundation of every piece of technology a consumer or a computer professional will ever touch in their daily life. But yeah, other than that, we should all be using.. oh, I don't know, scala or haskell or something like that.
- cbp 13y agoWhy do you group C with C++?
- chetanahuja 13y agoFrom the above-mentioned litany of deficiencies: "You might think of the C subset of C++ as bona fide assembly language which you shouldn’t use it in day-to-day programming, except that it’s right there on the surface. If you reach blindly into your C++ toolbox, you’re likely to come up with naked pointers, for loops, and all this ugly stuff." It's all rolled into one as far as the author is concerned.
- banachtarski 13y agoNo the article is clearly about C++.
- chetanahuja 13y agoSorry but I have to call bullshit on this. Even in addition to the passage I quoted which explicitly calls out compatibility with C as the biggest problem with C++, the bulk of the rest of that article is directed towards resource management, starting with dismissing malloc as the worst possible API for memory allocation and going on to bitterly complain about various problems with pointers, global memory, side effects, for loops and any and everything that C++ inherits from C. The overwhelming thrust of the article is that C++ needs to stop looking like C and has to start looking like Haskell or whatever other functional cool-aid is being drunk these days. If you are interpreting this blog post to be a call to programmers to go back to C, you're not reading the same words that I am.
- BruceIV 13y agoI think the author is saying that for what C++ is used for, its backwards compatibility with C is an anti-feature, because it's too low-level. That doesn't mean C is a bad language if you want or need that low level of control, just that modern systems programming should be using a higher level of abstraction which can be more efficiently optimized.
- banachtarski 13y agoCall bullshit? Please. Just say you disagree or something. Bullshit implies that I'm intentionally trying to feed you false information. And you've misunderstood. The line of reasoning you quote is about how C++ introduced new and delete to circumvent the follies of malloc and free. But the upshot was that even new and delete had pitfalls that developers fell prey to, so then came tr1's shared_ptr, followed by unique_ptr, which then necessitated, make_shared, etc. Where did I say this is a call to go back to C? Where did you learn how to read?
- _delirium 13y agoThe author definitely does not consider them all rolled into one; the author was a member of the C++ standards committee. That quote is discussing the C-backwards-compatibility baggage of C++ as a design flaw in C++. In the context of C itself, it might not be a design flaw, and the author appears less interested in that question (he's been writing about C++ since the '90s, and doesn't really write about C).
- chetanahuja 13y agoI don't know about you, but I read "which you shouldn’t use it in day-to-day programming" and "all that ugly stuff" to mean a complete and utter dismissal of C as a language even worthy of consideration. Are you somehow getting a message that the author is endorsing going back to the simple days of pure C?
- tesseractive 13y agoYou could believe C is an absolutely fantastic systems-programming language, but believe that in day to day applications programming, it is a poor choice. Actually, I think that belief is fairly common. I don't think it would be going too far in the direction of looking for a charitable interpretation of the author's statements to consider this possibility.
- PeterisP 13y agoI could argue that in C++ applications actually using the C subset should be completely and utterly dismissed, even though it is compatible.
- BruceIV 13y agoI think not - C has extremely thin abstractions - it's basically a portable assembler, with all the trade-offs so implied. C++ is a beast of a language that includes everything and the kitchen sink (plus decent backward compatibility with C), and as such is hard to optimize for new contexts (like concurrency), because there are so many interlocking bits that all need to work (ever tried to write code combining templates with class inheritance? It's mind-boggling, and that's likely a simpler example than those the author cites).
- nwmcsween 13y agoC is not C++
- jejones3141 13y ago"Therefore moun we singen Deo Gratias."
- nkurz 13y agoGoogle gets me the context, but not the meaning. Could you explain? C++ is the price of our sins and C the lost paradise?
- rumdz 13y ago90% of people who I come in contact with that claim to know c++: "Hey, I know C++! malloc, strlen, memcpy! Oh and std::cout." The article sums this up nicely. Pure, idiomatic C++ is beautiful but too many people are stuck using the C constructs when they should be using C++ alternatives.
- nkurz 13y agoAll true. But I was wondering where the closing line to "Adam lay ybounden". I can translate it literally, but don't understand the cultural context.
- jejones3141 13y agoYeah, I guess that was ambiguous, wasn't it? C could equally well be the original sin, if one goes by analogy with the whole song. I'm just glad that C isn't C++.
- frozenport 13y agoWe know programming is not incremental, often what we did to get 70% of the requirements will be completely useless to achieve the remaining 100%. C++ will take you everywhere, and I find it a solid choice for any project especially because I am often unsure of performance requirements. I can confidently say my C++ code will scale.
- tesseractive 13y agoAssembler will always scale too. The fact that something will always scale does not mean that it really is the proverbial golden hammer. Assuming that you will need scalability for any project regardless of what it entails is premature optimization. There are also any number of cases where by using C++, you are missing the opportunity to use something more sensible. Some example use cases include data processing using massively distributed Hadoop installations, data analysis using Matlab/Octave or R, scripting using shell, perl, python, or ruby, and web client programming using JavaScript. I can't imagine web client programming counts among your "anywhere", but if you are doing all of these other things and doing them in C++, then I must ask why. And in my personal experience[1], developer velocity has proven to be much higher in, say, Python than C++, and there are any number of use cases where rapid development is more important than scalability. Do you really find C++ to be the fastest language for a team to develop in (in your experience)? [1] Warning -- anecdotal evidence directly ahead.
- frozenport 13y agoASM doesn't scale in structure (impossible to manage) and certainly not in architecture - for example new Intel Haswell's have vectorization opportunities which will cause any code that doesn't use these opcodes to run worse. Lastly, it is increasingly difficult to beat C/C++ in performance using handmade ASM, especially when comparing tight loop performance in handmade asm and intel icc - although maybe I suck. Web-client doesn't count in my anywhere because my browser doesn't run a compiled language. That being said backends are often written in C++. A frequently used paradigm is to see some glue language java, python, calling critical C++ routines that are exposed as a library.
- 13y ago
- Scaevolus 13y ago"There are only two kinds of programming languages: those people always bitch about and those nobody uses." -- Bjarne Stroustrup
- cia_plant 13y ago"Popularity is a good indicator of quality" -- Ronald McDonald
- seanmcdirmid 13y ago"Worse is sometimes better" -- Richard Gabriel
- fredsanford 13y agoNinety Percent of everything is crap -- Sturgeon's "Law"
- andyzweb 13y agoSturgeon was an optimist
- michaelwww 13y agoThis quote reminds me of the US Navy saying I used to hear from officers: "A bitching sailor is a happy sailor." Sometimes, but more often sailors have real grievances that higher ups are choosing to ignore. I had a choice to re-enlist in the Navy and later with C++. Didn't happen with either.
- j_baker 13y agoYou're strawmanning. The author clearly didn't say that C++ was the worst language he's ever heard of. He didn't necessarily even say C++ is a bad language. What I'm reading is more along the lines of "Ok sure, C++ was important at one point in time. But in 2013, we have lots of things to worry about that C++ doesn't help us with that other languages do help us with."
- michaelwww 13y agoHe conclusion is the C++ is obsolete and the power of new hardware capabilities is being squandered because of it. I'd call that 'scathing.' I'll always be fond of C++, but I hope I never have to use it again.
- chetanahuja 13y agoThat conclusion on squandering the power of new hardware is being backed by absolutely zero data and is obviously false. Just look around you and note how much software you depend on runs in a parallel fashion on multicore systems (using the SMP model of programming) and is written in imperative languages (mostly C and C++). The only arguments presented by the author are his own subjective opinions of how bad various features of C++ are. There's merit in many of his arguments but the effect of each problem is exaggerated way beyond it's actual impact. For example, the bold, unhedged claim: "Two words: data races. Imperative languages offer no protection against data races — maybe with the exception of D." is a ridiculous claim to make right after his (mostly dismissive) nod to memory model and synchronization primitive introduced in c++11. If it was that difficult to implement parallel programming in imperative languages, we'd have to scrap every OS kernel (which pretty much all scale to large number of cores today) and every hosted language environment (which are all ultimately written in C/C++) and rewrite them in Haskell. Careful readers (who read the references at the bottom of the article) will note the author clearly has an agenda having to do with more automated resource management in C++. For whatever reasons, it has not found it's way into the standard until now and in his frustration, he's lashing out at not just C++ but basically the entire installed base of computer technology (mostly built on top of imperative, manually memory managed languages like C and C++).
- outside1234 13y agoC++ is a legacy language. It was indeed good, about 20 years ago, and we can't shake it because it was good, about 20 years ago.
- vinkelhake 13y agoWe can't shake C++ because for a number of things, there's still nothing better.
- deleted 13y ago[deleted]
- nly 13y agoYep. A legacy language that underwent a major revision 2 years ago, with another coming next year, and another planned for 3 years time.
- Someone 13y agoHave you used it about 20 years ago? I think what we have now is way better than that. Of course, what was there 20 years ago, language wise, still is there, but IMO that does not make it a legacy language. A language with legacy, yes, but it still is very much alive.
- 72deluxe 13y agoI recently had to maintain C++ code from about 15 years ago. It is nothing like the new C++11. C++11 is a completely different beast, with many enhancements. Looks good - I recommend you read Stroustrup's C++11 book; if you are familiar with C++, the tour of C++ covers most of the new C++11 features.
- CCs 13y ago> C++ is a legacy language. Based on which criteria? Citation needed.
- betterunix 13y ago"C/C++ have managed to be the foundation of every piece of technology a consumer or a computer professional will ever touch in their daily life" That has nothing to do with the technical merits of either language, and everything to do with a small number of early programmers' choice to use those languages -- which left us with a massive legacy codebase and an incentive to keep teaching people those languages. To put it another way, Unix is the reason C is popular and Windows is the reason C++ is popular. People who write software for Unix and Windows have compelling reasons to use C and C++, since every program ultimately needs to interact with the OS once in a while. Every time someone brings up the crippling technical deficiencies of C and C++, someone responds with a point about C/C++ being popular. All that says is that technical merits are not necessarily a determining factor in language choice.
- CCs 13y agoI think the actual argument was "C/C++ is not great, but others are worse". :) Pretty much all languages have handy OS API calls, usually a lot more portable than C/C++ - so that's not a compelling reason. Yet somehow a lot of new code is still written in C/C++: Redis, Memcached, Nginx, MongoDB, Android, Chrome etc
- betterunix 13y agoI am speaking from experience here. The only language I have used where this does not apply is F#, and only if you count .NET support. I love CL, I never want to go back to C or C++, but the most annoying aspect is the lack of good system call support. Sure SBCL has a posix compatibility layer, but anything beyond basic system calls becomes a drag. In the worst case you wind up having to write a C function to wrap a system call just to expose an easier-to-use interface for the FFI. It is a complete mess, and it becomes a maintenance nightmare.
- scythe 13y agoWell, there is also the difficulty that there has not been, save Ada, a serious and concerted effort to replace C and C++ for so many of the things that they are used for. Except for Ada, no other modern language is suitable for writing things like kernels, drivers, emulators, etc; except for Ada, basically all modern languages are dependent on garbage collection. So if you want to complain about C, remember that the only serious alternative is and has been Ada, and ask yourself why you're not using Ada, why operating systems and window managers, mupen64plus and Wayland, et cetera don't use Ada, and the truth is: people like C more than Ada. Ada is the anti-C++. It's the answer to every criticism. It's also basically unheard of outside of situations where people really, really need safety cf. airline industry. In fact most of the people who complain about C++ would never even consider Ada. The author of the article seems to be unaware it even exists, which says a lot. The takeaway is that safety is overrated, consistency is overrated, reliability is overrated, because if we really cared about these things... we'd use Ada. And we don't, because "Ada is annoying!".
- 16s 13y ago"There are only two kinds of languages: the ones people complain about and the ones nobody uses" - Bjarne Stroustrup
- graue 13y agoHeard that saying before, but didn't know it was from Stroustrup! That definitely adds to the hilarity. In that case, let's hope Haskell and Rust move ever more solidly from the second group over to the first :) Always gonna be stuff to complain about. Doesn't excuse C++'s issues.
- brudgers 13y agoEdward Sissorhands is a tragic figure - tragic in the classical sense, the essence of his strength is the source of his weakness. Correct or not as a metaphor for cpp, that, not attack, is the author's theme. I take the author to be issuing a warning that he wished he did not feel compelled to give, and that warning is that for some programming tasks which are increasingly becoming common the language beloved in his youth is feeling like a Turing tarpit. Yes, with enough effort the relationship could be maintained, and for many people doing so makes sense for the sake of the kids, but for others like the author, the spark has died and there are younger more attractive "local girls who want to meet."
- rybosome 13y agoYour point is correct, but it seems like a defensive stance. Rather than debating the technical facets of the article, you fall back on the ubiquity of C++ projects as an overwhelmingly positive aspect. For what it's worth, people say the same thing about PHP; how do you feel about that language? It's hard reading vitriolic attacks on things you enjoy. There was a talk given by a Rubyist on why he thought Scala sucked, and I found it very irritating (and incorrect). So, that being said, I don't want to dismiss people feeling this way when the subject is broached. It would be nice to find a way to raise these points without ruffling feathers. ...but I think it should still be talked about. Times change, we learn lessons, life moves on. In spite of this, our most-used software is written using a language that is decades old. C+ is not a mathematical theorem...there is no universal truth to it that gives it a timeless quality. It's very common in the medical profession to rapidly change treatment methods - although a majority of the underlying knowledge is static, the actual techniques and tools change as better ones are discovered. In the realm of programming, can't we at least have the discussion? I'm not advocating totalitarian FP. What I would love is for people to just take some of the biggest lessons learned and apply them. Hell, if I could just get immutability by default (we all know untamed mutability is dangerous), no untyped null (Hoare's billion-dollar mistake), and truly useful first-class functions (with everything that implies), I'd say that's enough to mollify me for the present. Thinking way, way, way forward, I would like to see people really studying and rethinking programming in general. Just because this is how we are doing this now doesn't mean it's the best way. "Normality" is sort of an accident - I'd love to see a more studied approach.
- chetanahuja 13y agoThe point I was making (somewhat sarcastically) is that the claims of deficiencies in C/C++ family of languages, such as they are, are way overblown. There are lots of problems with the model of course. The author is not the first person to express his utter dismay at the inelegance and crudeness (as they see it) of this model and won't be the last. They have seen the light. How can the others be so blind etc. Meanwhile in the real world, every single computing device, billions of them, are working non-stop, days and weeks and months on end, on a foundation of millions and millions of lines of imperative code (mostly a combination of C/C++/java/ObjectiveC ). If this programming model was so horribly broken, so inadequate, so crude, how could mere humans have created such an enormously complex technological edifice on top of such shaky foundations?
- signa11 13y agoplease don't club 'C' with 'C++' :)