I don't know why would I want to use this and not Scala.
Sure, Scala might have some complexity, but it's easy to learn and for me it's as productive as Python.
That Kotlin page calls them "Groovy-style", perhaps because many of those working on Kotlin (e.g. James Strachan, Alex Tkachman) used to develop the Groovy Language.
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?
I program in Groovy daily. "Groovy-style" builders are just sugar over the Builder pattern via heavy use of closures - so in reality they can be used anywhere an Object needs to be constructed.
So yea, any language which supports closures should be able to do "Groovy-style" builders.
Presumably because, among the languages (and standard libraries) you mentioned that have implemented this pattern, Groovy is the language that is most tightly associated with the JVM (which Kotlin is obviously targeting).
In Kotlin, you can write a function that takes, as its last argument, a function literal that is scoped to a specific class. Last I checked, function scoping does not work this way in Scala and you'd have to explicitly pass around objects to get the same result.
In the end, we end up with a builder DSL like this:
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...
That's not very hard to do with Scala. In fact, there's a few projects that have implemented whole other languages in Scala. Most languages that let you go near functional style do very well with DSLs and writing a DSL is one of the often highlighted strengths of Scala.
For a good example check out the Specs2 unit testing framework.
Because Scala is a mess of a kitchen-sink language, a heap of both practical and academic features, a lot of sound and fury with no clear purpose or aim, and absolutely no opinions; it's the "yeah, why not? we'll throw that in, too"-language.
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.
With Scala, it's often inconvenient when leaning how quickly code can become not just deprecated, but uncompilable because of the culture of whim.
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.
Scala puts too much pressure on the GC to be a good candidate for Android development and the complexity of its syntax makes developing good tool support very difficult.
Since I only write Java for Android Kotlin is already way ahead of Scala on my list for both reasons.
I found this comparision: http://confluence.jetbrains.net/display/Kotlin/Comparison+to... so basically Kotlin seems to be a "watered" Scala.