5 ms·
Having followed those proposals for a while, I can’t help but have the same question as the commenter over at the blog: at this point, why not just use C++? The
by pwdisswordfish8 6y ago
Having followed those proposals for a while, I can’t help but have the same question as the commenter over at the blog: at this point, why not just use C++? The features proposed are already present in C++, and the only C toolchains that I expect would implement them already include a C++ compiler as well. The effort to add those features to C as well seems like pointless busywork.
- pjmlp 6y agoEmbedded developers and anyone that even at gun point won't ever touch C++, like Linus. And platforms that keep C alive like UNIX clones.
- w4rh4wk5 6y agoDo you think the people not using C++ would welcome the proposed features in C? I personally doubt that, but that's just a wild guess.
- pjmlp 6y agoMost likely not, but that is their problem, C is no longer Dennis and Thomson language for about 40 years now.
- quotemstr 6y agoAnd the opposition these people feel to C++ is deeply irrational. Sorry, but it's true: there's just no reason to prefer C to C++ that stands up to scrutiny. Linus is dead wrong and is just tripling down on stubbornness. C++ doesn't cramp your style if you'd prefer to write C-style code, but it gives you the power to do much more, and on your own schedule and in your own way. Why on earth would you choose to use the much less capable plain C? Christ, it's not like the moment you switch the compiler from gcc to g++ a demon comes and bonks you over the head with the GoF design patterns book. C++ can be as much like C as you want.
- dnautics 6y agoSuppose you are a c programmer and start a project in c++ and then someone joins your team and starts using a corner of the language you are not well versed in. That can be a very scary place.
- quotemstr 6y agoSuppose you are a C programmer and someone joins and starts using C in a way that you don't like. So what? Deliberately using a crippled language is a poor substitute for having code review and style standards.
- pjmlp 6y agoSuppose you are a C89 programmer, and start a project in C18, and then someone joins your team and starts using a corner of the language you are not well versed in. That can be a very scary place.
- nytgop77 6y agoin defense of linux people: - more ways to do things -> more effort required to keep somewhat uniform style - linus and friends just get to decide. (they can be as subjective as they want. The "their house their rules" kind of thing). - there is no "c/c++" language. there is c and there is c++. they have different std libraries, different idioms, and expert overlap is not that high. - linux kernel even in c is a huge success - so c is good enough for linux (enough kernel developers are comfortible and productive with it). - linux might have succeeded with cpp if it were used from the start, but now it's too late. Migration to cpp is a no-go: benefits do not outweigh costs (old code will not be rewritten in cpp, so people maintaining code will now have to be profficient in c AND cpp).
- billfruit 6y agoWhy would embedded developers ignore the huge amounts of convenience given by C++ in organizing and structuring large programs? Namespaces alone itself is sufficient reason to use c++ than C in many contexts, and that is just one of the many others provided by c++.
- pjmlp 6y agoBecause it is a culture pretty much anti-C++, to the point that it is a common theme in C++ conferences how to succeed selling C++ to those communities, for example, "CppCon 2016: Dan Saks “extern c: Talking to C Programmers about C++” https://www.youtube.com/watch?v=D7Sd8A6_fYU https://www.youtube.com/watch?v=D7Sd8A6_fYU
- lpapez 6y agoHighly recommend watching this talk. The lessons conveyed by the author will serve you well not only in communication with C programmers, but communication with anyone really :) As the first comment on the video says: "I came here for a C++ talk, walked away with a life lesson"
- enriquto 5y agois there a text transcription of this talk for video-impaired readers? (I'm deeply triggered by the obvious falsehoods in the description paragraph, and I have morbid curiosity about the rest of the thing.)
- david2ndaccount 6y agoC++ has a lot of nontrivial problems that make it not a clear improvement over using C. These include things such as exceptions, lack of abi stability, constructors, destructors and greatly longer compile times (I once converted a project to cleanly compile as both C and C++ and compiling as C++ took twice as long). Some of these features proposed in this paper would be simple additions that have already been battle-tested in real compilers (gcc and clang already have ‘auto’ by using __auto_type, gcc and clang already have 'typeof’). I am less sanguine about adding any form of capturing closures (by value or by reference), but non-capturing function literals that get desugared to anonymous static functions would be a usability win.
- flohofwoe 6y agoThere is some value in harmonizing C and C++ a bit more, without going full C++. Personally I don't have a problem with the approach that C++ acts as an experimentation testbed for C to find the few good language features that should eventually trickle into C after they've proven their worth in real-world C++ codebases for at least a decade or so ;)
- samatman 6y agoThere is a lot of C code out there, right now, doing positively Lovecraftian things with void pointers. If they wanted to port the library to C++, they would have already. This would let them use something common to the C ecosystem, thus potentially harmonious with other libraries, and hopefully bring some compiler-level discipline to the non-Euclidean insanity.
- ddevault 6y agoExactly this. The C++ committee needs to stay the hell away from C.
- jjtheblunt 6y agoI honestly thought "Why not just use Go? Their compiler is smart enough to stack allocate when possible (escape analysis), so careful use of the language should compile to code comparable to what a C compiler emits?". i guess that was a wordy thought, but all the same...
- pjmlp 6y agoI guess, because the way things are going C is going to have generics first, given it already has a bit of it since C11. :)
- jjtheblunt 5y ago:)