Earlier quoted context omitted.
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.
Never wrote any Groovy? Java developers had no problem picking this style up a decade ago.
Learn Kotlin in Y Minutes
111–120 of 239 posts
Re: Learn Kotlin in Y Minutes
#112> 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
#113Earlier quoted context omitted.
If your 'let' doesn't propagate so that immutable collections are used, it's not very valuable. Just like 'final' in Java doesn't prevent anyone from mutating your ArrayList. Using 'val' instead of something more suggestive like final/const/'not mut' seems a lot nicer to me. (Edit: and indeed Kotlin having "mutableListOf" and "listOf" separation is a good step in readability. The val/var before either of those is les…
That's a misnomer, not a misgiving. val/var/const/whatever only describe the reference, not the value. It doesn't really make sense for that annotation to, say, swivel a collection between ImmutableList and MutableList. Now, you might be right that it's confusing, this difference between reference mutability and value mutability. I see beginners struggle with it in Javascript's new let vs const all the time.
Re: Learn Kotlin in Y Minutes
#114Kotlin is the new Swift/Golang #hype
Swift is similar in that iOS developers don't have to use Objective C any more, but actually looks like a nice language in its own right.
I think although Kotlin is going to be an improvement for Android development, it's not going to change much unless Google drastically simplify the actual Android API. You're still going to have to deal with this shit: https://github.com/xxv/android-lifecycle
Re: Learn Kotlin in Y Minutes
#115Earlier quoted context omitted.
ok so I'm guessing you can't operate on more then one scope at once? if let person1 = dashboard?.owner, person2 = selection?.organization?.owner { person1.cloneProperties(person2) }
You'd use nested let clauses and name the param instead of using the implicit "it"
Would be nice if there was a multiLet in the stdlib. Probably something that happens eventually anyways.
Re: Learn Kotlin in Y Minutes
#116Earlier quoted context omitted.
It's obviously very strongly influenced by Scala, to the point of adopting a number of its syntax decisions that are considered questionable (procedure syntax, infix notation, "=" function definitions). I will echo what the others have said; it's not what I would choose, but in practice it's never been a problem when I'm writing Scala.
Why are Scala's "=" function definitions questionable? It makes absolute sense since a function should return a value.
As a bit of an unreformed code golfer and a fan of ML-style syntax, I actually kinda like it myself; I was just listing a few things that are "considered questionable" (by some people) and present in both languages.
Re: Learn Kotlin in Y Minutes
#117Earlier quoted context omitted.
Why are Scala's "=" function definitions questionable? It makes absolute sense since a function should return a value.
They might be referring to the update methods: val array = new Array[String](10) array.update(7, "hello") array(7) = "hello" // simply calls out to update
Re: Learn Kotlin in Y Minutes
#118Earlier quoted context omitted.
If your 'let' doesn't propagate so that immutable collections are used, it's not very valuable. Just like 'final' in Java doesn't prevent anyone from mutating your ArrayList. Using 'val' instead of something more suggestive like final/const/'not mut' seems a lot nicer to me. (Edit: and indeed Kotlin having "mutableListOf" and "listOf" separation is a good step in readability. The val/var before either of those is les…
> * If your 'let' doesn't propagate so that immutable collections are used, it's not very valuable.* That's nonsense. 1. You cannot implement immutable collections without `let` / `final` 2. The Java Memory Model has special visibility guarantees for `final` (which does propagate), making it really, really useful 3. Having the guarantee that a certain reference won't change is still useful even if the object referenc…
2. Java does a lot with the keyword 'final'. I guess here you're talking about the concurrency behaviors of it? Does it bother you that you can remove 'final' via reflection?
3. It's still useful (e.g. not needing to use yoda-style ifs in languages where you can assign inside an if expression Just In Case you forget an =), but not very. That's my whole point.
Re: Learn Kotlin in Y Minutes
#119Earlier quoted context omitted.
Never wrote any Groovy? Java developers had no problem picking this style up a decade ago.
Nope, never. Just coming back to the JVM ecosystem, actually, as I've been away since around the Java 7 release time (with the exception of some Jython work).
Re: Learn Kotlin in Y Minutes
#120I 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…
It IS cooler, because everything that Google touches becomes gold, according to HN.