Live data from Hacker News

Learn Kotlin in Y Minutes

learnxinyminutes.com

181–190 of 239 posts

Re: Learn Kotlin in Y Minutes

#181
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.

'value' is frequently a keyword or property on objects, and has specific meaning in a lot of contexts. For names, IMO 'k' and 'v' also work, but I find an abundance of single-letter variables hard to read. key and val it is.

Re: Learn Kotlin in Y Minutes

#182

Earlier quoted context omitted.

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)

In actuality it will be extremely obvious in the IDE and the developer would not make this error.

Re: Learn Kotlin in Y Minutes

#183

Earlier quoted context omitted.

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)

if "val" is a constant, and you try to mutate it later, the compiler will tell you, "That ain't gonna happen."

Re: Learn Kotlin in Y Minutes

#185

Earlier quoted context omitted.

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)

In many cases, you would get warnings when accessing a var that you don't get when accessing a val. Also, IntelliJ suggests converting to val if a var is never reassigned.

Re: Learn Kotlin in Y Minutes

#186
post #147

Earlier quoted context omitted.

Hope we never see "looks exactly like Java syntax but behaves differently when you run it" like we see in Apache Groovy, e.g. their == operator acts differently to Java's.

Pretty much every language's `==` operator acts differently and more sanely when compared to Java's. Groovy had a very different initial design philosophy compared to Kotlin. The Groovy design philosophy was give Java developers a good highly-dynamic scripting language that still felt like Java but also made it more suitable for writing quick and dirty plugins, scripts and other extension bits to Java programs. Kotli…

It's OK for a JVM language to define things differently to Java but still "feel like Java", but it should also have enough syntactic differences so programmers know it isn't Java. The Wikipedia page for Apache Groovy says "Most Java code is also syntactically valid Groovy, although semantics may be different" which isn't a good design.

Re: Learn Kotlin in Y Minutes

#187
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.

Probably everyone will try to hide your comment but that's the truth, there hasn't been a worse ecosystem than Android, learning the Android SDK it's so painful that even if they choose a decent language like Python to support it won't change the fact that the APIs would still be called in the same way, just look at the examples, same just sugar-coated flavor: https://github.com/JetBrains/kotlin-examples/blob/master/…

What is wrong with that example?

Re: Learn Kotlin in Y Minutes

#188
post #9

In terms of why we'd want to, there is this note here: https://kotlinlang.org/docs/reference/comparison-to-java.htm... Other factors to consider are tools support, how often interoprability with java libraries causes problems. Would be nice to hear from someone who has used it a bit about what the state of these is?

To me the most promising aspect seems to be async-await on Android. It'd eliminate so much frustration in developing for that platform. In general, after bouncing between various desktop, mobile, and web-based technologies, I've come to the conclusion that any binding/event-based GUI system needs some sort of async-await or futures support to be truly workable. Otherwise, performing background tasks without locking u…

What do you think of EventBus on Android versus what you ended up using? https://github.com/greenrobot/EventBus Just looking to learn new things.

Re: Learn Kotlin in Y Minutes

#189

Earlier quoted context omitted.

I agree with making mutability require more typing, although I'd prefer going without the redundant `let`.

It's not redundant; for example let (mut x, y) = (1, 2); x is mutable, y isn't. That is, let is the way that you introduce a new binding, always.

Am I being a complete noob that only knows Python (I am) if I ask: Why do you need to declare that something is a mut or string or whatever? Python doesn't seem to need such extra lines with obvious declarations.

Re: Learn Kotlin in Y Minutes

#190

Earlier quoted context omitted.

It's not redundant; for example let (mut x, y) = (1, 2); x is mutable, y isn't. That is, let is the way that you introduce a new binding, always.

Am I being a complete noob that only knows Python (I am) if I ask: Why do you need to declare that something is a mut or string or whatever? Python doesn't seem to need such extra lines with obvious declarations.

Dynamic languages can convert types in runtime (so 1 + "f" = "1f") and not so many languages (not only dynamic) cares about mutability.
Post reply on HN