Live data from Hacker News

Why Continuations Are Coming to Java

infoq.com

11–20 of 185 posts

Re: Why Continuations Are Coming to Java

#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 mechanism could apply at the Spring Boot boundary. Using Spring Boot (for simple applications) is easy enough. Implementing it takes code that is beyond bizarre.

Re: Why Continuations Are Coming to Java

#12
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!"

It's because the Java ecosystem relies heavily on things automatically being done for you behind the scenes, like run-time reflection and classpath scanning.

Re: Why Continuations Are Coming to Java

#13
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!"

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.

Re: Why Continuations Are Coming to Java

#14
post #3

What impact, if any, would this have on Clojure?

I had a discussion about this with some other folks recently.

Clojure already supports forms of delimited continuations. You can use core.async for example, or cloroutine. That said, it can't yield across stack frames. One problem with that is that if you use a go block for example, calling anything inside it which will block can sabotage your go thread. With Project Loom, all blocking call made within a Fiber will yield it instead of blocking the thread. That would be the big advantage, and possibly something Clojure could leverage as well, so that say making a blocking IO call even indirectly inside a go block would park instead of blocking.

Re: Why Continuations Are Coming to Java

#15
post #4
post #2

Apache Commons Javaflow is an early implementation of continuations: https://commons.apache.org/sandbox/commons-javaflow/tutorial...

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

Re: Why Continuations Are Coming to Java

#16
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!"

Just avoid bloated frameworks and your problem is solved.

This is not a balanced argument. Spring offers a lot of helpful things and can increase productivity. But it also has it's downsides like when something is not working because all the magic behind the scenes, making you more productive normally, just doesn't work in your case.

If I look at Go code, for example, I can hardly bear all the tedious repetition and dumb code! There is hardly any magic in Go, but the downside is, that you have to write every `filter`, `map` and `reduce` by hand.

Re: Why Continuations Are Coming to Java

#18
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?

Re: Why Continuations Are Coming to Java

#19
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!"

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
Post reply on HN