Live data from Hacker News

Why Continuations Are Coming to Java

infoq.com

21–30 of 185 posts

Re: Why Continuations Are Coming to Java

#21

Earlier quoted context omitted.

Speaking as a dev who started with Java 1.2, I actually much prefer to write code that doesn’t rely on magic unseen effects. The only exception to this is dependency injection via annotations but for god’s sake use it in moderation. But then I still prefer to write for loops rather than streams because I know what the jit compiler is doing.

Unless you're writing assembly or maybe C then "magic" is happening

Assembly and C have plenty of magic to go around, don't worry.

Re: Why Continuations Are Coming to Java

#22
post #8

I 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!"

I think that's the writer/Project Loom's technical lead's thing. I got into a discussion with him about how magical Quasar's docs make it seem here, but we didn't reach accord:

https://www.reddit.com/r/java/comments/7ulmwn/coroutines_in_...

It's quite possible to make non-magical coroutines in Java. It's about how you document them (and perhaps how you try to hide implementation details).

Re: Why Continuations Are Coming to Java

#23
post #17

What is called continuations in Java is available as "coroutines" in Kotlin, today. Both terms means more or less the same, from a programmers point of view, actually Continuations are part of Kotlins coroutines. https://kotlinlang.org/docs/reference/coroutines-overview.ht...

Is there some special jvm/dalvik support for it?

It's a compiler plugin that generates bytecode for you, so there's no need for support from the runtime.

Re: Why Continuations Are Coming to Java

#24
post #17

What is called continuations in Java is available as "coroutines" in Kotlin, today. Both terms means more or less the same, from a programmers point of view, actually Continuations are part of Kotlins coroutines. https://kotlinlang.org/docs/reference/coroutines-overview.ht...

Is there some special jvm/dalvik support for it?

There is no JVM part of Kotlin coroutines, it just uses plain JVM features as every other Java program.

Re: Why Continuations Are Coming to Java

#25
post #11
post #8

I 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!"

I wonder if it's because there is such a sharp line between what a Java programmer can do in Java, and what the JVM does to make that possible. Much of what the JVM does is impossible to even describe in normal Java. That line doesn't exist in, say, C++, where the compiler is just another C++ program. With the caveat that there are JVMs written in Java, so that line can be crossed: https://www.jikesrvm.org/ The same…

The JVM is not magic, neither are Java programmers magicians, but I think the reason magical terms are used to describe Java systems is that the ecosystem had lots and lots of time to develop libraries and abstractions (a few of which happen to be of the right kind, read: leak just the right amount). Your typical Java programmer is well aware what it takes to implement a battle-proof connection pool, and will not attempt to implement their own. To them, adding the config stanza to enable a connection pool indeed feels like magic. Other platforms, that come with preconfigured connection pools, do not leak this to the programmer, and 80% of their users will not know what a connection pool is.

Re: Why Continuations Are Coming to Java

#27
> I serve as a technical lead for Project Loon. That is the project that's intended to add continuations and fibers to the JDK.

> However, actually, Project Loom, the goal of the project is to add continuations, fibers, and tail call elimination.

I'm guessing that the project is called either Loom or Loon (and i believe it's the former), but i like the idea that there are actually two cooperating projects, each of which occasionally suspends and lets the other run.

Re: Why Continuations Are Coming to Java

#28
How does this differ from scheme-style continuations? IIRC, full continuations in the scheme sense of the term are currently impossible in Java as they require forbidden stack manipulation. Or is what's being proposed here something entirely else?

Re: Why Continuations Are Coming to Java

#29
post #15
post #4

Earlier quoted context omitted.

I vaguely seem to recall that Rhino, Cocoon's pre-Node serverside javascript, had continuations too. That much have been around 2006 or thereabouts.

I remember them too. I had to dig a little to find the links I remember from the past. http://web.archive.org/web/20190127111220/https://wiki.apach... From the Rhino Google group, it looks like some people are still using continuations in Rhino: https://groups.google.com/forum/#!topic/mozilla-rhino/Gfo-dO... https://github.com/szegedi/spring-web-jsflow

That Rhino js engine stuff was all written in Java too.

Re: Why Continuations Are Coming to Java

#30

How does this differ from scheme-style continuations? IIRC, full continuations in the scheme sense of the term are currently impossible in Java as they require forbidden stack manipulation. Or is what's being proposed here something entirely else?

[deleted]
Post reply on HN