I've been using Kotlin for work (I'm a PhD student, so work is to be understood in a peculiar fashion) and I'm really liking it. It's a much needed upgrade to Java whose fundamental advantage is what I'd call "crispness": you can write terse code that is actually understandable. In particular, the notion of inlining closures allows for efficient functional programming and great DSLs. In comparison to Scala, Kotlin is…
By typeclasses, do you mean structural typing a.k.a. duck typing a.k.a. Go-style interfaces? I don't personally understand why people care about that: a simple structural match on names/parameter types doesn't seem like a strong enough signal that someone actually intended to implement such an interface. But ... type classes can be implemented on the JVM relatively efficiently these days. I threw together a simple Ko…
Kotlin 1.0 Released: Pragmatic Language for JVM and Android
41–50 of 112 posts
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#42Earlier quoted context omitted.
Maven is fantastic in my book. Literally the best build system I've seen. But even if you disagree with me on the specifics, if there's something you want to change about one of those tools, surely you'd want to make the same change when building Java? I don't see any value in rewriting one of those tools in Kotlin to make it Kotlin. (And if some particular idea is easier to express in Kotlin, I've written Maven plug…
how do you do conditionals or loops in maven?
What you're asking for is Turing-complete XML.
History has shown that this is usually a mistake.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#43Earlier quoted context omitted.
By typeclasses, do you mean structural typing a.k.a. duck typing a.k.a. Go-style interfaces? I don't personally understand why people care about that: a simple structural match on names/parameter types doesn't seem like a strong enough signal that someone actually intended to implement such an interface. But ... type classes can be implemented on the JVM relatively efficiently these days. I threw together a simple Ko…
No. Structural types are called structural types. The best known typeclass implementation is that of Haskell where they're built into the language, but Scala has them as a pattern implemented with implicits; I can try to explain the concept here if you like but honestly there are probably better explanations out there. Typeclasses are more powerful than structural types in that the implementation doesn't have to be t…
Oh, I don't know about that one. In Scala type-classes are interfaces and you can put that OOP to good use. For example in the Cats library, you get an Applicative type-class inheriting from Apply, a FlatMap inheriting from Apply and a Monad inheriting from FlatMap and Applicative. By comparison in Haskell a Monad is not automatically an Applicative and you get duplicate functions with different names, duplicate code, duplicate tests, etc.
Another advantage is that in Scala type-class instances are actual values that you can pass around. And because type-class instances are actual values, along with implicits which are lexically scoped, you can always provide another instance of a type-class, depending on context. You do not have the modularity problems arising from usage of type-classes in Haskell.
"The best implementation" is entirely subjective IMHO.
EDIT: got down-votes, not complaining, but I'd like to know where I'm mistaken. Thanks.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#44Earlier quoted context omitted.
Maven is fantastic in my book. Literally the best build system I've seen. But even if you disagree with me on the specifics, if there's something you want to change about one of those tools, surely you'd want to make the same change when building Java? I don't see any value in rewriting one of those tools in Kotlin to make it Kotlin. (And if some particular idea is easier to express in Kotlin, I've written Maven plug…
how do you do conditionals or loops in maven?
https://github.com/jruby/jruby/blob/8e29ae1302e7aa989b8808f7...
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#45Earlier quoted context omitted.
No, not that. I agree with you on structural typing. What I mean is what the Scala doc calls "context bounds": http://docs.scala-lang.org/tutorials/FAQ/context-and-view-bo... (bit outdated: view bounds are deprecated) You could think of it as "abstracting over the adapter pattern", i.e. being able to write methods that take as parameter things that can be adapted to an interface. (And of course the main point of the…
Right, I remember your thread, which is I guess why I'm a bit confused, as you said what you really wanted to do is make a type implement a new interface. I do understand Haskell type classes but in a language like that, they're almost obligatory as it's not an OO language at all. But in something like Kotlin, you should need it far more rarely, so the automatic/implicit "conversion" (I realise it's not quite "conver…
Also, type-classes in Scala are not implemented by means of "implicit conversions". It has nothing to do with it. Type-classes in Scala are implemented by means of implicit parameters, also called context bounds, but that's different.
Of course, you don't really need implicit parameters to work with type-classes. That's just syntactic sugar, because you can just pass dictionaries (type-class instances) around manually.
No, the far bigger problem that Kotlin has is that it doesn't support higher-kinded types. Without higher-kinded types you can't express generic code for containers (e.g. M[T]). And without that, you can't do do type-classes and you can kiss most FP abstractions goodbye.
If you don't believe me, try coming up with an interface for things that have "map", "filter" or "flatMap.
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#46Kotlin is currently my favorite alternative JVM language. Kudos to all collaborators for the great work. After 5 years of hard work, you finally made it! Here's a little starter project for Kotlin webapps using Spring Boot and React.js, I made a while ago: https://github.com/winterbe/spring-kotlin-react-demo
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#47Congratulations to Andrey and the rest of the JetBrains team. This really has been a long time coming. I've been following and experimenting with Kotlin now for the past year or so and it definitely solves a lot of Java's pain points without having to reinvent the way one thinks about programming languages. The interoperability and backward compatibility is one of the most useful features, meaning I don't have to wai…
What's Java 9 going to add that Kotlin can benefit from?
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#48Earlier quoted context omitted.
No, not that. I agree with you on structural typing. What I mean is what the Scala doc calls "context bounds": http://docs.scala-lang.org/tutorials/FAQ/context-and-view-bo... (bit outdated: view bounds are deprecated) You could think of it as "abstracting over the adapter pattern", i.e. being able to write methods that take as parameter things that can be adapted to an interface. (And of course the main point of the…
Right, I remember your thread, which is I guess why I'm a bit confused, as you said what you really wanted to do is make a type implement a new interface. I do understand Haskell type classes but in a language like that, they're almost obligatory as it's not an OO language at all. But in something like Kotlin, you should need it far more rarely, so the automatic/implicit "conversion" (I realise it's not quite "conver…
Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#49Re: Kotlin 1.0 Released: Pragmatic Language for JVM and Android
#50Earlier quoted context omitted.
It's not just a default, you can provide an adapter specific to the type: implicit object IntMonoid extends Monoid[Int] { def zero = 0 def plus(a: Int, b: Int) = a + b } implicit def endoMonoid[A] = new Monoid[A => A] { def zero = identity def plus(a: A => A, b: A => A) = a andThen b } You can't do that with a default method.
While it's an excellent example, I wonder if people don't see "endoMonoid" and run away screaming. I really wonder if people would have different reactions if this was presented as "Addable" instead.