Earlier quoted context omitted.
OS threads use statically allocated stack. This limits the nubmer of threads one can have (say if stack is 1MB and you have 1GB of memory, you can have 1024 threads max). That's the main difference. I think some savings also come from avoiding full blown context switches.
This is demonstrably not true. That address space isn’t allocated until it is used. Even with initial allocations of 4kB pages, there’s plenty more space than you’re estimating.
Why Continuations Are Coming to Java
131–140 of 185 posts
Re: Why Continuations Are Coming to Java
#132Earlier quoted context omitted.
Dylan did it first though.
Modula-2 had coroutines!
Now if we are speaking about coroutines, there are other languages even older than Modula-2, although it was probably the most mainstream one at its peak.
Re: Why Continuations Are Coming to Java
#133In the talk he says that continuations compose much better than monads. Can someone elaborate on this?
In a Java context, I'd say it's undeniably true. Haskell-style composition of monadic values depends on type system features that Java doesn't have and on no account should even be thinking about adding at this point in time. And that's ignoring the syntax mess it would be in Java today, too. In a Haskell context, since continuations are typically implemented as a monadic value, the statement would be more or less no…
Having said that, monads don't compose well regardless of language.
Re: Why Continuations Are Coming to Java
#134How will ThreadLocal behave under different fiber context switches?
Re: Why Continuations Are Coming to Java
#135I find it amusing that whenever people talk about Java, they're somehow using magic to describe it. It's like Java programmers see themselves as magicians... This is especially widespread with spring boot. I've even read sentences like "It's hard to say what it does, you can only see it's effects!"
This room is called Spring MVC and it has 2 million switches which will let you do anything you please. Good luck.
Re: Why Continuations Are Coming to Java
#136Does anyone have a good link to the state of the modern thinking on continuations? I remember from back in the Scheme R5RS era there was a conflict between call/cc and dynamic-wind. If you have a dynamic extent (like for example a try {} finally {} block that does resource allocation/deallocation), and you exit, but then jump back into the block, how far do you try to re-wind the state? You probably don't re-open fil…
Re: Why Continuations Are Coming to Java
#137Re: Why Continuations Are Coming to Java
#138Earlier quoted context omitted.
The lightweight threads(fibers) are actually not threads on the OS level, they just behave similarly. As such there are no context switches etc., which are slow.
i know, but why doesn't the OS do this too? Most programmers don't care if their "thread" is an actual thread on the machine or just a "fiber". If the benefits are this large, it should be provided by the OS in my opinion.
Like with most things, there are drawbacks as well as benefits.
Re: Why Continuations Are Coming to Java
#139Earlier quoted context omitted.
OS threads use statically allocated stack. This limits the nubmer of threads one can have (say if stack is 1MB and you have 1GB of memory, you can have 1024 threads max). That's the main difference. I think some savings also come from avoiding full blown context switches.
You only lose address space as long as that stack memory isn't used, right?
Re: Why Continuations Are Coming to Java
#140Earlier quoted context omitted.
OS threads use statically allocated stack. This limits the nubmer of threads one can have (say if stack is 1MB and you have 1GB of memory, you can have 1024 threads max). That's the main difference. I think some savings also come from avoiding full blown context switches.
This is demonstrably not true. That address space isn’t allocated until it is used. Even with initial allocations of 4kB pages, there’s plenty more space than you’re estimating.
But allocating the address space even if it is not committed still consumes finite resources and still limits the number of threads you can create.