Live data from Hacker News

Learn Kotlin in Y Minutes

learnxinyminutes.com

171–180 of 239 posts

Re: Learn Kotlin in Y Minutes

#171

> 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?

The look?

Re: Learn Kotlin in Y Minutes

#173
post #106

the whole kotlin debate is just a misguided stab at solving the pain that is programming for android. everyone everywhere hates android dev work. so they think that it must be java. no, java sucks, but kotlin sucks just the same. the problem is the android ecosystem as a whole. the ever changing apis. etc. wasting time on java vs kotlin is absurd with so many other real problems.

God, what a useless post. If you don't like Android development don't waste your time with it.

Criticism can be useful if constructive.

Re: Learn Kotlin in Y Minutes

#174
post #169

Earlier quoted context omitted.

Except when iterating through a hash, where 'key' and 'val' are my go-to names for stuff

Just use 'value'. Only you can be sure of shortened words even if it looks obvious. Not good in a team. I never understood people who shorten words to make the program look cryptic. Maybe it was someone who taught you how to program had it that way or somehow it makes you feel your program looks cooler if it looks more cryptic.

Agreed - at that point, I don't know why you wouldn't just (consistently) use 'k' and 'v'. 'val' adds some weird cognitive load, to me.

Re: Learn Kotlin in Y Minutes

#175
post #169

Earlier quoted context omitted.

Except when iterating through a hash, where 'key' and 'val' are my go-to names for stuff

Just use 'value'. Only you can be sure of shortened words even if it looks obvious. Not good in a team. I never understood people who shorten words to make the program look cryptic. Maybe it was someone who taught you how to program had it that way or somehow it makes you feel your program looks cooler if it looks more cryptic.

I dunno, I am horizontally challenged. I like condensed code style like minimizing words, 2 spaces for indent, etc.

Re: Learn Kotlin in Y Minutes

#176
post #168
post #162

Earlier quoted context omitted.

I'm guessing the parent is just complaining that if you are reading code very fast (particularly if you're browsing repositories on your phone) it is hard to distinguish between "val" and "var."

Let alone type them wrong on a tired night.

Thankfully that would be a simple compile-time error. The message might even be readable.

Re: Learn Kotlin in Y Minutes

#178
post #168

Earlier quoted context omitted.

Let alone type them wrong on a tired night.

Thankfully that would be a simple compile-time error. The message might even be readable.

If you type var and mean val - would there be any error?

(I'm sure that this is just something you need to get used to, I'm merely trying to point out that this could be a silent typo/mistake)

Re: Learn Kotlin in Y Minutes

#179

Earlier quoted context omitted.

my beef is with 'val' being keyword. How many variables did you name val in all your coding? I certainly did.

`val` is never an appropriate name for a variable because it tells you nothing at all about what the variable contains.

`val` isn't the variable name, it's the declaration. I'd imagine `val multiplier = 2' to make perfect sense. `var` likewise doesn't connote any truly valuable information other than the label for the memory location that follows is mutable.

Re: Learn Kotlin in Y Minutes

#180
I think the language is quite nice but the tooling is lacking (if you don't use intellj idea). Even the official eclipse plugin has many rough edges. So, when learning kotlin, you effectively also have to learn an ide if you're not already an idea user.
Post reply on HN