News for hackers. Stuff that matters.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by selimnairb on Tuesday October 04, 2022 @03:49PM (#33085756)
I have returned to using C++ over the last six-months after not using it really since university 20+ years ago. I mostly write Python these days, Java in the past, but have also recently written some moderately complex and unsafe C (e.g., making a parser using flex and bison; doing lots of void* pointer arithmetic to get around not having runtime reflection). I am astonished at the complexity of modern C++. I’ve studied Rust and used some Swift (on an iOS app for a client a couple of years back), and I struggle to “correctly” write code in C++. I feel as if C++ is collapsing under its own weight.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by curtis3389 on Tuesday October 04, 2022 @04:16PM (#33086133)
I programmed in C++ all through college, and I get the same feeling watching its development.

TR1 brought the language to a pretty good place with smart pointers, and at first C++11 looked awesome with its type inference features and range-based for loops.

But, also in C++11 were tons of weird gotchas with new and old features. The one that comes to mind is the uniform initialization. It was supposed to fix the issues with calling regular constructors, so you could just use the new syntax and not worry.

But, they also added initializer lists, and those have issues with uniform initialization, so now you not only need to know all the pre-existing issues with the old syntax, you need to know the new syntax and its issues.

This all comes back to C++ refusing to break backwards compatibility, which is great and all, but at this point they've made a language that is only good for job security.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by qwertox on Tuesday October 04, 2022 @07:26PM (#33088591)
I started programming with C and C++ in the 90s and I absolutely loved it. Then big projects with multithreading started to blow up because it became to complex to manage. 2010 I started with Python and absolutely fell in love. Since then I've been using it and never regretted it, until I had to upgrade servers and with it migrate from 2.7 to 3.8, now again to 3.10. There are issues with these migrations which aren't negletible if you're running over 50 different servers, doing different things, where suddenly for no reason at all a function parameter gets removed from some asyncio function, or all the virtualenvs are no longer usable because they were set up with 3.8, which got replaced by 3.10. This makes upgrading an OS very painful as it requires many weeks of preparation, which is something you first need to become aware if. I now have tooling which monitors every running Python process and prints out which modules are used an other things, because there was so much to look after. Basically each Python script has to register it's execution at a central server, but because it can be down, they have to use a local caching proxy server for this.

Then again, two weeks ago I started learning Rust and I'm absolutely blown away. I'm completely absorbed by it. I'm now thinking of migrating some of the Python projects to Rust so that I can have a single executable which I can then copy around without having to care about virtual environments. I mean, I loved C and C++ for its precision, and love Python for it's liveliness (I use `reload` a lot so all the projects are living things which support hot reloading), but Rust seems to hit the sweet spot between C++ and Python. Between performance and little dependencies due to the lack of an interpreter, and a somewhat easy to use threading and async / await with Tokio, with all the safety guarantees Rust offers. I'm currently in heaven for this and I hope it lasts.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @04:49AM (#33092931)
It's probably best not to run Python bare-metal on your operating system. Or at least not to rely on your operating system's Python.

Use a Python package manager, and/or run your Python processes in containers.

That way you can upgrade your OS without having to upgrade all Python programs at the same time.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by qwertox on Wednesday October 05, 2022 @07:17AM (#33093904)
Thank you for bringing this approach onto my radar. It sounds very promising for solving the OS upgrade issue but also let's me finally use the latest version for my projects. I will read up on this.

Are there some recommended keywords or things to avoid which I could use to orient myself? Like "use deadsnakes" or "avoid deadsnakes"?

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by eru on Wednesday October 05, 2022 @09:44PM (#33103364)
I suggest you look into Python's Poetry package manager.

There's some ways to keep multiple isolated Python environments around on the same OS (and Poetry can help with that, too). But I would suggest that you just stick every Python program in its own dedicated docker container, if you can get away with the overhead. (There are some ways to make rather slim containers.)

Of course, it doesn't have to be docker. Any other containerisation or VMs also work.

In general, I found it a good idea to keep the host operation system as small as possible, and stick everything into containers that you can upgrade separately.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by synergy20 on Tuesday October 04, 2022 @05:24PM (#33087175)
what exactly are them? I'm also back to modern c++ but I plan to only use a subset of the super set to make life easier. for example I don't need write a c++ library so many of the new (meta-template-programming) feature I don't need to pay attention to at least for now.

what I really need are RAII, smart pointer, the STL library and algorithms basically, plus simple OOP use cases, those combined are not very complicated to me.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by intelVISA on Tuesday October 04, 2022 @07:15PM (#33088467)
> what I really need are RAII, smart pointer, the STL library and algorithms basically, plus simple OOP use cases, those combined are not very complicated to me.

That's just about what anyone needs, I fear most people are simply too deep in their cargo cults these days to reason about a complex lang appropriately.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by gpderetta on Wednesday October 05, 2022 @04:40AM (#33092870)
Exactly. In fact these days you need less metaprogramming, not more.
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by pjmlp on Wednesday October 05, 2022 @06:09AM (#33093426)
Agreed, I like to watch metaprogramming talks in a similar vein like solving chess match puzzles, but I hardly use any of that in my own C++ code, and tend to stay away from clever libraries.

Best part of latest improvements is that most common mortals don't have to deal with SFINAE, enable_if or tag dispatching.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by TremendousJudge on Tuesday October 04, 2022 @04:08PM (#33086002)
Similar story here. I'm constantly wrestling with the tool more than the actual problem I should be solving
Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by lloydatkinson on Wednesday October 05, 2022 @05:29AM (#33093153)
All of these sorts of reasons are why I skipped learning C++ and don’t intend to use it. I learned C and then C#. I can’t imagine using C++ after using C# - modern C# and .NET have loads of performance and native related functionality including pointers, Span, AOT, etc.

From my outside perspective it seems absolutely chaotic and simply unmaintainable.

Re:C++20 coroutines: “The bug is in the C++ standard, not GC... by pjmlp on Wednesday October 05, 2022 @06:12AM (#33093446)
Kind of, except for the small detail that WinDev loves their C++, and leaves to the .NET community the burden to create libraries, or even Windows Runtime components for their APIs, and also has Windows integrations that don't allow for COM implementations in .NET, forcing some of us to keep our C++ skills up to date.