News for hackers. Stuff that matters.
Re:C++ coroutines: Initial implementation pushed to master by rumanator on Sunday January 19, 2020 @04:35AM (#22090420)
> I used to be a C++ diehard, but modern C++ is why I started learning Rust. If I'm going to have to learn a whole bunch of new idioms and rules

You don't. Just because you bump a version number it doesn't mean you are forced to use all the bells and whistles.

Re:C++ coroutines: Initial implementation pushed to master by Rizz on Sunday January 19, 2020 @04:54AM (#22090479)
That stops working once you're no longer a solo developer, but part of a team, then you need to learn everything any of your fellow developers might use. You might as well focus on learning a new language and having access to new jobs where you don't have to deal with legacy languages.
Re:C++ coroutines: Initial implementation pushed to master by rumanator on Sunday January 19, 2020 @05:09AM (#22090543)
> That stops working once you're no longer a solo developer

It doesn't. If you have any experience working on C++ projects you will be very aware that deciding which feature is and is not used is the kind of stuff which is defined in the project's coding guidelines docs, along with naming conventions and choice of build system.

With C++ you only have to use a feature introduced after C++11 if you decide you really want to use it. Some projects even in this very day still don't use smart pointers or exceptionsor std::array. Some people still do the old C with classes thing.

Moreover, the world does not come to an end if you arrive at a project and need to learn a feature provided by a programming language.

Re:C++ coroutines: Initial implementation pushed to master by simias on Sunday January 19, 2020 @07:46AM (#22091153)
That's a very optimistic way of looking at things. More than a decade ago (pre-C++11) I used to be a pretty proficient C++ developer. I had a bunch of books about C++ designs, I would use Boost left and right, I knew my design patters, I knew advanced templating tricks etc...

Then I kind of grew frustrated by the complexity and super long build times and for a few years I left C++ on the side, going back to C and other languages. Now I'm a big fan of Rust.

These days when I see a modern C++ codebase using "auto" all over the place, lambdas, the new constructor/initializer syntax, std::move and more, it can be very tricky for me to understand what some code is doing. I feel like I'm reading a new C-based language where I can understand most of it but I feel like some key components are eluding me. Generally I end up figuring it out but I really don't feel comfortable modifying the code because I don't understand all the implications. Very few languages, especially as old and huge as C++, change so drastically and so fast.

And again, I considered myself an advanced C++ user not so long ago.

>With C++ you only have to use a feature introduced after C++11 if you decide you really want to use it.

If you're the original developer who makes the decisions. If you end up working on a project using a different subset than the one you're used to then you're screwed. That's what the parent is talking about.

Re:C++ coroutines: Initial implementation pushed to master by jcelerier on Sunday January 19, 2020 @08:46AM (#22091389)
> Now I'm a big fan of Rust.

> These days when I see a modern C++ codebase using "auto" all over the place, lambdas, the new constructor/initializer syntax, std::move and more, it can be very tricky for me to understand what some code is doing.

But what if you had spent 1/10th of the time you spent learning Rust looking at these features (frankly looking at the wikipedia pages for each revision is enough most of the time I think :

https://en.wikipedia.org/wiki/C%2B%2B11

https://en.wikipedia.org/wiki/C%2B%2B14

https://en.wikipedia.org/wiki/C%2B%2B17

https://en.wikipedia.org/wiki/C%2B%2B20

)

Re:C++ coroutines: Initial implementation pushed to master by imron on Sunday January 19, 2020 @10:00PM (#22095925)
> But what if you had spent 1/10th of the time you spent learning Rust looking at these features

You can write object-oriented code in C too (e.g. gtk, glib etc). It just involves much more boilerplate, and it doesn't offer the same amount of built-in safety guarantees.

So I know enough Modern C++ to use it, but why would I when there are far better alternatives?

Re:C++ coroutines: Initial implementation pushed to master by pjmlp on Monday January 20, 2020 @09:50AM (#22099146)
Because those alternatives, while better at syntax + semantics part, are still quite immature at IDE + libraries + eco-system part.

For example, try to use Rust to implement a UWP component callable from .NET, interacting with the Visual Layer, while using mixed mode language debugging inside Visual Studio.

Re:C++ coroutines: Initial implementation pushed to master by jcelerier on Monday January 20, 2020 @09:30AM (#22099004)
those alternatives don't always offer what C++ has - for instance template<int I> is damn useful in many cases and not many languages have that
Re:C++ coroutines: Initial implementation pushed to master by rumanator on Sunday January 19, 2020 @05:18PM (#22094523)
> That's a very optimistic way of looking at things.

It's the way a professional software developer who actually works with C++ projects looks at C++.

> More than a decade ago (pre-C++11) I used to be a pretty proficient C++ developer. (...) Then I kind of grew frustrated by the complexity and super long build times

Honestly, that comes out as utter bullshit. It sounds like you tried to find out which were the cliche criticisms and mindlessly repeated them, without noticing none of it makes any sense.

The main "complexity" that C++11 added was smart pointers and threading. It is simply unbelievable how someone who parrots they switched to Rust claims that stuff such as smart pointers and threading is too complex to learn. It's the sort of stuff that any developer quickly picks up with a cursory glance through the docs.

Your whole statement is even less believable if we were to believe your claim that you were somekind of Boost wizard who "considered myself an advanced C++ user", because Boost is the staging ground for whatever was added to the C++ standard.

Quite honestly, I find it hard to believe any of your claims.

Re:C++ coroutines: Initial implementation pushed to master by cowsandmilk on Sunday January 19, 2020 @07:09AM (#22090960)
> If you have any experience working on C++ projects you will be very aware that deciding which feature is and is not used is the kind of stuff which is defined in the project's coding guidelines

And you will find that you have to learn these features once they are allowed in the guidelines. Some workplaces stick to the old features. Some regularly update with pushes toward use of modern features. When your coding guidelines prefer modern C++, you have to learn it.

Re:C++ coroutines: Initial implementation pushed to master by tcbawo on Sunday January 19, 2020 @07:44AM (#22091142)
The sentiment of dreading having to learn new language features (as in being forced to) does not compute to me. Being a software developer, you should always be learning new things.
Re:C++ coroutines: Initial implementation pushed to master by armitron on Sunday January 19, 2020 @09:56AM (#22091715)
The complexity that emerges out of C++ with most/all of its features is immense to the point where it's clearly not worth the investment when there are so many alternatives out there. Nobody should be expected to deal with a language so complex that it takes a decade or more of effort before one can say with confidence he truly understands it.

Which is why C++ is dying and those other alternatives are finding so much appeal with new generations of programmers.

Re:C++ coroutines: Initial implementation pushed to master by vips7L on Sunday January 19, 2020 @09:17AM (#22091525)
Let's not pretend there are jobs in Rust or whatever you think replaces C++.
Re:C++ coroutines: Initial implementation pushed to master by 72deluxe on Sunday January 19, 2020 @08:40AM (#22091367)
True to some extent but education is good and knowing the language you are using can only be a good thing.

The same could be said of English. Would you switch to another language because someone uses a word you have never used before?

Re:C++ coroutines: Initial implementation pushed to master by imron on Sunday January 19, 2020 @10:13PM (#22095997)
> Just because you bump a version number it doesn't mean you are forced to use all the bells and whistles.

But I want to use those features. I want memory safety and a way to say this variable owns the memory, vs that variable which is only borrowing it. I want move semantics in some cases and copy semantics in others. I want lambdas so I don't need to define new functions (or classes) to handle simple visitor patterns (or other cases where passing a 'function' makes sense).

These are good, useful features that I'd like to use to make my code more safe, more performant and more readable, and while C++ can do these things to some degree, there's boiler plate and new rules (rule of 5 vs rule of 3) and gotchas, compared to a language like Rust that has these things built in, with more safety and without compromising performance, and for me it made sense to start using it instead.

I still have projects in C++ that I'll maintain with modernish C++ rather than re-writing them, but for new things where I have a say in the matter, I'll choose Rust.

Re:C++ coroutines: Initial implementation pushed to master by ncmncm on Monday January 20, 2020 @11:00AM (#22099713)
I see that you have not kept up. Since C++17 it's "rule of zero": you don't need to write any of them, because the compiler does it. As the language gets more capable, the code you write gets simpler.

I don't think that is happening in Rust.

Re:C++ coroutines: Initial implementation pushed to master by imron on Monday January 20, 2020 @11:20PM (#22104278)
> I see that you have not kept up.

I have not (C++14 onwards was roughly where I started paying less attention), and that was partly my point. C++ has gone through dramatic change, and if I'm going to go through that dramatic change, I might as well do it with a language that has modern features and safety built in, and doesn't require extra boilerplate to do it.

Looking up the rule of zero, it seems there's still some debate about whether it's a good thing or not [0] (don't know if it's been resolved yet), and it still doesn't preclude you from knowing about the rule of 5 and the side-effects of declaring or not declaring certain operators/constructors/destructors.

> As the language gets more capable, the code you write gets simpler.

> I don't think that is happening in Rust.

This happens quite often in Rust, see for example error handling and the evolution of the ? operator, and the recent addition of async/await, and unlike c++, as the language gets more capable the changes required in terms of coding style and updating your mental model of how things work is usually not so dramatic.

0: http://scottmeyers.blogspot.com/2014/03/a-concern-about-rule...

Re:C++ coroutines: Initial implementation pushed to master by ncmncm on Friday January 24, 2020 @12:40AM (#22135693)
2014 was a long time ago.

Scott has retired. The better alternative to his suggestion was noted right there in the comments. Rules of 3 or 5 concern only designers of a library, and if you are designing a library, you may ignore them now.

Re:C++ coroutines: Initial implementation pushed to master by gumby on Sunday January 19, 2020 @03:46PM (#22093943)
Think about it the opposite way: the modern language gives you a much safer and more expressive way to express your algorithms and still gives you access to the large library of existing code.
Re:C++ coroutines: Initial implementation pushed to master by nmca on Sunday January 19, 2020 @06:15AM (#22090772)
On the flip side, I learned low-level programming in rust, and am thankful that $bigcorp uses modern c++ so the initial gap was smaller. Rust is still better though.