15 ms·
Kotlin: A New Hope in a Java 6 Wasteland
- michaelmior 11y agoInteresting that this is being "introduced" now given that it's been around for several years.
- guelo 11y agoIt's still not at 1.0.
- networked 11y agoBetween Kotlin, Ceylon [1] and Xtend [2], all recent JVM languages that aspire to be an improved Java, which one would you bet to come out on top in the long run? [1] http://ceylon-lang.org http://ceylon-lang.org [2] http://www.eclipse.org/xtend/ http://www.eclipse.org/xtend/
- harryh 11y agoMy answer to this question used to be Scala. It has orders of magnitude more traction (and is a much better language) than any of the options you mention. The fact that it hasn't "happened yet" is a bit worrisome though. To the point that I honestly think the answer at this point is Java. It will never be awesome but it will get a bit better every year.
- cdbattags 11y agoI believe a lot of the lack of adoption has to do with how hard it tends to be setting up the environment for Scala dev on Android. Whereas, Kotlin aims to make it as easy as possible by working hand in hand with Android Studio/IntelliJ.
- harryh 11y agoI certainly agree that Typesafe (the company behind Scala) has hugely underinvested in tooling. The fact that they still (afaik) recommend sbt as a build tool is telling.
- andreaferretti 11y agoI happen to find sbt one of the few build tools (together with lein) that are decent enough. Do you have any particular reason for your dislike?
- harryh 11y agoIt doesn't work with large codebases. Or even very well with medium sized ones.
- dragonwriter 11y ago> It doesn't work with large codebases. This type of general conclusion isn't, by itself, particularly useful in discussion; a lot more useful would be presenting a summary of the specific facts and experiences that lead you to this conclusion.
- saryant 11y agoWhat size are we talking? I've had no issues with SBT on a 20k line codebase.
- eeperson 11y agoI'm using it on a 100k line codebase without issue. What problems are you having?
- merb 11y agoi'm loving sbt, but still on projects above > 100 dependencies it gets really really slow to download it, while with gradle (even i dislike it) it is way way faster.
- incepted 11y agoScala's runtime also disqualifies it from anything but toy projects on Android (something like 50k methods). This document goes in greater details: https://docs.google.com/document/d/1ReS3ep-hjxWA8kZi0YqDbEhCqTt29hG8P44aA9W0DM8/edit?hl=en&forcehl=1 https://docs.google.com/document/d/1ReS3ep-hjxWA8kZi0YqDbEhC...
- harryh 11y agoIsn't it fairly easy to slim down the runtime at build time to only the methods you're using? I was under the impression that this was possible, though I've never actually done it so what do I know....
- eeperson 11y agoYes, it is. This is commonly accomplished with a tool called ProGuard. Doing this comes with some other trade offs but it is easy to do.
- justthistime_ 11y agoJust because they didn't do their research doesn't mean it's not a no-brainer. > it requires build complexity All languages benefit from not having to deploy their standard library on every iteration, not only Scala.
- cdbattags 11y agoIMO, as with every "who will win out" scenario, it usually depends on how well word gets out, who's backing and just basic "do I like this". That being said, I really like Kotlin and the fact that it can be used easily with Android Studio and IntelliJ means I'll be watching it closely (more closely than all the rest).
- txrit 11y agoProbably Scala (although I hope Kotlin makes some inroads too), but I don't think it will ever displace Java in a significant way. Scala, outliers aside, is well loved by it's users [1], but not everyone wants to spend the time to learn it. Java remains popular because it's the nobody got fired for picking it default, not because it's technically superior to Kotlin, Celon etc. The Java language has become one of the poorest choices on the JVM and is showing its age when compared to the alternatives. We ditched Java for Scala for most work. It's fantastic to work with once you've learned it, but it's not a path for everyone who doesn't have the inclination to spend the time learning. [1] http://stackoverflow.com/research/developer-survey-2015#tech-super http://stackoverflow.com/research/developer-survey-2015#tech...
- incepted 11y agoLast I checked, Xtend generates Java, so it's kind of a non starter. A year ago, I would have put Kotlin and Ceylon on the same level in potential but Kotlin seems to have gained some momentum this past year. On the other hand, I barely hear about Ceylon, even though it's now approaching 1.1.
- ExpiredLink 11y agoJava 8
- Randgalt 11y ago^^^ Winner. The reports of Java's death have been greatly exaggerated
- Babylonian 11y agoBy default, it's the weakest of the bunch but everyone uses it because everyone else is using it.
- mindcrime 11y agoGroovy.
- thefirstzealot 11y agoPersonally, even though I like all 3 languages (ceylon, kotlin and scala - no experience with xtend) I came to appreciate the vision behind ceylon lately: the language is really well designed, with very few compromises. A lot of people overlook ceylon because the language is just not promoted too well currently: even though the documentation is comprehensive, it's not focused on the features the programmers are interested about. And they need more target platforms, but they are already working on that.
- zem 11y agoif ceylon had better android support (codegen and tooling) i would start learning it immediately. kotlin seems like it's gotten that right; if it builds up enough momentum that there's a good third party ecosystem of android libraries i can see it doing very well in the future. it's design is not quite as nice as ceylon's, and it doesn't do as much as scala, but it's a very pleasant language to use and jetbrains has some really good tooling for it.
- thefirstzealot 11y agoTrue, kotlin has the huge advantage that google switched to Intellij, and the team knew how to take advantage of this opportunity really well. It also helps that JetBrains is a much smaller company and with that, more focused on their core products. As opposed to that, I assume it is much harder for the ceylon team to get the entire company to support them. For example, even though vert.x 2.0 had support for ceylon, it's not clear for me if that is also the case for vert.x 3.0, and even if it is, ceylon still isn't featured as a main language on their landing page. But they are working on an Intellij plugin, which I think will be available in ceylon 1.2. And that is the first step towards Android support. Anyway, I hope both languages do well.
- dlandis 11y agoDoes JetBrains have any way to make money off of Kotlin? Most people use the free version of IDEA nowadays. Do they have consulting services for Kotlin? Seems especially strange since they seem to be admitting it will be irrelevant once Java 8/9 get on to Android.
- ryandvm 11y agoI'm no longer holding out hope that Java 8/9 will ever get to Android. I think it's more likely that we'll see Go, Dart, JavaScript, or even Swift become a first-class development option on Android. Swift would be especially nice. How fantastic it would be to be able to use the same language to target the two most popular mobile platforms? Of course Swift is also probably the least likely since Google is still smarting from the Oracle/Java debacle. The last thing they need is another decade-long copyright infringement fight with the richest company in the world...
- sangnoir 11y ago> I'm no longer holding out hope that Java 8/9 will ever get to Android. That would be a little foolhardy on Google's part, don't you think? Considering the ongoing 'API copyright' wrangle that is Oracle v. Google
- ryandvm 11y agoNot really. Their fight with Oracle would be entirely justified to avoid paying the largest copyright damages award in the history of software.
- drzaiusapelord 11y agoThis. Google is in a very ugly place with Oracle right now. Being able to jump ship might save them, but I'm not sure if Kotlin avoids all the legal troubles here. I do believe that Google will continue to lose as the history of the East Texas juries for IP is almost always gifting the patent/copyright holder. I wish our system had some kind of venue randomizer. Its clear that this district is a moneymaker for IP holders.
- tendertree 11y agowhat's difference beetween Kotlin and Scala??
- kensuke155 11y agohttp://kotlinlang.org/docs/reference/comparison-to-java.html http://kotlinlang.org/docs/reference/comparison-to-java.html
- oweiler 11y agoI love how fast you can get productive in Kotlin. With https://github.com/jetbrains/workshop-jb https://github.com/jetbrains/workshop-jb and some glimpses into the documentation you can get productive within a day or two. It may not be as expressive as Scala but still is a huge improvement over Java (or even Groovy).
- abreslav 11y agoGreat slides! I hope we'll be able to adopt this style for our introductory materials
- drdaeman 11y ago> Adding to your Kotlin to your project is pretty easy as now you can just have it mixed in with Java classes. You’ll need to add the gradle plugin to your build script, apply the Kotlin Android plugin, add your source directories, and include the standard library. Wanted to ask for a step-by-step guide for awfully lazy developers, but found one myself. I suppose I'll leave a link here: http://blog.jetbrains.com/kotlin/2013/08/working-with-kotlin-in-android-studio/ http://blog.jetbrains.com/kotlin/2013/08/working-with-kotlin... (haven't tried that yet, though)
- cmrdporcupine 11y agoI like what I see, though there seems to be significant overlap with Scala. Though I suppose Scala has never had much uptake in Android-land. http://kotlinlang.org/docs/reference/comparison-to-scala.html http://kotlinlang.org/docs/reference/comparison-to-scala.htm...
- pjmlp 11y agoIt doesn't help that the community shuns Android tooling instead of embracing it like Kotlin does.
- Cyph0n 11y agoThe big issue with Scala on Android is the size of the Scala runtime, which is around 5 MB. Kotlin's is about 900 KB if I recall correctly. I like to see it as a "mini" Scala for Android. Just like Scala, it's a pleasant language to write in.
- eloisant 11y agoYes, you pretty much have to use proguard when programming in Scala on Android. The other problem I had using Scala on Android is that the very nature of the Android SDK forces you to work in a way that is very Java-ish. There are some libraries that try to provide a nice Scala layer on the top of the Android SDK, but it never covers everything so you always end-up writing ugly Javaish Scala code.
- Cyph0n 11y agoI faced the same problem with JavaFX. .asScala calls everywhere!
- justthistime_ 11y agoIt seems that Scala has much more uptake on Android than Kotlin will ever have.
- ufmace 11y agoI haven't worked with Android or Java that much, but I tried out Kotlin a few months ago, and my impression was that it takes Java from several steps behind C# to several steps ahead as far as being a high-quality, efficient strongly-typed language. I also liked how simple it seemed to be to get it going on Android. The only downside is that it seems to be immature and not very widely adopted yet, but at least it has a strong backer in Jetbrains. I would like to hear what people with more experience in the Java world think of it versus other alternate JVM languages.
- eloisant 11y agoIt feels to me like a better Java, but still very limited compared to Scala. It stays very much in Java's paradigm. So while Scala doesn't have to fear Java's evolutions, Kotlin seems to be risking obsolescence when Java gets good enough - and it's already happening with Java 8. Just look at the article: they talk about Kotlin as a good language for people stuck with Java 6.
- incepted 11y ago> but still very limited compared to Scala. The fact that Kotlin has fewer features than Scala is what makes it appealing to me. Scala has become a kitchen sink with too many features, it's kind of the C++ of the 21st century in that respect.
- kbenson 11y agoI'm not really sure how to interpret that. To you, what's the negative aspect of a feature? If features are things to avoid, what's the benefit of Kotlin over something with less features, like Java 6?
- zck 11y agoA car plus an airplane has downsides in both car and airplane mode that cars and airplanes do not have.
- edgyswingset 11y agoI can't seem to find anything on the Kotlin Github repo that implies code like this: ints.filter { i -> i > 0 }.map { i -> i*i } will use deferred execution. Is this correct? If so, why?
- barrkel 11y agoThe type of 'filter' and 'map' should tell you whether they are eager or lazy. If they return something iterable and uncountable except by consuming, then they're probably lazy. If they return something array or collection-like, they're probably eager. I had a quick scan of the Kotlin repo, and I think it depends on the type that you start out with. The sequence stuff is lazy; the map stuff is eager.
- edgyswingset 11y agoLooking at the docs on Iterable, map and filter return List<T>, not another Iterable. I imagine this isn't a concern when you've got small data sets, but I wouldn't feel safe using this when performance is a concern.
- asdf1234 11y agoI haven't played with Kotlin in a while but if you want collection operations to be lazy you have to explicitly convert it to a sequence. So your example would be something like: ints.asSequence().filter { it > 0 }.map { it * it } and then you can convert it to a concrete collection type with toList, toHashSet, toArrayList etc.
- edgyswingset 11y agoThat's just baffling to me. Why would they advertise chaining together sequence operations like this as being LINQ-like (or like Clojure and other functional languages) when it's eager by default? What is gained by making these eager by default? It just seems like a poor choice to me. That's a shame, because I feel like it's otherwise a pretty well-designed language.
- kragen 11y agoThe most important thing about Kotlin is a bit hard to find — it’s licensed under the GPL-compatible Apache License 2.0: https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt https://github.com/JetBrains/kotlin/blob/master/license/LICE... Now that I know that, Kotlin looks pretty cool! It proposes solutions to a lot of the most painful problems in Java. I'm not sure the solutions are always correct, though. When I hear "null safety", I think "pattern matching on a Maybe sum type to statically ensure non-nullness", but what the talk says Kotlin actually provides is pressuring you into writing a bunch of your code in the Maybe monad, thus spreading nullness far and wide. The talk example is "println(a?.length())". Maybe that's the best pragmatic solution in Kotlin, or maybe the talk oversimplifies what Kotlin actually gives you, but it kind of seems like the wrong direction to go in to me (most of the time!)
- non-alexandro 11y agowhat about a?.let { println(it.length()) } or val let: Int? = arg?.let { it.length() } ?
- rattray 11y agoI don't think that's the way to do it in Kotlin (though I'm no expert). More idiomatic: fun myFunc(a: Int?): { if ( a == null ) { // handle the null case } // a is guaranteed non-null here } EDIT: And, of course, you can just use non-nullable types: fun myFunc(a: Int) { // a is guaranteed non-null }
- ufmace 11y agoI think the point isn't the Maybe stuff - Int? - but the non-nullable reference types. In conventional Java, every reference type is always nullable, so there's no way to strictly differentiate between things that couldn't possibly be null, and so don't need checking, and things that have a valid reason for being null, and should be checked and handled properly. Kotlin allows non-nullable reference types, so you can declare a method as taking a non-nullable reference to an object. Now within that method, you know that reference is never null, and don't need to check it. When you call it, you have to either check for null beforehand, or pass something that is already guaranteed not to be null. It's kind of like it builds a wall between things that could be null, and things that can't be, instead of having theoretical potential nulls all over your code. When you think about it, it seems like a pretty natural thing for a strongly-typed language to do.
- maaaats 11y agoHow come one can use other modern jvm languages on Android, but not newer Java? E.g., if you can make Android support Kotlin, why cannot Java8 be introduced the same way?
- pjmlp 11y agoBesides the sibling answers, the situation will only get worse. Java 9 brings modules. Java 10 has on its roadmap value types, JNI replacement, GPGPU support, new array model and whatever they might still consider.
- cdbattags 11y agoCan you expand on this?
- pjmlp 11y agoIn what sense? These roadmaps have been presented at multiple Java conferences.
- AnimalMuppet 11y agoI suspect that ctbattags meant "can you expand on why these will make the situation get worse", rather than "can you expand on what these things are". But I'm not ctbattags, and I'm not psychic, so I could be wrong...
- pjmlp 11y agoI see, then themgt's answer covers it. From a technical point of it just seemed obvious to me.
- themgt 11y agoIf you mean the "getting worse" part, I believe the implication is that Google's lack of control over either Java the language, or the Android device ecosystem upgrades, means the future would likely see increasing fragmentation/divergence in important core language features across Android devices, causing much developer pain. If one assumes e.g. in comparison Apple will in 2 years have 95% of devices capable of running Swift 3 apps vs. 15% of Android devices capable of Java 8, much less 9/10 ... it could be quite a competitive disadvantage for Android, as well as argument for adopting a forward-looking JVM language dedicated to compiling to 1.6 bytecode if you plan to do Android development.
- krschultz 11y agoI saw this talk in person and it was really good, I would highly recommend the time to watch the video.
- omyufu 11y agolol
- omyufu 11y agoyo
- omyufu 11y agoI kmow how to unblock the school computer to the out side wolrd like for really
- gagege 11y agoOkay, now stay in school and learn how to spell.
- vivin 11y agoI'm going to be using Kotlin for my next hobby project. Really excited about this language!
- winterbe 11y agoHere's a sample webapp using Kotlin, Spring Boot and React.js: https://github.com/winterbe/spring-kotlin-react-demo https://github.com/winterbe/spring-kotlin-react-demo
- tendertree 11y agoafter seeing the information about Kotlin, I think 'coffeeScript' which is more convenient, concise, easy to read than javascript. time is only one problem, it is immature can Kotlin support 'Spring framework ?, if can, it is more attract for Java developer
- doomspork 11y agoKotlin is my favorite JVM language by far, it's like Scala-lite. It has great tools thanks to IntelliJ. It's great how easily you can substitute Kotlin for Java in most projects, doing so with Dropwizard was quite easy: https://github.com/doomspork/kotlin-dropwizard https://github.com/doomspork/kotlin-dropwizard
- guymcarthur 11y agoWhat was wrong with Groovy?
- Morcane 11y agoI wonder as well, we use it in quite a bit of production applications and have really good experiences with it.
- gedy 11y agoIt was gigantically SLOW from my perspective - was excited when it came out, then noticed it was a magnitude slower for some things.
- vorg 11y agoDid you know Groovy was booted off the Codehaus hosting service and its 3 developers retrenched by Pivotal,Inc last January? And Groovy's backup plan to join Apache via its incubator is a hoax, just providing a cover story for a non-technical person to run the show in the background. Virtually all the links at Groovy's page at Apache redirect to "groovy-lang.org", which is privately registered to Registrant Name "Guillaume Laforge" and blank Registrant Organisation. This individual controlling this domain and holding passwords to other non-Apache infrastructure for Groovy is a non-technical person pretending otherwise. Looking at today's emails on the Groovy dev list, we see Cedric Champeau giving two examples of "non code committing" committers, but this Laforge would be a far better example as he doesn't have even one single email in the entire 6-month history of the notifications or commits lists for Groovy at Apache. Until "Apache Software Foundation" is listed as the Organisation, the incubation process isn't real. Even better would be if the technical people who actually built and tested Groovy took over. The only real reason they haven't tried is they know a worse predator lurks over at the Grails ecosystem ready to pounce if Laforge is toppled.
- pjmlp 11y agoI guess if it wasn't for Google forcing Gradle upon us, Groovy would no longer be relevant.
- guymcarthur 11y agoWhat was wrong with Groovy?
- newlang 11y agoWhat is with languages that swap args and type? It looks cooler? It says, "Hey look at me, I'm not like those languages your dad used, tee hee!". If I want a simple and clear to understand script language on the JVM I'd choose Groovy, in fact, Grails is a pure joy to develop with I've come to find out.
- joesmo 11y agoI think it's because Kotlin and Scala infer types so it's more convenient to write it afterwards, as needed, hopefully not to often.
- swsieber 11y agoThat's an excellent point: optional bits come last.
- deleted 11y ago[deleted]
- Roboprog 11y agoThat was a bit harsh, but oh the irony that C syntax is now considered "normal". Yuck. I admire the bravery of Guido the Python guy for giving C layout orthodoxy the finger when he designed his language. But of course Python doesn't have variables with explicit types to worry about where to put them :-)
- incepted 11y agoFor languages with type inference, this syntax makes the code somewhat cleaner overall. As for Groovy, it's barely statically typed so not really an option for me.
- djur 11y agoKotlin has almost exactly the same declaration syntax as Pascal, which would seem to me to be the platonic ideal of "language your dad used". Postfix type annotations go way back. They permit somewhat less ambiguous syntax for things like function types (see C's infamous function pointer declarations) and play more nicely with type inference (it makes more sense to drop the ': int' in 'a: int' than the 'int' in 'int a'). It's certainly not a radical or nonconformist choice to make while designing a language. It might seem unusual to people whose experience is with C-style declarations, but it really is just replacing one well-known syntax with another, equivalent well-known syntax.
- gosukiwi 11y agoI'm not a Java guy but I remember checking the language a few months ago and really enjoying it. I wouldn't mind if Java dies and people adopt languages like Kotlin and Scala instead. Of course, Java will never die, because of BUSSINESS APPS!
- arrty88 11y agoWhat are the well known kotlin shops? Are there any companies hiring explicitly for kotlin?
- e12e 11y agoI just wish there was an officially supported way to get set up with a kotlin-first Android project from the command line. So far the best documentation I've seen is: http://kotlinlang.org/docs/tutorials/kotlin-android.html http://kotlinlang.org/docs/tutorials/kotlin-android.html Which a) requires one use the IDE. Maybe not surprising from a company that sells IDEs, but it's not my dream environment. b) Even then, one is asked to manually "replace java kode with kotlin" (with help of a wizard). Couldn't we just get a script/function that'll set up a project targeting the desired Android API level? It'd be nice if kotlin provided a script/command-line utility that basically allowed the equivalent of: android create project -a Main -p hello \ -k com.example.app -t android-15 -g -v 1.3.1 cd hello/ # Note that even android sdk is broken, # one needs to manually change: # # runProguard false # # to # # minifyEnabled false # # in build.gradle gradle build # Start emulator (android avd...) # possibly (re)start adb server # adb install ./build/outputs/apk/hello-debug.apk I'm still figuring out the Android/java command-line/build workflow, but I suppose one should be able to drop the kotlin.jar somewhere, and add something to build.gradle. I've yet to find any documentation how how to do that (official or otherwise). Am I really the only one that wants a predictable, scriptable environment in which I can both initiate development from scaffolding supported by upstream, and have a reasonable grasp over the entire build process? I mean, we all want to automate this for Continous Integration, right?
- kensuke155 11y agoHere's the reference for building for Android with Gradle: http://kotlinlang.org/docs/reference/using-gradle.html#targeting-android http://kotlinlang.org/docs/reference/using-gradle.html#targe... And other build tools: http://kotlinlang.org/docs/tutorials/build-tools.html http://kotlinlang.org/docs/tutorials/build-tools.html
- e12e 11y agoThank you for the reminder, I'd looked at that, and forgot while figuring out why the "android sdk" skeleton didn't work (see note above about manually patching the build-file). At least now I should be able to get a proper java skeleton, fix the build, add support for kotlin. Only missing piece would be a supported "pure" kotlin Android project/skeleton generator. At some point I also looked at the Android example at the bottom of that page: https://github.com/JetBrains/kotlin-examples/tree/master/gradle/android-mixed-java-kotlin-project https://github.com/JetBrains/kotlin-examples/tree/master/gra... -- that is also IDE centric, and hasn't been touched in a while. Which doesn't leave me very confident that it's been tested with Android 5.1 and/or 6 alpha. I suppose I'll just have to push out a "howistart"-article if/when I figure out a process that is both easy and repeatable, and hope someone will help with filing bugs as it inevitably drifts towards being outdated as the android landscape changes :-)
- merb 11y agoI really didn't understand why they didn't started to work at scala and make it better?! Like modularize it more so they can have a subset working on Java and make the compiler faster / better / more tooling support. That would've been better with yet another JVM language. The community is splitting and splitting and still most people think in the same niche, but they always use their different syntax. I mean kotlin does a lot of things like scala but still tries to be his own language and doesn't use as much fp as scala does. it also uses 'it' instead of '_' not sure why they came to 'it' also the data classes so much work around stuff, thats just aweful. Hopefully Java will get more functional so that we don't get a too fragmented community. P.S.: Yes everything has it's place i just dislike whats happening in the it, so that everybody wants to do his own thing instead of working together.
- k_bx 11y agoKotlin brings few very clear improvements to Java, while Scala is a completely different language. There is no single "make it better" that would work for both. > Hopefully Java will get more functional so that we don't get a too fragmented community. Java did so much harm to programming community, it basically destroyed reputation of strong static typing as something considered "fun". Maybe it's time to move on, to split into better, more modern, elegant and expressive languages.
- justthistime_ 11y agoAs we have seen in most milestones, Kotlin is gradually moving closer and closer to Scala, because even they realize that "a slightly better Java" won't cut it in the mid-/long-term.
- incepted 11y agoI see it the other way around: Scala demonstrated that a C++-like beast with too many features is not what the community wants since Scala failed to gain any sizeable mind share. Kotlin is an attempt at taking the other road: building an incremental language over Java. We'll see in a couple of years if that experiment is a success.
- sheldor 11y agoHow come noone mentioned Xamarin? Coming from a C# background it's definitely the choice; even coming from a non-Java and non-C# background seems a better choice nowadays.
- aargh_aargh 11y agoI really appreciate that the page has a transcript and doesn't force me to watch the whole talk!