News for hackers. Stuff that matters.
Re:C++ coroutines: Initial implementation pushed to master by LessDmesg on Sunday January 19, 2020 @05:46AM (#22090670)
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_anatom...

Re:C++ coroutines: Initial implementation pushed to master by nemetroid on Sunday January 19, 2020 @09:04AM (#22091469)
The 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.
Re:C++ coroutines: Initial implementation pushed to master by ncmncm on Sunday January 19, 2020 @01:17PM (#22092895)
It 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++.

Re:C++ coroutines: Initial implementation pushed to master by EliRivers on Sunday January 19, 2020 @06:20AM (#22090793)
In 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.
Re:C++ coroutines: Initial implementation pushed to master by jefftk on Sunday January 19, 2020 @07:52AM (#22091176)
That's still C++, just not modern C++.
Re:C++ coroutines: Initial implementation pushed to master by EliRivers on Sunday January 19, 2020 @10:12AM (#22091806)
Technically, 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.

Re:C++ coroutines: Initial implementation pushed to master by rossmohax on Sunday January 19, 2020 @08:11AM (#22091253)
AFAIK 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.
Re:C++ coroutines: Initial implementation pushed to master by tsimionescu on Sunday January 19, 2020 @04:50PM (#22094360)
> 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/

Re:C++ coroutines: Initial implementation pushed to master by gdy on Sunday January 19, 2020 @08:32AM (#22091336)
"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?

Re:C++ coroutines: Initial implementation pushed to master by stjohnswarts on Monday January 20, 2020 @04:30PM (#22102239)
Almost no one is using Rust in embedded. C++ has a much higher uptake among that crowd.