5 ms·
You have some strange ideas about why people use C instead of C++ these days. People continue using C not because C++ lacks coroutines or something else (a stra
by LessDmesg 7y ago
You have some strange ideas about why people use C instead of C++ these days. People continue using C not because C++ lacks coroutines or something else (a strange argument for C which has almost no features to speak of), and not because they hate safety. No, people use C dor the sake of portability, for the sake of embedded systems, and for the sake of utter simplicity where that is required. Weaning them off C to C++ is impossible because C++ already doesn't fit their requirements. In fact, Rust is better suited to embedded devices than C++, so there's no real need to proselytize C++ to C programmers. Or to anyone, I would argue, because C++ is a terrible language nearly impossible to write safe software in, as well as an ergonomical, developmental and compilational pain in the ass.
In fact, I believe that in terms of developer time wasted as well user frustration, C++ is the most harmful language in the history of humanity. Someday I'll put together a page listing the dozens of C++'s design daults. Here's just a single article demonstrating how incompatible with simplicity and correctness C++ is: http://www.icu-project.org/docs/papers/cpp_report/the_anatomy_of_the_assignment_operator.html http://www.icu-project.org/docs/papers/cpp_report/the_anatom...
- EliRivers 7y agoIn my experience, the majority of C that is used is actually by people who think they're working in C++, because they were taught to use manual memory management, raw pointers and other such C-like constructs. Some keywords about classes were thrown in towards the end of "C++ 101" or whatever they learned from, and away they go, writing C with classes like the last 30 something years never happened.
- jefftk 7y agoThat's still C++, just not modern C++.
- EliRivers 7y agoTechnically, in that the C++ spec allows it, yes, it's C++. However, I find such definitions to be of little practical use, although frequently in the workplace I sit and wait while someone satisfies their need to carefully divide the world up into precise, clear, exacting and useless definitions before we can get on with doing something useful - the industry just seems to attract that; often they don't care about trashing all those lines immediately afterwards, so long as everyone acknowledged the lines. That said, the discussion about how many layers there are in a model of networking and what they're named rendered some people unable to do anything for the rest of the day. Colloquially and practically, I might suggest that it demonstrates that the programmer may be dangerously thinking in C with little lumps of data as their classes. The programmer is thinking and coding in C, with some classes, that they then feed to a C++ compiler. People were doing it like that back in the nineties, when what we think of as "modern C++" didn't exist.
- rossmohax 7y agoAFAIK this very problem is addressed with introduction of move semantic and the goodness, which comes with it, such as unique_ptr instead of raw pointers. With that default move assignment operator does the right thing by default. So C++ langauge development actually improves simplicity and correcness as least for this particular example.
- gdy 7y ago"Here's just a single article demonstrating how incompatible with simplicity and correctness C++ is" I don't see where is the problem. Perhaps, you could give an example of the equivalent code in your favorite language?
- nemetroid 7y agoThe article is from 1997. Every C++ developer will agree that the area surrounding owning raw pointers is chock-full of footguns, but that area is avoided in modern C++, both in theory and in practice.
- deleted 7y ago[deleted]
- ncmncm 7y agoIt is a fact that people still do graduate from C to C++, for a wide variety of reasons. Some discover that their embedded system can be coded with C++ as easily as C. Some learn that C++ is faster than C. Some just gain more confidence and adopt a new feature that is only in C++. The large number of remaining C coders, and the ease of switching incrementallty, means that the number switching to C++ is always overwhelmingly larger than the number adopting Rust from all starting points. We may lament that they do not start writing modern, high-level C++ immediately, but the number of CppCon (and similar) talks hosted on Youtube, and rocketing attendance at, and number of, such events, shows that there is great interest in learning good modern C++.
- tsimionescu 7y ago> Someday I'll put together a page listing the dozens of C++'s design daults. It's pretty old and somewhat outdated by now, but you might enjoy the C++ FQA (Frequently Questioned Answers): https://yosefk.com/c++fqa/ https://yosefk.com/c++fqa/
- stjohnswarts 7y agoAlmost no one is using Rust in embedded. C++ has a much higher uptake among that crowd.