Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Kotlin is just syntactic sugar of some newer java features on top of older java. Looks like someone hasn't actually spent time discovering how amazing Kotlin is.


I have, but it always felt like not going the whole length with the features, when Scala did much earlier. So if I want a “better Java” I really don’t see why should I stop at half way there. Java is a decent language nowadays so I either just use that or something quite different.


I'm sorry but this looks like an ad-hoc black or white thinking. Language design is made of tradeoffs e.g between features and complexity. However contrary to popular opinion, I'd say that Kotlin actually has almost all Scala features and notably has important features that Scala does not (such as coroutines, reified generics, compile time safe tail recursive, etc)

The most unique Scala feature seems to be implicits. While I'm not convinced by their usefulness, the feature will be available in Kotlin in a few months: https://github.com/Kotlin/KEEP/issues/259 I'd even argue it is more useful in Kotlin since the language is state of the art regarding it's ability toward making DSLs.

The major features that Scala 3 has that Kotlin does not that I can identify are: 1) Pattern matching -> Kotlin is almost there, it has destructuring, a when control structure, and can express ADTs via sealed classes/interfaces. The limitations are: name based destructuring is not implemented. No destructuring in when blocks. However since java will be getting extensive pattern matching support in jdk 19/20 I expect Kotlin to catch up there and I recognize pattern matching can be a very useful feature.

2) union types and intersection types. While those are useful in a structurally typed language such as typescript, I don't see much usefulness for them in Kotlin. You can express union types via sealed classes somehow. The compiler plugin arrow meta brings union type support but I haven't tested it yet. As for intersection types it is on the roadmap. The main usefulness of union types I can see are the union of exceptions in catch blocks, that BTW Java supports, surprisingly.

3) higher kinded types I don't see much usefulness in higher kinder types What else could their use be beyond abstracting over collections? Every Kotlin collection implement the interface Collection<T> which enable this use case. Again, higher kinded types are supported by the arrow-meta compiler plugin.

To me the very few pain points of Kotlin have nothing to do with functional features but are: 1) Inability to deflare a function parameter as mutable. Inability to declare for loop element as mutable. Which in fact are because of IMHO religious functional toxic beliefs about immutability everywhere. 2) no package private modifier (although java 9 modules are supported and they are working on the issue)


> I'd say that Kotlin actually has almost all Scala features and notably has important features that Scala does not (such as coroutines, reified generics, compile time safe tail recursive, etc)

I really don’t see the point of coroutines, especially when a) project loom is on the horizon, b) higher kinded types make it quite trivial to implement as a library (answering your 3rd point)

I’m not sure about reified generics, they are very seldom a problem and frankly, type erasure is most often just misunderstood. Also, with pattern matching overloading is used less often so it is even less of a win.

Regarding compile time safe recursion, I’m pretty sure that Scala was actually the first bigger language implementing that (with an annotation), so it definitely has that.

So don’t get me wrong, Kotlin is a great language with some nice features, I just don’t see it doing anything novel to be honest (and that’s not a bad thing! Non-research languages rarely do anything truly novel!). I just feel like Scala does all of those with less special cases (eg. extension functions can be done with implicits so you get one feature doing many things)


here's the point. I dont have an opinion on the language design of scala vs kotlin.

I am merely pointing out that Kotlin has a much larger community adoption. and it was never backed by corporates.

Ultimately - adoption matters.


No way —- Scala is a much bigger language. Kotlin usage is basically null outside of android (and even there, native may very well be bigger), while Scala is used by several companies for backend, data science, etc. I do know for a fact that eg. Morgan Stanley for example has many backends running it.


actually not true. ever since spring and everyone started supporting kotlin officially, a significant number of startups use Spring Boot, etc through Kotlin.

https://spring.io/guides/tutorials/spring-boot-kotlin/

in fact, this data is fairly accurate - check out the stats on rise of Kotlin's popularity.

https://www.developernation.net/blog/infographic-programming...


Kotlin is a PITA to work with and code compared to modern Java.


Well that seems absurd and a very unpopular opinion that would benefit from actual well quantified arguments




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: