News for hackers. Stuff that matters.
Re:Kotlin 1.4 by hocuspocus on Tuesday August 18, 2020 @07:36AM (#24197480)
I've honestly never heard anyone say that. Since Spring 5 it's pretty clear there's some interest in server-side Kotlin; there are several heavy-weights behind that.

However, it's fair to make a distinction between the slowly evolving Android runtime and the JVM. Java language features are catching up with Kotlin, and might even surpass it (I believe pattern matching might land in Java sooner than in Kotlin). Also Kotlin might get stuck for a while when big breaking changes finally come to Java (like Valhalla). I understand why some companies/teams think it's not worth it.

Re:Kotlin 1.4 by matsemann on Tuesday August 18, 2020 @08:04AM (#24197639)
Still lots of kotlin-features I don't see land in java soon. My favorite is passing a lambda in brackets when it's the last argument to a function. Makes it easy to make semi-dsls and nice-looking code. So instead of

  myFun(someVar, { it.something() }) 
it can be written like

  myFun(someVar) {
    it.something()
  }
or if no parameters to the function other than the lambda like

  myFun {
   it.something()
  } 
making the function almost look and behave like a language keyword. I also use extension-functions a lot. Especially for libraries or legacy-java code we wont touch. Where I work we now use Kotlin for all new backend code. And we don't do any Android.
Re:Kotlin 1.4 by thecupisblue on Tuesday August 18, 2020 @10:08AM (#24198707)
I abuse the hell out of this and @DSLMarker. Such a small but amazing feature.
Re:Kotlin 1.4 by lokedhs on Wednesday August 19, 2020 @07:16AM (#24209186)
I do that too, but a real macro facility would be a lot nicer. There are a lot of things that cannot nicely be implemented using the existing syntax.
Re:Kotlin 1.4 by thecupisblue on Wednesday August 19, 2020 @08:01AM (#24209534)
Yep, wish we had that. I had to satisfy myself with annotations and kotlinpoet for now.
Re:Kotlin 1.4 by pjmlp on Tuesday August 18, 2020 @10:40AM (#24199109)
Very Groovy.
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @08:37AM (#24197874)
is that modeled on ruby ?
Re:Kotlin 1.4 by vvillena on Tuesday August 18, 2020 @08:45AM (#24197942)
This is a very common idiom in Scala. Function definition is slightly different, but usage is the same.
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @09:13AM (#24198153)
Any example ? or an idiom name I can google ?
Re:Kotlin 1.4 by swsieber on Tuesday August 18, 2020 @09:49AM (#24198490)
Groovy also does it. I have no idea what the name is though: https://mrhaki.blogspot.com/2009/11/groovy-goodness-passing-...
Re:Kotlin 1.4 by matsemann on Tuesday August 18, 2020 @05:09PM (#24204373)
Not sure about the exact name. But kotlin also has "function with receiver" that together with this makes it very easy to write almost a custom domain language on top of kotlin.
Re:Kotlin 1.4 by matsemann on Wednesday August 19, 2020 @03:31AM (#24208042)
Re:Kotlin 1.4 by jayrhynas on Tuesday August 18, 2020 @03:11PM (#24202964)
Swift calls it trailing closure syntax
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @04:43PM (#24204106)
Ok so it's an explicit parameter, the function is just ~curried so you can just write it nicely.
Re:Kotlin 1.4 by pjmlp on Tuesday August 18, 2020 @10:41AM (#24199129)
Not at all, it is very common in ML languages, Smalltalk, and even Groovy already had it.
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @01:56PM (#24201887)
I never saw that idiom in any ml classes.. I'm honestly surprised
Re:Kotlin 1.4 by pjmlp on Wednesday August 19, 2020 @05:40AM (#24208688)
It is a common idiom for dealing with deterministic resource management, and takes advantage that in ML all functions are single parameter actually.

So you can partially specialize, and then the lambda gets the already allocated/opened resource, thus acting as region/arena resource allocator.

And you can combine it with currying to apply the concept to multiple kind of parameters.

Re:Kotlin 1.4 by untog on Tuesday August 18, 2020 @09:48AM (#24198478)
I don't know, but you can do the exact same thing in Swift.
Re:Kotlin 1.4 by pjmlp on Tuesday August 18, 2020 @08:37AM (#24197869)
Spring sells to everyone, I am old enough to have seen that playbook with Groovy as main actor.
Re:Kotlin 1.4 by BossingAround on Tuesday August 18, 2020 @03:26PM (#24203176)
Groovy was good in what it set out to do, i.e. bringing Python freshness into the vast Java ecosystem.

I loved Grape for single-file scripts. Does any language have similar single-file dependency manager? I guess Go, but then, you have to compile Go, so it might not be as useful, because you distribute binaries anyways.

Re:Kotlin 1.4 by hocuspocus on Wednesday August 19, 2020 @04:15AM (#24208277)
Scala does, thanks to Ammonite:

https://ammonite.io/#import$ivy

Re:Kotlin 1.4 by asdfthvaa2 on Tuesday August 18, 2020 @08:00AM (#24197615)
>I believe pattern matching might land in Java sooner than in Kotlin

Depends on what you call pattern matching. Kotlin had pattern matching from day one, but it's just one level, Java might have it recursive by java 19

Re:Kotlin 1.4 by hocuspocus on Tuesday August 18, 2020 @08:48AM (#24197963)
Calling Kotlin's when pattern matching is a stretch. Even the official documentation doesn't call it like that anywhere.
Re:Kotlin 1.4 by asdfthvaa2 on Wednesday August 19, 2020 @11:14AM (#24211193)
Well, fr sealed classes it's quite good, but yeah, nothing like the scalas and haskells of this life