Kotlin: statically typed programming language that compiles to JVM & JavaScript
kotlin.jetbrains.org
kotlin.jetbrains.org
I found this comparision: http://confluence.jetbrains.net/display/Kotlin/Comparison+to... so basically Kotlin seems to be a "watered" Scala.
That being said, the one really cool feature Kotlin has that Scala doesn't is the ability to build strongly-typed builder DSLs:
http://confluence.jetbrains.net/display/Kotlin/Type-safe+Gro...
You simply can't accomplish this in Scala with the same elegance.
In the end, we end up with a builder DSL like this:
div() {
h1("header")
p("paragraph")
div() {
p("another paragraph")
}
h2("another header")
}
In Kotlin, each function call is properly scoped inside (unseen) classes for each level, allowing the code to generate the appropriate object tree.In Scala, all functions would have to be visible in the local scope of the top-level function and we'd end up with a flat object tree instead.
To get the proper object tree in Scala, you'd need to pass explicit references to each containing object into the appropriate function literals, which makes it much more verbose and extremely error prone.
EDIT: not nearly as convincing without proper formatting...
For a good example check out the Specs2 unit testing framework.
But doesn't Ruby also have those builders? Wouldn't it be easy enough for Scala to implement them in a library if they haven't already? Wouldn't Python also provide this type of syntax? E.g. a possible translation into Python from the Kotlin code on the linked page...
html:
head:
title {"XML encoding with Python"}
body:
h1 {"XML encoding with Python"}
p {"this format can be used as an alternative markup to XML"}
// an element with attributes and text content
a(href = "http://python.org") {"Python"}
// mixed content
p:
"This is some"
b {"mixed"}
"text. For more see the"
a(href = "http://python.org") {"Python"}
"project"
p{"some text"}
// content generated by
p:
for (arg in args) arg
So what are they called "Groovy-style" builders for?So yea, any language which supports closures should be able to do "Groovy-style" builders.
That could've been very true 6 years ago, when Groovy 1.0 was released, but I'd have to challenge that for 2012 (and 2013).
Since I only write Java for Android Kotlin is already way ahead of Scala on my list for both reasons.
Most people who use Scala, use it simply as a better Java. Well, Kotlin is that better Java they've actually been looking for all along. And for anyone looking for a truly modern, opinionated language -- there's Clojure.
Most people who end up hating Scala (or at least ruling out its use) seem to be unhappy with the tooling (mainly compile times or out of date IDE modules), rate of language change (either scala or even worse, scalaz), or the inconsistency of interfaces.
One reason why I chose Node.js over Scala for my current personal projects is that I prefer programming in the same language on the client and server.
That being said I've never used Kotlin and can't compare it with Scala, which I have used for my personal and commercial projects.
also, if you like single-language stacks, give opa [http://opalang.org] a serious look. it's essentially based on ml, with a javascript skin, and offers strong static typing and easy integration of front-end and back-end code.
http://devnet.jetbrains.net/community/kotlin?view=discussion...
Thankfully, your comment made me seek it out again and I saw they also added MIT for the framework part, so that apps can be licensed in any language. Will have to try it out now that they have given users that choice.
Obviously I am not target group.
Code is a mass noun when talking to the computer profession.
The science professions still use the (now thought by the computer professions to be archaic) form "Codes"
ps. i'm not cool enough to use notepad, vim etc.
Just wanted to point that out, because you mentioned Notepad and VI. If you don't like IntelliJ, that's a whole other story.
Since they've designed it with tool support in mind from the beginning I expect Kotlin to seriously outstrip the other JVM languages in IDE integration.
However it's a bit weird: they're creating a language that, basically, "needs" an IDE, so they can sell that IDE. I don't doubt they did put a lot of stuff in their language at which IDEA was good (e.g. @NotNull / @Nullable which IDEA was able to check in real-time on partial ASTs etc. which apparently made it into Kotlin right from the start).
I'm sure there's going to be quite some "refactor xxx to use pattern yyy", making IDEA "great" to work on Kotlin.
But are these really the features we want? A language that is "flawed" by design so that we can be sure we need an IDE to develop in it?
I'm still using IDEA and still doing some Java programming.
But I'm more and more investing time in Clojure / Emacs and, honestly, there's more pleasure to develop with these than with IDEA / Java. I don't know why IDEA / Kotlin would be any better.
To me it seems that, from the start, it's a language arguing for its own limitation.
P.S: what about concurrency? does it offer lock-free concurrency? Because there's no way I'm moving back to using explicit 'synchronized' keywords and having fun with deadlocks...
I, too, am a fan of Clojure, but I'm also a fan of Java, and Kotlin is probably the language best called "a better Java". Both kinds of languages have their place.
And as for concurrency -- I'm not sure, but I suspect that it follows the Java/C++/Scala model rather than adopt an opinionated vision of concurrency like Clojure and Erlang do. But if you'd ever need to write a new concurrent data structure for use by your Clojure app, you'll be able to do that with Kotlin rather than Java.
All languages are flawed by design.
Assembly language is flawed so we need a higher level language like C, with easier to read syntax. C/C++ is flawed by requiring us to manage heap memory so we need a managed language like Java/C#. These and Kotlin are flawed because we need some visual help like name lookups and pattern refactorings.
Think of the IDE as part of your exocortex. Leverage it for the junk you don't need so you can switch levels of abstraction as you desire.