News for hackers. Stuff that matters.
Re:Niklaus Wirth has died by mkl on Wednesday January 03, 2024 @03:42PM (#38859590)
It has mostly won for individual programs, but very much not for larger things like operating systems and web browsers.
Re:Niklaus Wirth has died by epcoa on Wednesday January 03, 2024 @03:48PM (#38859676)
Mostly won for CRUD apps (yes and a few others). Your DAW, your photo editor, your NLE, your chatbot girlfriend, your game, your CAD, etc might actually want to use more than one core effectively per task. Even go had to grow up eventually.
Re:Niklaus Wirth has died by pjmlp on Wednesday January 03, 2024 @04:24PM (#38860134)
Indeed, however the experience with crashes and security exploits, has proven that scaling processes, or even distributing them across several machines, scales much better than threads.
Re:Niklaus Wirth has died by kragen on Wednesday January 03, 2024 @06:22PM (#38861185)
preemptively scheduled processes, not cooperatively scheduled
Re:Niklaus Wirth has died by pjmlp on Thursday January 04, 2024 @01:36AM (#38863818)
Ah, missed that.
Re:Niklaus Wirth has died by frognumber on Wednesday January 03, 2024 @04:01PM (#38859848)
It's moving in more and more.

A core problem is that it's now clear most apps have hundreds or thousands of little tasks going, increasingly bound by network, IO, and similar. Async gives nice semantics for implementing cooperative multitasking, without introducing nearly as many thread coherency issues as preemptive.

I can do things atomically. Yay! Code literally cooperates better. I don't have the messy semantics of a Windows 3.1 event loop. I suspect it will take over more and more into all walks of code.

Other models are better for either:

- Highly parallel compute-bound code (where SIMD/MIMD/CUDA-style models are king)

- Highly independent code, such as separate apps, where there are no issues around cooperation. Here, putting each task on a core, and then preemptive, obviously wins.

What's interesting is all three are widely used on my system. My tongue-in-cheek comment about cooperative multitasking winning was only a little bit wrong. It didn't quite win in the sense of taking over other models, but it's in widespread use now. If code needs to cooperate, async sure beats semaphores, mutexes, and all that jazz.

Re:Niklaus Wirth has died by funcDropShadow on Thursday January 04, 2024 @02:20AM (#38864134)
Async programming is not an alternative to semaphores and mutexes. It is an alternative to having more threads. The substantial drawback of async programming in most implementations is that stack traces and debuggers become almost useless; at least very hard to use productively.
Re:Niklaus Wirth has died by funcDropShadow on Thursday January 04, 2024 @02:15AM (#38864095)
In the last 15 to 20 years asynchronous programming --- as a form of cooperative multi-tasking [1] --- did gain lot's of popularity. That was mainly because of non-scalable threads implementations in most language runtimes, e.g. the JVM. At the same time the JS ecosystem needed to have some support for concurrency. Since threads weren't even an option the community settled first on callback-hell and then on async/await. The former reason to asynchronous programming alleged win is currently being reversed. The JVM has introduced light weight threads that have the low runtime cost of asynchronous programming and all the niceties of thread-based concurrency.

[1]: Asynchronous programming is not the only form of cooperative programming. Usually cooperative multi-tasking systems have a special system call yield() which gives up the processor in addition to io induced context-switches.

Re:Niklaus Wirth has died by pjmlp on Thursday January 04, 2024 @03:09AM (#38864451)
In .NET and C++ asynchronous programming is not cooperative, it hides the machinery of a state machine mapping tasks into threads, it gets prempted and you can write your own scheduler.
Re:Niklaus Wirth has died by funcDropShadow on Thursday January 04, 2024 @03:16AM (#38864483)
But, isn't the separation of the control-flow into chunks, either separated by async/await or by sepration between call and callback, a form of cooperative thread yielding on top of preemptive threads? If that isn't true for .NET, then I'd really interested to understand what else it is doing.
Re:Niklaus Wirth has died by pjmlp on Thursday January 04, 2024 @04:29AM (#38864979)
No, it is a state machine that generates an instace of a Task from Task Parallel Library, and automates the Run()/Get() invocations from it.

Assuming your type isn't an Awaitable, with magic methods to influence how the compiler actually generates the state machine.