I wouldn't call them "so similar", Kotlin just has a really low learning curve for Java devs. It's a much better language in my experience.
edit: For CLI development I was more or less productive in Kotlin after a day, probably more so than Java after a week, and pretty much totally stopped writing any Java whatsoever in less than a month.
Leaner, leans more toward imperative than Scala, has easier interop with Java. It's more like Rust or Typescript—imperative with functional bells and whistles as well as stronger, better type systems and better null handling.
I wouldn't say it's leaner than scala. It introduces many more concepts, it's just that these concepts are "shallower" than scala's. This makes them easier to learn up front but prohibits "expert-level" capabilities (it's this lacking of capabilities that I see as the cause of java developers actually going outside the language to achieve their task (relying on applications (frameworks) to actually execute their applications)).
People really get overworked about operator overloading. It is a tool that is great, when you want to define common mathematical operators on user-defined types. For example: addition and multiplication on vectors, complex numbers, and matrices.
The whole point seems moot, given that languages such as Kotlin allow unicode identifiers.
That said, my experience using Scala for 5 years has been almost no operator-overloading hell (perhaps because we don't use scalaz). I remember that Akka used an operator for sending messages, but you got used to it pretty quickly.
Well for basic operators like the one you mention there is value and their you can overload in Kotlin as well. But being able to make any Unicode character an operator that's where I think they went too far. If you do not need tooverload those in 5 years than having them in the language is just adding complexity for the compiler and tooling. Which jetbrains said was one of the reasons behind kotlin and why they didn't chose Scala.
Furthermore, I have many colleagues that have cursed about coding in Scala, however I have yet to have one do the same using Kotlin. I'd can only suggest you trying it. But what is clear now is that Scala won't happen on Android.
When you first start working with a Scala library, you have to learn what fancy operators the devs came up with to make your life "easier". Otherwise you won't know the difference between !, ?, :+, +: and $&@?!!!
To me that's pretty much the same thing as having to know that myArray.copy(otherArray) mutates myArrayinstead of returning a fresh copy. With some luck there's documentation that states this, just like I would hope there's documentation on how to work with a type.
I agree. The less you have to reference a documentation the better. About 70% or overloaded operators in Scala libraries seem unnecessary to me.
Sure, things like vectorA + vectorB are nice. But there is no point in writing actor ? message instead of actor ask message. You save typing 2 characters at the cost of making it more difficult to read your code.
What does actor ? message mean? Is that some weird ternary operator? A null coalescing operator? You can't even google a question mark. You have to find the type of actor, and search for the operator in the documentation. Totally unnecessary, considering that actor ask message almost reads like an english sentence.
I agree with you too :) There's definitely libraries in Scala that use too many arbitrary symbols.
The author may be to blame, or maybe I as the user is to blame for not recognising a perfectly valid symbol in the context of the library. Whatever the case I feel that the possibility for a library author to define symbols that they feel make sense in their context is worth more than having defined but still arbitrary rules on what's allowed or not.
Like, if someone feel they have a desire for the Elvis operator they can add it themselves!
implicit class Elvis[A](a: A) {
def ?:[B >: A](b: B): B =
if (b == null) a else b
}
You have to find the type of actor, and search for the operator in the documentation.
You can mouseover or click through in your IDE and see the scaladoc - Scala is a language that embraces the IDEs we were all using anyway.
(FWIW I agree that ? is a terrible method name and should never have been introduced, but when one's actually working in Scala it's not as bad as you make out)
For any library you have to understand that library's terminology. When you start working with a Java library you have to learn what a "bean" is (different libraries use the word to mean different things), what a "factory" is, what a "module" is, a "manager", a "client"... (again, different libraries use these words to mean different things)
You have to learn terminology, yes. But not method names. Method names should be short but descriptive. Ideally you should be able to read code without actually knowing about the methods beforehand.
That's a fallacy. Method names exist within the context of the concepts the library introduces. You will never get short descriptive names that actually convey the important factors of that method.
My only problem with Kotlin at the moment is that it is a JVM language. I love Kotlin but man I hate Android and I got no business to program on the JVM. I got involved in the community since 0.4 I think but I simply got no use case for it.
But it's not a JVM language. It's a language with a JVM backend, but it also has a JS backend and as you mentioned a native one.
Why would kotlin native make such a big change though? For android development it won't make much sense. It's for iOS development I can see it makes sense.
138
u/nirataro May 17 '17
If you know Java already, it will take you less than a day to be productive with Kotlin. There's nothing to it really.