Re:Kotlin 1.2.20 released
by stewbrew on Wednesday January 17, 2018 @09:33AM
(#16168133)
I like Kotlin but I really wish they would draw a clearer line between kotlin the language (incl. compilers + generic tools) and the kotlin-plugin for IntelliJ IDEA. It seems they see the work on IDEA support for kotlin as an essential quality of new kotlin features. But guess what, there are people out there who don't want to use JetBrains' IDE, who prefer eclipse (for whatever reason) or who would be much happier to use an editor with LSP support.
If JetBrains didn't make most of their money with their IDE, they would probably put more effort in providing general tools that can be used with any IDE/editor. In this sense, I think JetBrains is hampering the success of kotlin. They should try to give kotlin a better organisational foundation.
Re:Kotlin 1.2.20 released
by V-2 on Wednesday January 17, 2018 @09:37AM
(#16168167)
That's sort of the point though, no? What's in it for them if they were to take care of Kotlin support on Eclipse - their competitor. They don't make their living off Kotlin
Re:Kotlin 1.2.20 released
by stewbrew on Wednesday January 17, 2018 @10:39AM
(#16168747)
Now imagine the only option to write JavaScript in a sensible way (however this should be possible :-) would be VSC. Do you really think JS would have had any success? I think it would have been another Visual Basic.
Even typescript (a MS product) can be written with all sorts of IDEs/editors.
Re:Kotlin 1.2.20 released
by _sdegutis on Wednesday January 17, 2018 @02:53PM
(#16171174)
C# and Swift are in that boat (VS and Xcode) but they’re doing alright, because they’re the main blessed languages for their platforms. JS is the only blessed language of web front ends. So yeah I don’t think IDE lock-in is a concern for JS but it definitely makes me happier as a developer to have deep integration that makes my job easier.
Re:Kotlin 1.2.20 released
by nobleach on Wednesday January 17, 2018 @11:12AM
(#16169042)
This is my exact gripe. I appreciate that they've invested a serious amount of time and effort into creating an entire language for the JVM. But I am bummed about how tied it is to the IDE experience. Writing Go or Rust in Vim is relatively painless. I've written a few minor things in Kotlin and Kotlin/Vert.x and the non-IDE experience is pretty craptastic. Almost all docs assume you'll write some code, and some IDE will automatically add imports for you.
I left the Java world because I couldn't stand having to have all of the hand holding just to achieve simple goals. I'm not saying Java or Kotlin are _bad_ languages at all. Perhaps I'm just bugged by the general attitude that "everyone will have IntelliJ".
Re:Kotlin 1.2.20 released
by bberrry on Wednesday January 17, 2018 @08:17AM
(#16167609)
I love Kotlin, it's been such a breath of fresh air at work. I hope it continues to gain adoption in backend services and not only Android, because it definitely shines at both.
Re:Kotlin 1.2.20 released
by billfruit on Wednesday January 17, 2018 @08:09AM
(#16167560)
Despite being a new language, what little I have seen of it looks pretty old school, i.e functional features seemed like an afterthought and also perhaps features like pattern destructuring and immutable data structures.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @08:17AM
(#16167608)
In principle it's not that bad a language; compared to Swift or Typescript or even Rust it's at a similar level of conservatively adopting a few features that have become very mainstream. Every language design has to adopt a balance between making use of improvements that are coming down the pipeline and not adopting ideas that will later turn out to be bad.
In a language built for the same platform where Scala has already been available for a decade it's very disappointing though.
Re:Kotlin 1.2.20 released
by cookiecaper on Wednesday January 17, 2018 @08:59AM
(#16167887)
I've had nothing but trouble trying to get Scala bootstrapped (sbt is a wreck), and while it's ostensibly interoperable with Java, there are many caveats.
Kotlin's biggest strength is that it brings near-perfect Java interoperability. Almost any code that runs on a JVM released in the last 10 years will interoperate with Kotlin with minimal hassle.
Boutique languages on the JVM are old hat by now, and they're neato and everything, but most people do not have the luxury of getting to choose to base their company on one of them. Kotlin is so compatible with Java that you can mix Java and Kotlin code freely in the same project, allowing people to move to adopt Kotlin gradually, without throwing away their extant business logic or requiring the wholesale sign-off of everyone in the org all at once.
Kotlin may not be the most theoretically pure language, but it lets you hit the ground running while shedding many of the crusty, obnoxious parts of the Java language. We've badly needed a semi-modern JVM language for the working man, something that doesn't get in the way and makes the business of doing software simpler. That's why Kotlin has had such an ecstatic reception.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @09:16AM
(#16168020)
> I've had nothing but trouble trying to get Scala bootstrapped (sbt is a wreck), and while it's ostensibly interoperable with Java, there are many caveats.
SBT is indeed a wreck, just ignore it (at least to start with) and keep using whatever you were using (Maven or Gradle or what-have-you). In maven and eclipse/scala-ide with the m2eclipse-scala plugin installed I always found it "just worked": add the scala plugin to the pom, let eclipse notice that it's Scala, create a Scala class in the project and keep going. The IntelliJ experience is only very slightly more involved (have to manually tell IntelliJ to update the project config with Scala nature).
> while it's ostensibly interoperable with Java, there are many caveats.
> Kotlin's biggest strength is that it brings a reasonable amount of modernity with near-perfect Java interoperability. Almost any code that runs on a JVM released in the last 10 years will interoperate with Kotlin with minimal hassle.
This is the Kotlin narrative but I don't think it's actually supported by the facts. In the early days Scala looked perfectly interoperable with Java, but as we started writing more substantial things in Scala and a native-to-Scala library ecosystem developed it became clear that there was more to interop than being able to call methods directly, as nice as the latter is. As Scala became a full-fledged language with its own idioms we started needing idiomatic wrappers or native-to-Scala libraries. This is happening in Kotlin too, e.g. look at how http://arturdryomov.online/posts/kotlin-the-problem-with-nul... talks about having to consider whether calls are into Java libraries or not and treat them differently if they are.
And if anything I'd say this is getting worse for Kotlin with "modern" Java code: Java 8 is seeing more use of Optionals (particularly in streams) which correspond directly to Scala but are more difficult to interoperate with in Kotlin with its null-oriented design.
Re:Kotlin 1.2.20 released
by royjacobs on Wednesday January 17, 2018 @05:03PM
(#16172443)
Why do you see options vs nulls as the same kind of interoperability issue as, say, Scala's completely incompatible collections library? That seems a little disingenuous.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @05:50PM
(#16172833)
Taken in isolation they're exactly the same kind of interoperability issue; the difference is that Scala has the language facilities (typeclasses and implicit conversions) to solve that kind of interoperability problem and Kotlin does not. In Scala it's straightforward to write methods that work with both Java and Scala collections (either at a syntactic level by using implicit conversions or in a "true" way by using typeclasses); in Kotlin it's simply impossible to write a method that will work with both options and nullables.
Re:Kotlin 1.2.20 released
by royjacobs on Thursday January 18, 2018 @02:34AM
(#16175375)
Having to work with Optionals in Kotlin means just using their Java API. Having to work with Scala collections means having to convert them back and forth every time you interop with Java. The performance implications of the latter are much higher.
Re:Kotlin 1.2.20 released
by lmm on Thursday January 18, 2018 @07:39AM
(#16176622)
Almost all JVM projects are much more tightly constrained on development time than on compute time - and those where compute time is the limiting factor are unlikely to consider either Kotlin or Scala.
But in the vanishingly rare case where you have a performance-critical codepath that needs to zigzag back and forth between Java and Scala... it's still not a problem, because it's easy to work with the Java collections in Scala. The absolute worst case is "just using their Java API" (the same thing you dismiss about using Optionals in Kotlin). But since Scala has typeclasses we can actually do much better than that.
Re:Kotlin 1.2.20 released
by simon_o on Thursday January 18, 2018 @03:17AM
(#16175513)
The ironic thing us that Scala could have just implemented java.lang.Iterable and/or java.util.Iterator, instead of rolling their own interfaces with largely the same methods with identical signatures.
Re:Kotlin 1.2.20 released
by eropple on Wednesday January 17, 2018 @02:19PM
(#16170855)
> In a language built for the same platform where Scala has already been available for a decade it's very disappointing though.
Given that after literally years of Scala experience I could easily write code I couldn't read three months later, this is not a big negative.
Kotlin takes a lot of the good from Scala, leaves most of the bad, and gets the hell out of my way (while giving me literally-perfect Java interop--the only problem I ever had was how to annotate only the getter part of a property, and it was unintuitive but I figured it out). I'm a big fan.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @07:05PM
(#16173329)
To me it feels like they took the sugar from Scala but not the meat. All the simple examples of monads like Future work but with their own ad-hoc solutions (e.g. async/await) so there's no way to implement the reusable library functions that give them their real power. Direct pattern matching is there but the generic tree traversals that give you the real power of ADTs are impossible. All the one-page examples of "Scala power" are there but if you look closely they all fall apart once you try to expand them into the things you do in a full-size codebase.
Re:Kotlin 1.2.20 released
by eropple on Thursday January 18, 2018 @03:54AM
(#16175663)
Sure--but every time I do those things in a full-size codebase, I regret it later. ;) Scala is cool. I like a lot of the people involved (especially since Tony Morris was shown the door). But trying to get something out the door that doesn't turn into a mess of code I have to sit down and chew through, slo-oo-owly, is a heck of a fight. And it's worse when other people's preferred bits-and-bobs of Scala start sneaking in (kind of like C++, in a way!).
The complexity I end up carrying in my head is way, way too high.
Re:Kotlin 1.2.20 released
by lmm on Thursday January 18, 2018 @07:37AM
(#16176615)
> Sure--but every time I do those things in a full-size codebase, I regret it later.
Hmm, that's backwards from my experience. Like, I actually regret it when I use the Future-specific operations on Futures, because I don't use those often enough to remember what they are, whereas I use the generic Monad operations all the time on pretty much everything.
> trying to get something out the door that doesn't turn into a mess of code I have to sit down and chew through, slo-oo-owly, is a heck of a fight
I find often something that would be 10 lines of Java or Kotlin can be 1 line of Scala - but still 8 lines' worth of reading time. It can be difficult to remember that this is an improvement when you're thinking "why is it taking me all morning to read 10 lines?", but when you take a step back you realise that those 10 lines are actually doing the work of many more.
Re:Kotlin 1.2.20 released
by Scarbutt on Wednesday January 17, 2018 @08:44AM
(#16167786)
I don't know kotlin but if you read your collections link well, it does look like immutability was an afterthought, for starters, you can't create immutable persistent versions.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @11:13AM
(#16169047)
There are no built-in immutable collection types; what Kotlin calls "immutable" is closer to C "const" i.e. it could be a view onto a list that's mutated elsewhere. This means you can't safely write a method that requires an immutable list; if you want to e.g. check the size of the list and then iterate over it, while maintaining the invariant that the number you got is the same as the number of iterations you're going to do, then you have to make a defensive copy, because there's no argument type you can ask for that means "actually immutable".
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @11:56AM
(#16169516)
It's not immutable, it's something analogous to C const: you can't mutate it, but it can be mutated under you. If you call .size() on it twice you might get different results.
Re:Kotlin 1.2.20 released
by pdpi on Wednesday January 17, 2018 @09:41AM
(#16168198)
It's important to note that Kotlin defines itself as a blue-collar language, and if the feel you get from it is "this is as if Java had been designed today", then they accomplished their goal.
There's exactly one unusual/novel feature in the language (AIUI), and it's a feature that I personally find inspired: anonymous receiver functions, as it makes EDSLs trivial to write.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @11:25AM
(#16169180)
Delegation as implemented in Kotlin is very novel; AFAIK it's the first remotely mainstream language with that feature (not counting Go since it doesn't have traditional inheritance at all).
(I think it's a very good idea, but it's as innovative as anything you'll see in e.g. Scala, so it makes a mockery of the "blue collar" narrative)
Non-representable types are also decidedly "novel" (in the sense of "wtf?"), as are some of the details of their preferred way of doing await/async (assuming they haven't radically changed again in a minor version as they did in the past).
The only sense in which Kotlin is blue-collar is that it prioritizes immediate use cases over consistency and theoretical coherence. That's not "Java as if it had been designed today", that's "Perl as if it had been designed today".
Re:Kotlin 1.2.20 released
by pdpi on Wednesday January 17, 2018 @01:06PM
(#16170188)
Several features have a clear "this is annoying in Java" background: Type inference is table stakes for a modern language, data classes make beans painless, receiver methods are explicitly designed to ease the pain of FooUtils classes, inline+reified open up generics to a tonne more use cases, and variance annotations helps with several others.
Re:Kotlin 1.2.20 released
by lmm on Wednesday January 17, 2018 @05:45PM
(#16172801)
Sure, it does fix some of the annoying things in Java, as do most languages from the last ten years. But it does also make radical moves away from it - the narrative that you could easily port any Kotlin codebase to vanilla Java becomes a complete myth once you start using delegation or async/await. From my perspective Kotlin tries to have it both ways and ends up achieving neither: it's different enough from Java that you have to treat it as a whole new language, but the lack of usable result types or structured/safe ways to do things like JSON serialization makes it looks painfully limited next to Scala. Indeed by lacking any practical way to safely report errors with information (it's missing checked exceptions but doesn't have practical result types either, because there's no "do notation"-like syntax - the "elvis operator" and friends only work with null, not with errors that carry information), in an important respect it's a regression from Java.
Re:Kotlin 1.2.20 released
by roflc0ptic on Wednesday January 17, 2018 @10:39AM
(#16168746)
Are you familiar with Scala's implicits? Reading about them here (https://kotlinlang.org/docs/reference/lambdas.html), they seem very similar. If you happen to know, what affordances do anonymous receiver functions provide that implicits don't? It looks like they make it marginally easier to add functions to some existing type, but at the cost of making the typeclass pattern less palatable.
Re:Kotlin 1.2.20 released
by billfruit on Wednesday January 17, 2018 @08:48AM
(#16167822)
I am not disliking these features, only was commenting that in my limited knowledge of Kotlin, functional features like these ( which I have come to like from using them in clojure) did not appear like the core design elements of the language. Like another commenter said below, in this regard Kotlin seems rather conservative in design.
Re:Kotlin 1.2.20 released
by cageface on Wednesday January 17, 2018 @09:11AM
(#16167982)
Kotlin is a conservative design, but very pleasant to use with best-in-class tooling. I'd love to have a reason to use it on a real project. They hit the sweet spot on a lot of metrics with this design IMO.
Re:Kotlin 1.2.20 released
by sus_007 on Wednesday January 17, 2018 @08:33AM
(#16167710)
For somebody starting to learn Android Development, is it recommended to study Kotlin simultaneously with Java, or should I just master Java first before touching Kotlin ?
Re:Kotlin 1.2.20 released
by yoz-y on Wednesday January 17, 2018 @09:40AM
(#16168194)
I have done little Android development and none in Kotlin. However, if it is anything like the Obj-C to Swift transition, then I would recommend to learn to write programs in Kotlin but learn to read Java code. Most examples/tutorials/solutions will be in Java so you definitely need to understand them.
However, I think it is better to write all new code in Kotlin.
Re:Kotlin 1.2.20 released
by Larrikin on Wednesday January 17, 2018 @09:07AM
(#16167941)
Focus on Java, since 99% of online examples on the beginner side will be in Java and learning two language on top of Android will be a lot. There is no need to master Java before you begin learning Kotlin, but currently being able to convert between the two is still a requirement for effective development. Kotlin simply makes your life easier as a Java developer.
Re:Kotlin 1.2.20 released
by thibran on Wednesday January 17, 2018 @09:11AM
(#16167979)
Go with Java first. Kotlin fixes a lot of Java flaws and provides many Java-compatible solutions to those. Without knowing the flaws, you probably would have a hard time understanding the solutions.
Re:Kotlin 1.2.20 released
by V-2 on Wednesday January 17, 2018 @09:30AM
(#16168106)
You can't escape learning Java (as of now), but it doesn't mean you can't follow it along learning Kotlin. It does not have to be one, then the other. It's just a matter of managing the cognitive load, and that's your private preference.
Re:Kotlin 1.2.20 released
by phreack on Wednesday January 17, 2018 @08:44AM
(#16167792)
Kudos to the team on not just a sane style guide, but an IDE to help in keeping it! Not having to worry about this helps newbies a lot to focus on learning the language, so it's come far in becoming a great one to teach programming basics.
Re:Kotlin 1.2.20 released
by relics443 on Wednesday January 17, 2018 @11:45AM
(#16169388)
I think the core team is opposed to it. IIRC it's because they don't want to surprise anyone with the type used for collection literals, but it might have been something else.
If JetBrains didn't make most of their money with their IDE, they would probably put more effort in providing general tools that can be used with any IDE/editor. In this sense, I think JetBrains is hampering the success of kotlin. They should try to give kotlin a better organisational foundation.
Even typescript (a MS product) can be written with all sorts of IDEs/editors.
I've found the same of IntelliJ products. They're so good that I don't mind being forced to use them.
I left the Java world because I couldn't stand having to have all of the hand holding just to achieve simple goals. I'm not saying Java or Kotlin are _bad_ languages at all. Perhaps I'm just bugged by the general attitude that "everyone will have IntelliJ".
In a language built for the same platform where Scala has already been available for a decade it's very disappointing though.
Kotlin's biggest strength is that it brings near-perfect Java interoperability. Almost any code that runs on a JVM released in the last 10 years will interoperate with Kotlin with minimal hassle.
Boutique languages on the JVM are old hat by now, and they're neato and everything, but most people do not have the luxury of getting to choose to base their company on one of them. Kotlin is so compatible with Java that you can mix Java and Kotlin code freely in the same project, allowing people to move to adopt Kotlin gradually, without throwing away their extant business logic or requiring the wholesale sign-off of everyone in the org all at once.
Kotlin may not be the most theoretically pure language, but it lets you hit the ground running while shedding many of the crusty, obnoxious parts of the Java language. We've badly needed a semi-modern JVM language for the working man, something that doesn't get in the way and makes the business of doing software simpler. That's why Kotlin has had such an ecstatic reception.
SBT is indeed a wreck, just ignore it (at least to start with) and keep using whatever you were using (Maven or Gradle or what-have-you). In maven and eclipse/scala-ide with the m2eclipse-scala plugin installed I always found it "just worked": add the scala plugin to the pom, let eclipse notice that it's Scala, create a Scala class in the project and keep going. The IntelliJ experience is only very slightly more involved (have to manually tell IntelliJ to update the project config with Scala nature).
> while it's ostensibly interoperable with Java, there are many caveats.
> Kotlin's biggest strength is that it brings a reasonable amount of modernity with near-perfect Java interoperability. Almost any code that runs on a JVM released in the last 10 years will interoperate with Kotlin with minimal hassle.
This is the Kotlin narrative but I don't think it's actually supported by the facts. In the early days Scala looked perfectly interoperable with Java, but as we started writing more substantial things in Scala and a native-to-Scala library ecosystem developed it became clear that there was more to interop than being able to call methods directly, as nice as the latter is. As Scala became a full-fledged language with its own idioms we started needing idiomatic wrappers or native-to-Scala libraries. This is happening in Kotlin too, e.g. look at how http://arturdryomov.online/posts/kotlin-the-problem-with-nul... talks about having to consider whether calls are into Java libraries or not and treat them differently if they are.
And if anything I'd say this is getting worse for Kotlin with "modern" Java code: Java 8 is seeing more use of Optionals (particularly in streams) which correspond directly to Scala but are more difficult to interoperate with in Kotlin with its null-oriented design.
But in the vanishingly rare case where you have a performance-critical codepath that needs to zigzag back and forth between Java and Scala... it's still not a problem, because it's easy to work with the Java collections in Scala. The absolute worst case is "just using their Java API" (the same thing you dismiss about using Optionals in Kotlin). But since Scala has typeclasses we can actually do much better than that.
Given that after literally years of Scala experience I could easily write code I couldn't read three months later, this is not a big negative.
Kotlin takes a lot of the good from Scala, leaves most of the bad, and gets the hell out of my way (while giving me literally-perfect Java interop--the only problem I ever had was how to annotate only the getter part of a property, and it was unintuitive but I figured it out). I'm a big fan.
The complexity I end up carrying in my head is way, way too high.
Hmm, that's backwards from my experience. Like, I actually regret it when I use the Future-specific operations on Futures, because I don't use those often enough to remember what they are, whereas I use the generic Monad operations all the time on pretty much everything.
> trying to get something out the door that doesn't turn into a mess of code I have to sit down and chew through, slo-oo-owly, is a heck of a fight
I find often something that would be 10 lines of Java or Kotlin can be 1 line of Scala - but still 8 lines' worth of reading time. It can be difficult to remember that this is an improvement when you're thinking "why is it taking me all morning to read 10 lines?", but when you take a step back you realise that those 10 lines are actually doing the work of many more.
https://kotlinlang.org/docs/reference/multi-declarations.htm...
https://kotlinlang.org/docs/reference/collections.html
?
However, if you look just at Kotlin's syntax, the default is meant to be immutable while the mutable version is longer: listOf versus mutableListOf.
That looks very much like design and not like an afterthought.
There's exactly one unusual/novel feature in the language (AIUI), and it's a feature that I personally find inspired: anonymous receiver functions, as it makes EDSLs trivial to write.
(I think it's a very good idea, but it's as innovative as anything you'll see in e.g. Scala, so it makes a mockery of the "blue collar" narrative)
Non-representable types are also decidedly "novel" (in the sense of "wtf?"), as are some of the details of their preferred way of doing await/async (assuming they haven't radically changed again in a minor version as they did in the past).
The only sense in which Kotlin is blue-collar is that it prioritizes immediate use cases over consistency and theoretical coherence. That's not "Java as if it had been designed today", that's "Perl as if it had been designed today".
It is a new language on JVM. It also suppose to work with Java libraries. So it won't radically different from Java.
However, I think it is better to write all new code in Kotlin.