News for hackers. Stuff that matters.
Re:Love It or Hate It, Java Continues to Evolve by butteroverflow on Monday June 17, 2019 @05:21AM (#20201197)
That sure looks nice, but how often do you write services which return a single constant string? I like to judge languages/frameworks based on more representative snippets.
Re:Love It or Hate It, Java Continues to Evolve by unscaled on Monday June 17, 2019 @06:57AM (#20201674)
I think this is not about showing off the easy case, but rather the straightforwardness of the framework. I haven't used spark myself, but I used frameworks quite like it (Jooby, Rapidoid, Ktor) in Java, as well their counterparts in Nodejs (Express, Koa) and Go ("net/http" + some router).

The applications certainly got a lot more complex than that, but we never found ourselves in need of a magic annotation that you can't step through with your debugger.

This is all about simplicity. It's pretty clear how a get() function on the router which takes a route and a callback works, but it requires some work to understand how Spring magically scans all your classes looking for annotations and then builds parser based on that. It's quite unclear where all of the routes are coming from (since they can come from a class just about anywhere). You suddenly need special tools. And the worst thing that suffers is transparency. Ctrl-clicking/Cmd-clicking on an annotation in your favourite IDE never tells you what it does.

In comparison, a second-order function is a vastly simpler and more grkoable beast.

Re:Love It or Hate It, Java Continues to Evolve by Nursie on Monday June 17, 2019 @07:13AM (#20201771)
> That sure looks nice, but how often do you write services which return a single constant string?

The point was just to show that the http server aspect of it is trivial to set up.

You can hook in whatever you want from there.

Re:Love It or Hate It, Java Continues to Evolve by Nursie on Monday June 17, 2019 @01:22PM (#20205229)
FYI, the "(a, b) -> Hello World" piece is a lambda returning a string constant, rather than just a string constant, hence the ability to hook in whatever you want.