100 points · by prof18 · 5y ago · 49 comments
And one day I had to work on a project that was 100% kotlin and so i decided to do a 3 hour crash course on Youtube (actually watched it at 3x speed so it was really 1 hour) and once I grasped the basics it really made so much sense and I don't think I'm ever going back to writing Java classes anymore after having seen the light.
Same happened with xpath long back. So long I resisted learning it because CSS selectors did the job but once I reluctantly learned it it changes your whole way of thinking.
I think my fear of learning new things comes from coffeescript, something that actually had a negative impact and I would have better off not learning it which also made me scared of learning new technologies.
Also unlike stuff like CS it has a very strong future with Android backing.
Java has much more inspections, more intentions and some next generation inlay hints such as the "related problems" view. Thankfully Kotlin is catching up (and is e.g currently getting support for code vision)
On the other side Kotlin is THE language optimized for developper Happiness/ergonomics and its shows that it has been designed by IDE developers.
Groovy was great for “more than Bash” and DSLs.
I was wrong. Last year we gave Kotlin a try as a team and at this point we’re 100% Kotlin where we would’ve been using Java or Groovy (which would be the vast majority of our code).
Spring and IDE support has made this transition easy. Coroutines are great for the type of code we write, SAM advances in Kotlin 1.4x have removed the last couple “I like the way Java handles that better”. Best off, all of those libraries we already created and use are still completely usable, we didn’t have to rewrite anything.
For me nullability checks by default, synthetic/map backed properties, extension functions, inline/reified functions, and coroutines have so drastically improved the readability AND conciseness of our code I can’t imagine going back.
By way of example:
Final classes by default with an open keyword instead of open by default with a final keyword. Inheritance is a very tricky thing to get right and it’s better to explicitly say “I thought about this and put in the effort to make it work”.
Checked exceptions are a contentious topic and I’m not sure which choice I prefer, but Kotlin chose to remove that, and it has an impact on style.
Now, guess it's not Scala, by Kotlin. Why? - First class citizen for Android development. Yes, most of my works is on Android.
- Not to foreign compared to Java. In general, Java devs should be able to Kotlin in relatively short time. Not sure about Scala, which is influenced by Haskell/ML etc. At least in my circle, not many folks familiar with functional programming.
- Of course now Spring also supports Kotlin :)
Highly ironic since Java was the hot, shiny, and new thing when it came out.
So basically I can confirm "Android’s Kotlin-first approach" https://developer.android.com/kotlin/first
I guess I remember incorrectly it was 3 hours long. It is only 1hr few minutes and you can easily watch it at 2x speed.
But overall Youtube is a great resource for learning new things. If you search Kotlin crash course (filter by duration > 20min) you will find ton of such courses and you can easily judge them by number of likes/dislikes.
And make sure to watch it at 3x speed with subs ON initially (video speed controller for chrome). This is truly a great hack when learning tech things via video.
Come to think of maybe I didn't learn it well enough at that time and blamed it for my silly mistakes. CS did introduce a lot of good things like the fat arrow which was just amazing at that time.
To inject some time perspective, Clojure is 14 years old, so it's not too bad to be moving from initial steam to young-adulthood steam now :)
There even are frameworks that make writing such plugins easier such as https://github.com/arrow-kt/arrow-meta (which enable to bring union type, higher kinded types, pattern matching, etc) Or https://github.com/google/ksp
Manifold[2] is basically a javac plugin if I'm not mistaken, and it shows just how powerful stuff can be accomplished with this approach (including e.g. auto-generation of Java types from common modelling languages like GraphQL, JSON, YAML etc. adds extension methods, unit expressions, ranges, C++-like preprocessors, structural subtyping, even crazy stuff like type-safe reflection - like Ceylon used to have!).
For Groovy, besides the built-in AST annotations like `@Immutable` and `@Canonical` (which turns a class into a data class, basically), you can achieve stuff like the Spock Testing Framework[3] which changes the Groovy syntax a little bit to make it really awesome for testing.
[0] https://www.baeldung.com/java-build-compiler-plugin
[1] https://groovy-lang.org/metaprogramming.html
[3] https://spockframework.org/spock/docs/1.0/spock_primer.html
It would be nice to have a list of such extensions of the language/bytecode
I regret so much losing Ceylon :(
Guessing this is a bit like Java's annotations. FWIW, I'm not a fan Java's annotation processing plugin stuff. It's fun for personal projects, cuz metaprogramming FTW. But debugging someone else's custom annotation stuff really sucks.
Basically, to stay on topic, there are currently multiple kotlin compilers, including one that transpiles to Javascript. There is also tooling to interface with npms, to adapt typescript type mappings to Kotlin, and a few more goodies. Basically you lose the java standard library but you gain access to the browser APIs. Node API mappings are more of a work in progress but you should be able to target node.js as well. Browser side kotlin-js is pretty nice. You can do pretty much everything that you would normally do in js/ts. The build tooling uses gradle, which underneath uses webpack. There's a dead code eliminator, source maps, minification, etc.
Our web app uses cordova (for IOS and Android wrappers) with a few plugins, integrates Leaflet for maps, has reactive components (using co-routines and flows), has styled components, etc. So, pretty nice and modern way to do frontend. We have a handful of js things we integrate (like leaflet) and quite a few Kotlin multi platform things (like our own API client).
There is also a js backend for the new IR compiler, which is the thing that Jetbrains is currently building to unify the many Kotlin compilers they have. There is also a wasm compiler backend for that in the works but it's to early to rely on that probably. The IR to JVM backend is currently in beta and kotlin native also uses the IR compiler.
Kotlin-js is not for everyone just yet (a lot of these tools are beta quality) but if you are more comfortable with Kotlin than js/ts, it's worth checking out. That being said, our setup is quite nice compared to some react train wrecks I've been involved with.
That being said, it doesn't really make sense to try to use mainstream javascript frameworks as they are a poor fit for a strongly typed language like Kotlin. And in general, there aren't a lot of npms that are worth integrating. We made an exception for leaflet and that was pretty easy to integrate in the end. Otherwise we mostly use multiplatform kotlin libraries.
There's my crash course in Kotlin
We're talking about a company that sued it's own salesperson for earning too high of a commission.
Meanwhile the Oracle vs Google case is still going on.