10 ms·
Kotlin 1.0.5 is here
- gregschlom 10y agoKotlin has been a joy to use. Really happy with it. Our Android app (http://play.google.com/store/apps/details?id=com.eatsa.app http://play.google.com/store/apps/details?id=com.eatsa.app) is 100% Kotlin (with a good amount of Java libraries of course). Some highlights: - Great type system, with type inference. - Full Java interop. You can literally copy/paste Java code from Stackoverflow and it's automatically translated to Kotlin. It doesn't feel like 2 different languages. Working with Java libraries doesn't feel awkward or foreign, like in many other JVM languages. - Beautiful syntax that allows to construct some pretty advanced DSL, yet because it's statically typed the IDE can always resolve the DSL constructs and take you "under the hood" to the actual code that's going to be executed. This is in contrast to languages such as Ruby where most of the time when you encounter a DSL construct there's no easy way to understand what's going on.
- brightball 10y agoEven though I'll happily claim to being all aboard the Elixir train, I've looked at Kotlin due to so many of my Java friends talking about it. I really like everything I've seen from it. If/when I finally need to get around to learning to make an Android app it's definitely the first place I'll look.
- salimmadjd 10y agoMy first thought was, a post to promote an app. But then, realize it's Eatsa so it probably doesn't need any promotion. What I like to know is the following: What are some of the challenging issues of using Kotlin? Did you start from Kotlin or migrated from java to Kotlin? What drove the decision to use Kotlin in such a visible app? What are the top 3 - 5 improvements or things you want to see? Thanks
- gregschlom 10y agoYeah, I only included the link as a proof that we're actually using Kotlin in production :) 1. Kotlin issues: - Libraries that use reflection (such as Gson) can break some assumptions that Kotlin makes (for example, a read-only field may actually change). There's maybe 2 or 3 little things like that that may catch you by surprise, but once you figure them out it's easy to work around them. - Stack traces in lambdas are obscure sometimes. Sometimes you won't get the line number. - Proguard integration has proven challenging. 2. We started from Kotlin. 3. Learning Clojure and Haskell has made me yearn for more functional languages and better type systems. Kotlin has that, in a neat syntax that's very beginners friendly. I'm firmly convinced that a good programming language needs: - Strong library ecosystem - Static type system + type inference. (I won't get into the static/dynamic argument here. Suffice to say that there's a whole class of bugs that you can avoid with static typing, and type inference makes the "but I hate these types cluttering my code" argument irrelevant) - Killer IDE support (essential for productivity. If you're writing a large application without using an IDE that gives you code inspection and navigation, you're wasting your time) Kotlin has these 3 things. 4. Top improvement: can't wait for Kotlin 1.1 to be released, and start using coroutines. Other than that, I'm happy with it.
- Nullabillity 10y agoAlso, using it with RoboGuice is a bit annoying. At the moment I use vals, but it still requires me to mark injected dependencies as nullable (and coerce them with !! on use), which feels like I'm fighting the type system. It would be really nice if there was some sort of "special" null that was of the non-nullable type, but could only be used when initializing variables.
- gregschlom 10y agoWouldn't a `lateinit var` solve the problem in this case? (Although the downside is that now it's a variable) Otherwise I'm sure you can come up with a good solution using delegated properties or something like that.
- Nullabillity 10y ago
- dimascyriaco 10y agoIs the iPhone app a completelly diferente codebase?
- adrianlmm 10y agoWhy not use Xamarin? it has a better lenguaje (C#) and is free.
- on_and_off 10y agoC# better than java, maybe but than Kotlin ? That's a very subjective opinion. Apps written in Xamarin and kotlin work very differently : -with Xamarin you have to add the Xamarin runtine and depend on its integration. This brings several downsides : http://www.slideshare.net/KonstantinLoginov/we-are-ditching-xamarin-why http://www.slideshare.net/KonstantinLoginov/we-are-ditching-... -Kotlin outputs bytecode, so from the outside, it is just the same as any android app written in java. The output is a standard android app with one more library (the standard kotlin lib with all its base methods)
- bitmapbrother 10y agoProbably because IntelliJ is a superior IDE, Kotlin is a better language than C# and Xamarin apps look and perform like ass.
- V-2 10y agoI like both, but why do you consider Kotlin better than C#? I also don't get your point about how lame Xamarin apps look. Xamarin apps use native layout components (could be wrapped with lowest common denominator abstractions in case of Xamarin.Forms, but it's optional), so they're 100% capable of looking the same way your native app would.
- voddan 10y agoiOS and Android UX guides have completely different approaches to the logic of user interaction. AFAIK, Xamarin does not allow to have different layouts generated from shared code. So, even that components are native, their placement is alien.
- V-2 10y ago> Xamarin does not allow to have different layouts generated from shared code That's true, but noone says or recommends that all the code is shared. Typical Xamarin architecture and good practice assumes sharing the business (or domain) layer, and coding the views separately. In terms of reusability it's still superior in comparison to writing both versions natively. Obviously the level of reuse you can achieve that way very much depends on the nature of the application.
- gldalmaso 10y agoAnyone using Kotlin to compile to javscript in a large app care to share some experiences?
- avodonosov 10y agoJS support was an experimental and TODO for a long time. Is it ready now?
- mr_tristan 10y agoI don't believe JavaScript will be "un-experimental" until Kotlin 1.1 is out.
- jean79 10y agoWe do. We are migrating our WPF, Flex, VB6 apps to our custom fw based on KotlinJS, ViewModels and bindable properties. There are some kotlin features whixh are not yet supported by JS compiler, ocassionaly something stops working with a new version of Kotlin plugin, but in general it is still the most productive frontend solution I experienced. We also generate a Kotlin domain classes from our Java backend domain objects to keep strongly typing when building UI.
- isoos 10y agoI have found Kotlin and Dart similar in many aspects, with the major difference that Kotlin is much better if you have a ton of Java libraries that you want to use along your code, while Dart is much better if you want to do frontend development. I'd suggest to check it out if your primary focus is compiling to javascript.
- KennyCason 10y agoI have became a 100% Kotlin convert. Every single project I work on now is using Kotlin. I have also found that if you are using LibGDX Java game framework, it's very trivial to convert it to Kotlin. I have been doing that pretty extensively and it has been very pleasant. Feel free to check my GH for some examples. Most notably, the Bayesian Classifier. Also be sure to check out the Kotlin slack room. It is filled with a bunch of great and active people. But most importantly, just go try it. If you come from Java and are hesitant to leave given all the nice libraries available in Java, Kotlin is for you.
- sdegutis 10y agoOn the topic of using the JVM to make games, do you find yourself using the trick of not allocating any new objects (wither from Java or Kotlin) within the game loop? I've heard of that trick, and am considering using it because GC pauses are the main reason I'm considering avoiding the JVM for games.
- KennyCason 10y agoDefinitely. The use of object pools for performance is common in game development regardless of language. It's something that I tend to add in as needed or when I have decided that a game I'm working on warrants this level of engineering. (i.e. I wouldn't care about it as much if I'm just programming pong or Tetris.)
- sdegutis 10y agoAwesome thanks for the advice. Maybe one day I'll get around to making that video game I wanted to make 15 years ago. :D
- KennyCason 10y agoGood luck! Game development is what got me addicted to coding to begin with! :)
- mike_hearn 10y ago
- meddlepal 10y agoKotlin is great and we're using at in the backend at Datawire.io. Also we're hiring! Check us out if you're a backend JVM/Kotlin developer and are in the Boston, MA area! https://www.datawire.io/careers/ https://www.datawire.io/careers/
- sdegutis 10y agoDo you use any specific Kotlin (or other JVM lang) web framework for your backend, or did you roll your own?
- meddlepal 10y agoVert.x 3 currently. First class Kotlin support is dropping before the end of the year according to the Google Group for Vert.x but for right now the excellent Java/Kotlin interop hasn't prevented us from building.
- claudiug 10y agovertx looks very slow compare to other java frameworks. And the fact that you can use them and you will the same speed asta java... https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=query&l=27wqyn https://www.techempower.com/benchmarks/#section=data-r12&hw=...
- meddlepal 10y agoHard to say what's going on there. Vert.x itself is quite speedy. The DB access module they use (http://vertx.io/docs/vertx-mysql-postgresql-client/java/ http://vertx.io/docs/vertx-mysql-postgresql-client/java/) is still in technical preview so there may be legitimate issue with the module or something wrong being done (I only glanced quickly and didn't see anything immediately obvious). Vert.x really isn't much more than a pleasant facade over Netty so it's hard to imagine what's actually wrong. It appears there may be an issue with the benchmark? https://github.com/TechEmpower/FrameworkBenchmarks/issues/2117 https://github.com/TechEmpower/FrameworkBenchmarks/issues/21... Personally, I don't really care about benchmarks. Getting stuff done is more important at this stage. Eventually this may become more important but I'm not going to worry about it until it becomes and issue for us specifically.
- nostrademons 10y agoSaw this pop up in my IDE this morning, excited to upgrade. The auto-for-loop-refactoring is interesting. I've found I never use for-loops in Kotlin - between the abundance of iterator methods and concise trailing-closure syntax, it always ends up being more concisely expressed as collection.forEach { ...body... }. Seems like the language may be going that way too; I wonder if we'll eventually see the for-loop start to fall out of use in modern languages.
- djfm 10y agoI make it a point never to use a for loop in JS. It's sometimes tricky but often leads to cleaner code.
- mike_hearn 10y agoWhat's unclean about for loops?
- tlarkworthy 10y agoMutating index state variables, and it's not functional (you can't pass a function to be the inner loop)
- deleted 10y ago[deleted]
- willtim 10y agoFor loops require explicit and error-prone use of integer indices and are of limited utility outside arrays. Foreach loops in Java/C# are an attempt to generalise, but they are really just syntactic sugar over external iterators. They give privileged status to the specific iteration interface chosen, entangling the language and its libraries. The actual Iterator interface chosen by Java has proven to be unsuitable for coroutines/yield, but is now too difficult to change. In Haskell, foreach loops can be implemented purely as a higher-order library function.
- 10y ago
- maaaats 10y agoSaw a great Kotlin talk by Hadi Hariri from JetBrains at Javazone this year. [1] What I liked about it was that instead of the usual "this is how you do X in language Y" it focused on the immediate value it could bring to professional developers used to Java. Made me really want to try it out and start using it at my job. [1]: https://2016.javazone.no/program/kotlin-ready-for-production https://2016.javazone.no/program/kotlin-ready-for-production
- dxxvi 10y agoIs there anybody switching from Scala to Kotlin?
- runT1ME 10y agoI can't imagine anyone who has used Scala for long would switch to Kotlin. Kotlin is 'Java++'. Scala is a fully featured functional language. Kotlin is missing all of the most powerful Scala features. No type classes, monadic comprehension, higher kinded types, adhoc polymoprhism. :(
- Apocryphon 10y agoNot everyone needs a functional language.
- V-2 10y agoWell, it's kind of the point. Kotlin is supposed to be light weight and easy. Besides, using Scala for Android, while possible, is cumbersome. Kotlin wins this one hands down.
- simono 10y agoWhich issues did you experience?
- lmm 10y agoScala for Android is fine. The only thing that makes it harder than Kotlin is JetBrains disingenuously shipping their Kotlin plugin but not their (more popular) Scala plugin by default, which they could fix tomorrow if they wanted to.
- V-2 10y agoLast I checked, Kotlin plugin isn't installed (in Android Studio) by default. Are you referring to IntelliJ Idea? I tried to use Scala for Android in the past and I gave up after attempting to set it up for a few hours. Admittedly it was a while back, perhaps things have improved. Your claim that Scala on Android works fine got me interested again, so I googled around, found that blog post from May this year (that's more recent than my own experiments), and apparently there are still hurdles: http://blog.scalac.io/2016/05/19/reflections-on-starting-android-project-with-scala.html http://blog.scalac.io/2016/05/19/reflections-on-starting-and... With this type of issues the thing that I'm wary about is not getting a "hello world" app to compile once, but that I can get a project up and running, then need to add something else to the equation (say, a DI, or some code processor), and things fall apart again in an X-Files fashion. I've heard that Scala has long build times, too, but maybe it's a thing of the past as well - no first-hand experience here as I never got to that stage.
- xiaoma 10y agoI'm torn on this. On one hand, Kotlin is great. It's not Scala but it gives you a whole lot while maintaining the ability to very easily swap in for Java. On the other hand, it's controlled by Jetbrains—the company that now offers a "yearly license" of many of its compilers at the same price point it once sold them for, after which time they forcibly downgrade the software their users have paid for. It's not illegal and some even agree with the practice on an ethical level, but it's clear that Jetbrains is all about hoarding as much consumer surplus for themselves as they can. If only Kotlin were truly an open project and well supported outside of the Jetbrains marketplace, e.g. by VS Code, I'd be cheering it on. -former webstorm/rubymine customer
- mike_hearn 10y agoI don't really get that. Kotlin is open source. You can write and compile Kotlin code without paying JetBrains a penny, it's not hard. There's even an Eclipse plugin - written by JetBrains. I'm not sure what more is required to make it truly open.
- xiaoma 10y agoWhat non-Jetbrains IDE supports Kotlin well? What % of its contributions come from outside the Jetbrains ecosystem? Once Jetbrains no longer controls Kotlin's future and most Kotlin users are not Jetbrains customers, then I'd consider it truly open.
- trevor-e 10y agoI think you're confusing language openness with freedom of choice for consumption.
- xiaoma 10y agoI think you're confusing deduction with speculation. I'm fully aware of the difference between language openness and "freedom of choice for consumption". I just don't agree with the wisdom in tying my workflow to a company like Jetbrains.
- carsongross 10y agoCongrats to the entire Jetbrains team. Great language, greater IDE.
- edem 10y agoI can also vouch for Kotlin. I am actually not an Android dev and I started using Kotlin for a backend project (uses Spring Boot) and I was pleasantly surprised how easy my switch to Kotlin was.
- on_and_off 10y agoIt also finally solves the Android Studio bug that would show all the Databinding code as erroneous in the IDE. The tooling is still a bit rough around the edge compared to the base Android one, mostly because the android tools team really does an awesome job. It is still useable though, and the language is so much better than java that it is a breeze to use. The only downside is that you have to interface it with java code, which brings a couple of issues.
- skybrian 10y agoIs there a lambda-to-loop refactoring? Every refactoring should have its inverse. For loops are often better than map() calls (not always).
- davidsawyer 10y agoI'm curious to hear from anyone with a Groovy background that has worked with Kotlin as well.
- vorg 10y agoApache Groovy's original creator, James Strachan, worked on Kotlin for a while after, er, leaving the project, as also did Alex Tkachman, creator of Groovy++ which was cloned as the static typing facility in Groovy 2.x.
- sandGorgon 10y agoHi guys, what is the Kong term story here ? We have been yearning to use kotlin for our Android app and backend...but have been worried about Oracle doing something that breaks compatibility, or jetbrains going out of business as a company. I see a few people have adopted it - what do you guys see as the future of the language? Do you think java8+Lombok is moving in a direction that makes kotlin useless ?
- chenshuiluke 10y agoFor those who use Kotlin to target Javascript, how does it perform against something like Elm?