Live data from Hacker News

Why Kotlin is my next programming language (2015)

medium.com

41–50 of 185 posts

Re: Why Kotlin is my next programming language (2015)

#41

I tried Kotlin during the Surprise Language round of Codeforces, a programming competition. I found it to be more verbose than a typical modern scripting language. Maybe it's the result of choosing the least of the evils for what it's trying to accomplish. The other drawback: the documentation. Kotlin's reference documentation (looking up how to properly use a call) does not have any examples. I'm not even talking ab…

The Kotlin reference is not supposed to be used for finding methods.

The way to go is to use auto completion in an IDE. If you type `myArray.sort`, you get all one needs, including `sort`, `sorted`, `sortBy` (which you needed).

Alternatively you could search the reference page for Array or MutableList or MutableMap, not sure what you wanted: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/ https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collecti... https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collecti...

Re: Why Kotlin is my next programming language (2015)

#42

Are there any decent languages that compile to readable Java? I think such a language would have a place in conservative Java shops, where management insists "we only use plain old Java around here". You could program in a "cleaner Java" translate it to vanilla Java, then commit, and nobody would know the difference.

> Linj is a Common Lisp-like language that tries to be as similar to Common Lisp as possible but allowing Linj programs to be compiled into human-readable Java code

https://github.com/xach/linj

Re: Why Kotlin is my next programming language (2015)

#43
A few people mentioned problems with Kotlin documentation (presumably with a connection to the Surprise Language round of Codeforces).

Could you describe in detail the problems you had? What was unclear or misleading? Were those problems with the JVM setup or Kotlin itself?

Re: Why Kotlin is my next programming language (2015)

#44
post #40

What happened to Scala? Wasn't that the #1 language for JVM?

Scala is still there, still growing, and a much better language. Kotlin is founded on this anti-intellectual rejection of Scala's advanced features... only to then add them back in piecemeal. So rather than a single powerful general feature like implicits or higher-kinded types you have language-level special cases like extension methods and specific nullness operators.

(Don't get me wrong, there are plenty of things Scala would do differently if it were made today - there's space for a language like Ceylon that makes a genuine effort to simplify on what's in Scala)

Re: Why Kotlin is my next programming language (2015)

#45
When I tried Kotlin some time ago on a side project I wasn't very impressed. To me the problems Kotlin is addressing are not that huge. It feels like having to switch to another language (albeit very similar to Java) just to fix some annoyances is just not worth it.

Maybe prior to Java 8 this would've been more interesting. I also wonder how much time it will take Kotlin to start benefiting from Java 9 features when that gets released.

Re: Why Kotlin is my next programming language (2015)

#46
Hmm, this does seem like a pretty tasteful design in many ways.

The declaration-site variance for generics is a pretty good idea, but is still inadequate to deal with functional collections. (I use the term "functional" as opposed to simply "immutable": an immutable collection has no update operations at all, while a functional collection has functional update operations: for example, given a set S and an element X, to compute a new set whose elements are those of S together with X (S ∪ {X}). This usage is certainly not universal, but the distinction needs to be drawn somehow.)

Anyway, the point is this. Kotlin has in its collections API

  interface Set ...
where the use of 'out' says that given types A and B where B is a subtype of A, 'Set' is a subtype of 'Set'. But then if you wanted to add a 'with' operation as described above:

  interface FunctionalSet : Set {
    fun with(E elt)
  }
you can't do it, because type parameters marked with 'out' can't be used for method parameters.

Re: Why Kotlin is my next programming language (2015)

#47

Are there any decent languages that compile to readable Java? I think such a language would have a place in conservative Java shops, where management insists "we only use plain old Java around here". You could program in a "cleaner Java" translate it to vanilla Java, then commit, and nobody would know the difference.

If you ever tried to push some Java-generated code in the repository I will never ever approve your pull request. It's simply one of the most wrong thing that you can do on so many levels that I really don't know from where to start. You will need to keep track separately of the kotlin code and Java code and keep them in synch. You cannot use the repository because, per your admission, you are doing this in secret, so if your machine dies then you lose all the original kotlin code. Even if you didn't lose the original kotlin source future iterations of the language may change the generated code, so even if you simply remove a comment your pull request will have changes in pretty much all the generated files. A simple refactoring can have similar effects. Generated Java code in my experience can be spotted immediately given that usually is very verbose. I simply can't imagine what huge amount of code that thing will generate for a simple one liner using streams, given that it's targeting Java 6. Probably there are many more other reasons that I cannot think of early in the morning. Last but not least, I'd rather never work with someone that tries to deceive all his colleagues and pushes in the repository awful code. If you don't want to use Java then find another job, nobody is forcing you to work there.

Re: Why Kotlin is my next programming language (2015)

#49
post #4

I really liked Scala when I played around with it (bare with me here), but when deciding on what to use on a project I'm starting, targeting the JVM is a downside. Can I depend on the JVM being on the target machine? If not, I'll have to deal with the dependency. However, if I choose a compiled language like Rust, I don't have to worry about that.

Scala native exists, and is probably a similar overall maturity to Rust (scala native itself is newer, but much of the ecosystem has been around longer).

(Why are you running things on uncontrolled machines? Don't you have puppet or the like set up so that every machine has whatever it needs to run whatever you put there?)

Re: Why Kotlin is my next programming language (2015)

#50

Hmm, this does seem like a pretty tasteful design in many ways. The declaration-site variance for generics is a pretty good idea, but is still inadequate to deal with functional collections. (I use the term "functional" as opposed to simply "immutable": an immutable collection has no update operations at all, while a functional collection has functional update operations: for example, given a set S and an element X,…

The correct signature for that method is something like (don't know whether this is the syntax)

    fun with(F elt)
Post reply on HN