4 ms·
OK, but where are the advantages? The page has just a different syntactic sugar resembling Pascal/Scala; sine JVM nihil Kotlin anyway. Sometimes Kotlin's "advan
by bitL 7y ago
OK, but where are the advantages? The page has just a different syntactic sugar resembling Pascal/Scala; sine JVM nihil Kotlin anyway. Sometimes Kotlin's "advantages" there have more boilerplate than Java...
- driver733 7y agoI leave it to the reader to decide whether the advantages are clear or not. For instance, in Kotlin you can perform operations on collection without converting them to a stream first, and collecting them with a certain collector afterwards. So in order to perform a single filtering operation on a collection, you need to do three steps in Java and just one in Kotlin. Another advantage is coroutines, which not only allow you to write asynchronous code in a common, synchronous manner, but also get rid of shared mutable state, since coroutines can send/receive shared state through channels.
- deepsun 7y agoThat's actually what I like about Kotlin the most -- it's just syntactic sugar over Java, I wouldn't call it a new language. E.g. if you want to parse a CSV or JSON, you would google "how to parse it in Java", not "... in Kotlin". That's different, from e.g. Scala, where everything should be Scala-way (of course you could use Java libs in Scala, but it was always second-class I feel).
- pkolaczk 7y agoOnce you learn the Scala way of e.g. parsing JSON or defining any custom parser or working with collections/optionals you don't want to look back. I had to move back to coding in pure Java for a while after coding Scala many years, and really it feels Java is making things far too overcomplicated in many places.
- bitL 7y agoScala is overcomplicated. Java's goal was to get rid of C++ complexity, Scala sneaked it back in.
- aliakhtar 7y agoIts really amusing to consider Java somehow simpler than Scala. Take any Java class and rewrite it in Scala, you end up with at least 3x fewer lines of code.
- bitL 7y agoThat's not about length of code. It's about how many different approaches in Scala one has to be aware of when working in a team. All team members need to have a similar familiarity with the language/frameworks or team disintegrates and is unable to fulfill its goals. Scala is as fragile as C++ here, prolonging development time unnecessarily.
- pkolaczk 7y agoSame is true for any other mainstream language like Java, C# or Python. There are many ways to do the same thing, and this is why teams have code style guides and code reviews.
- pkolaczk 7y agoIt is only because you are familiar with Java. Scala is much different language so it looks unfamiliar to you. But familiarity is not objective simplicity. Java has many more gotchas and irregularities than Scala, and you just got used to it, so you don't see it. Primitive types vs boxed types, static state, default methods (poor man's traits), unsound array types, etc to name a few. Also it is funny to see how Kotlin or Swift are marketed as simple languages when they managed to literally copy 90%+ of Scala features and make some actually even more complex (eg nullability). If you say "overcomplicated" it suggests you have a simpler solution for the same problem in mind. So, what exactly would you simplify in Scala? Which unnecessary features would you remove? It is easy to throw an "X is overcomplicated" statement but much harder to point to concrete things that could be done differently. Sure, some stuff could be easily removed, but not without making the language less expressive.
- gentaro_ 7y ago
- deepsun 7y agoLast time I tried to store items in a collection and iterate through them (List in Java), I counted 11 different types I could call it in Scala (List, Seq, SeqLike, Traversable etc). And different tools.used different ones. It wasn't easy.
- pkolaczk 7y agoI could easily find 11 collection types in Java as well. Any industrial language will have many data structures, because they have different tradeoffs and there is no single container that suits all needs. Scala standard library is a bit in the baroque side, but it has been simplified recently in 2.13.
- deepsun 7y ago> Once you learn the Scala way ... That. There's no "Kotlin way", there's only Java way. That's what I mean.