Live data from Hacker News

The Kotlin Language: 1.0 Beta Is Here

blog.jetbrains.com

11–20 of 102 posts

Re: The Kotlin Language: 1.0 Beta Is Here

#13

Looking at the syntax briefly it seems very similar to Scala. Is there any major differences between Scala and Kotlin?

There are many feature-level differences, but the biggest differences are in the approach, goals and philosophy[1].

When it comes to philosophy, Kotlin is a modern Java -- i.e. a "blue-collar" language[2], aiming to adopt only tried-and-true ideas and not to break new grounds. Scala is most certainly not blue-collar, serving as a basis for a few PhDs, and incorporates many ideas that haven't been tried in the industry. Scala is adventurous; Kotlin tries hard not to be.

When it comes to goals, Kotlin aims to solve Java's pain points (nulls, properties, beans) while keeping the same libraries. Kotlin doesn't even have much of a runtime library to speak of. A Java library is an idiomatic Kotlin library, and is almost indistinguishable from Kotlin libraries when used from Kotlin (i.e., no limited functionality, no wrappers needed). Kotlin's design is built around this core idea. While Scala interoperates with Java, it has its own runtime library, and many types (e.g. collections) need to be wrapped when passed across languages.

When it comes to approach, Kotlin is developed hand-in-hand with its tools (IDE, build, multi-lang compilation), and made to be gradually adopted into Java codebases. You can easily mix Kotlin and Java classes in the same package (the IDE will even convert any given Java class to a Kotlin class, and seamlessly handle mixed-language codebases). Scala and its tools are developed separately, and it's built to be independent of Java (although it interoperates with it). Another difference in approach (although it's still theoretical so not quite fair) is that the Koltin dev promise that the language will be source and binary backwards-compatible starting with the imminent version 1.0 (though this promise hasn't been put to the test), while Scala allows for occasional breaking changes.

[1]: Java and C have very similar syntax, yet the two are completely different (although Kotlin and Scala are probably more similar to one another than Java and C).

[2]: http://www.win.tue.nl/~evink/education/avp/pdf/feel-of-java....

Re: The Kotlin Language: 1.0 Beta Is Here

#14
post #11

It would be sweet if it already had a CoreCLR backend. Portable code between WP and Android without JNI pain.

They have taken steps to separate (most) of the frontend and the backend and will be resuming work on the JS side after 1.0. While I haven't dug into the internals very much, it seems with the concept of "platform types" (i.e. implicitly nullable) and not having anything too JVM-specific, CLR support might be an approachable project for the community. I recommend the community take it and keep it up to date with pre-releases of Kotlin. With ScalaCLR IIRC, when Typesafe decided to stop supporting it it basically withered as new Scala features were rapidly developed.

It also has a better chance than ScalaCLR due to how small the runtime is. But, like Swift with ObjC, since the runtime is so small so many of the libraries are going to targer the JVM and reference JVM libs which may make the cross-VM ecosystem non-existent (doesn't mean it still won't have good CLR uses of course).

Re: The Kotlin Language: 1.0 Beta Is Here

#15
are non-exhaustive pattern matches in kotlin warnings, errors, or neither?

looks like from the docs:

"If `when` is used as an expression, the `else` branch is mandatory, unless the compiler can prove that all possible cases are covered with branch conditions."

So it is an error, I assume?

Re: The Kotlin Language: 1.0 Beta Is Here

#16

Looking at the syntax briefly it seems very similar to Scala. Is there any major differences between Scala and Kotlin?

Can't do much FP in Kotlin. Unless your definition of FP is programming with lambdas.

I agree. One thing that is sorely missing, for example, is a way to define recursive values.

In Scala, to express a recursive parser combinator:

val e = p | e

You can't define such a thing in Kotlin. Atleast, this was the case the last time I looked at it.

Re: The Kotlin Language: 1.0 Beta Is Here

#17
post #11

It would be sweet if it already had a CoreCLR backend. Portable code between WP and Android without JNI pain.

They have taken steps to separate (most) of the frontend and the backend and will be resuming work on the JS side after 1.0. While I haven't dug into the internals very much, it seems with the concept of "platform types" (i.e. implicitly nullable) and not having anything too JVM-specific, CLR support might be an approachable project for the community. I recommend the community take it and keep it up to date with pre-…

That is my view as well.

But having platform specific code hidden behind interfaces is way saner than having to write JNI for almost every framework API when using C++ for business logic.

The problem doesn't happen in the other mobile OSes thanks to Objective-C++ and C++/CX. My current approach.

Re: The Kotlin Language: 1.0 Beta Is Here

#18
post #11

It would be sweet if it already had a CoreCLR backend. Portable code between WP and Android without JNI pain.

They have taken steps to separate (most) of the frontend and the backend and will be resuming work on the JS side after 1.0. While I haven't dug into the internals very much, it seems with the concept of "platform types" (i.e. implicitly nullable) and not having anything too JVM-specific, CLR support might be an approachable project for the community. I recommend the community take it and keep it up to date with pre-…

Right now developing a new backend for Kotlin is much harder than necessary because the compiler doesn't have any IR and any desugaring passes - in other words, each backend has to work directly with the full AST (annotated with types etc., but still using all language constructs).

We plan to rework this post-1.0, after which building a new backend will be much more feasible.

Re: The Kotlin Language: 1.0 Beta Is Here

#19
I've been using Kotlin for a little while, as the backend language for the side project/maybe-startup I'm working on. I went with it because of my troubling tendency to write Scala code I can't read three weeks later, and in that I think Kotlin's a big success: the Java interop is good (still some weirdness around DI frameworks and non-nullable types, which is unavoidable if you're using something like Jersey with HK2), the language itself has most of the niceties I want, and I find that the tooling is really pretty good in general. And the Kotlin community, in my experience, has been really good (aside from...sigh...yet another Slack chat to be in), unlike the continuing and perpetual disaster of Scala whenever certain members of the This Should Be Haskell mafia are allowed near anyone who's just asking a question.

I miss things from Scala once in a while, but they're usually me being way too cute with my code anyway--good for tiny personal things, not for something I'm hoping I'm looking at three years from now, not just three weeks from now.

Re: The Kotlin Language: 1.0 Beta Is Here

#20
post #15

are non-exhaustive pattern matches in kotlin warnings, errors, or neither? looks like from the docs: "If `when` is used as an expression, the `else` branch is mandatory, unless the compiler can prove that all possible cases are covered with branch conditions." So it is an error, I assume?

With the caveat that I haven't tried it myself:

> What about pattern matching? This is where the word “sealed” above comes in handy; we can do an exhaustive pattern match without an else/otherwise branch

from https://medium.com/@octskyward/kotlin-fp-3bf63a17d64a#.8dbwa...

Post reply on HN