Live data from Hacker News

Learn Kotlin in Y Minutes

learnxinyminutes.com

51–60 of 239 posts

Re: Learn Kotlin in Y Minutes

#51
I like kotlin a lot, but suddenly there are a lot of articles in the front page about it. Kotlin isn't more cool because Google announced yesterday it is going to use it in Android. Kotlin is the same good language it was 2 days ago! (rant over)

If you want to learn kotlin go to the official docs and tutorial, they are as good as the language:

http://kotlinlang.org/docs/reference/

And you don't need to install anything as you can try it in the browser:

https://try.kotlinlang.org

Re: Learn Kotlin in Y Minutes

#52
Been watching Kotlin for a long time. Usually it pops out when I talk about how great Scala is, and I get Kotlin as "what Scala should have been". I have been avoiding using it at work instead of Java/Scala just because Scala had more "buy in" and it was easier to convince people to try it. Now with the new Google/Android (and HN) love, this is the perfect time to give it another try.

Re: Learn Kotlin in Y Minutes

#53
post #45

Does Kotlin have algebraic types? Possibly via sealed traits or the like, similar to Scala?

Kotlin has sealed classes. It also has built in generic Pair and Triple containers. But no it doesn't really have algebraic types as you see in Haskell. For example, you can't build a linked list by `cons`ing Ints and Strings and then take the dot product with another Int-String list. It still relies on generics in that regard although it does make improvements with reified types (generics that are retained at runtime for use in type checking `is`--kotlin `instanceof`) and variance indicators.

Re: Learn Kotlin in Y Minutes

#55
post #8

Earlier quoted context omitted.

Deservedly so. It is a great language, and it's backed by the ultra-power JVM. You can use a hipster language with great features and still use JodaTime and maven and all the enterprise stuff that just works.

What exactly make it a great language? What are the advantages compared to Java? I search for it but couldn't find any simple answer to that question. The fact that things are shorter to declare doesn't make it better. It makes it less readable.

> The fact that things are shorter to declare doesn't make it better. It makes it less readable.

That's not a hard and fast rule. There are obvious inflection points. A 200 character long identifier is less readable than a 20 character identifier in almost all cases. A 1 character identifier is less readable than a 8 character identifier in almost all cases. Somehwhere between those extremes is the sweet spot, and it's likely somwhat different depending on person.

As for language keywords, as long as they are unique, unambiguous, and not likely to conflict with written code often, shorter is likely better since it's purely a matter of learning them when learning the language. Given those constraints, it's easy to see it's possible to be too short though (any single character keyword that is not context sensitive is likely a horrible choice).

Re: Learn Kotlin in Y Minutes

#56

Does it have an equivalent to Swifts if let clause? if let person = selection?.organization?.owner { setTitle(person.name) setImage(person.image) }

Yes. val person = selection?.organization?.owner?.let { setTitle(it.name) setImage(it.image) it }

You can use `also` instead of `let` to remove the last `it` line.

Re: Learn Kotlin in Y Minutes

#57
post #48

Earlier quoted context omitted.

Somehow that seems even less readable to me.

This is simply "parentheses in a call can be omitted entirely if the lambda is the only argument to that call." This one feature allows for type safe DSL's which eases GUI construction on Android and other domains. https://github.com/Kotlin/anko/wiki/Anko-Layouts Its also used for chaining stream code which takes in functions. You get used to this feature very quickly.

I know what it is, I'm just saying that in a Java-esque language, omitting parens for function application feels worse than doing so in eg Haskell or even Ruby.

Re: Learn Kotlin in Y Minutes

#58
post #51

I like kotlin a lot, but suddenly there are a lot of articles in the front page about it. Kotlin isn't more cool because Google announced yesterday it is going to use it in Android. Kotlin is the same good language it was 2 days ago! (rant over) If you want to learn kotlin go to the official docs and tutorial, they are as good as the language: http://kotlinlang.org/docs/reference/ And you don't need to install anythi…

Official support still matters. There is some inherent risk whenever you go in a direction not explicitly supported by the owner of your platform, and now that risk is gone.

Re: Learn Kotlin in Y Minutes

#59
post #31

Earlier quoted context omitted.

What exactly make it a great language? What are the advantages compared to Java? I search for it but couldn't find any simple answer to that question. The fact that things are shorter to declare doesn't make it better. It makes it less readable.

I haven't used Kotlin, but glancing over their comparison page the one that jumped out to me was that it (almost) eliminates the possibility of null pointer exceptions: https://kotlinlang.org/docs/reference/null-safety.html

This is like an entry-level expectation for a modern language. Hardly something to write home about in this day and age.

Re: Learn Kotlin in Y Minutes

#60
post #51

I like kotlin a lot, but suddenly there are a lot of articles in the front page about it. Kotlin isn't more cool because Google announced yesterday it is going to use it in Android. Kotlin is the same good language it was 2 days ago! (rant over) If you want to learn kotlin go to the official docs and tutorial, they are as good as the language: http://kotlinlang.org/docs/reference/ And you don't need to install anythi…

The language itself isn't 'more cool' or better, but the risk profile of adopting it has dropped dramatically. That makes it much more interesting.
Post reply on HN