> Declaring values is done using either "var" or "val". "val" declarations cannot be reassigned, whereas "vars" can. I wonder why they decided on these very mistakable names. Why not const/constant/cons/whatever else just as long it's distinguishable from each other?
Learn Kotlin in Y Minutes
41–50 of 239 posts
Re: Learn Kotlin in Y Minutes
#42> Declaring values is done using either "var" or "val". "val" declarations cannot be reassigned, whereas "vars" can. I wonder why they decided on these very mistakable names. Why not const/constant/cons/whatever else just as long it's distinguishable from each other?
Re: Learn Kotlin in Y Minutes
#43> Declaring values is done using either "var" or "val". "val" declarations cannot be reassigned, whereas "vars" can. I wonder why they decided on these very mistakable names. Why not const/constant/cons/whatever else just as long it's distinguishable from each other?
var = variable (can vary/change) val = value (constant) What can be mistaken?
Re: Learn Kotlin in Y Minutes
#44Earlier 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
Unfortunately, my day to day language at work is Go.
Re: Learn Kotlin in Y Minutes
#45Re: Learn Kotlin in Y Minutes
#46Kotlin is more than just simpler java-syntax, though. If you want to really take advantage of it, there's new idioms, you can use it as a typesafe dsl etc.
Re: Learn Kotlin in Y Minutes
#47> Declaring values is done using either "var" or "val". "val" declarations cannot be reassigned, whereas "vars" can. I wonder why they decided on these very mistakable names. Why not const/constant/cons/whatever else just as long it's distinguishable from each other?
var = variable (can vary/change) val = value (constant) What can be mistaken?
l => let
v => var
Re: Learn Kotlin in Y Minutes
#48Earlier quoted context omitted.
You can even get rid of the final parentheses. (1..100).map { it + 10 }
Somehow that seems even less readable to me.
Its also used for chaining stream code which takes in functions. You get used to this feature very quickly.
Re: Learn Kotlin in Y Minutes
#49> Declaring values is done using either "var" or "val". "val" declarations cannot be reassigned, whereas "vars" can. I wonder why they decided on these very mistakable names. Why not const/constant/cons/whatever else just as long it's distinguishable from each other?
Re: Learn Kotlin in Y Minutes
#50Earlier 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.
This is debatable. In fact, shorter code could (but not always, of course) mean less room for error and more room to hold higher abstractions. Boilerplate is a less efficient use of cognitive energy.