Takeaways from KotlinConf 2017
vokal.ioKotlin Native is exciting. But there's another way to run JVM languages, including Kotlin, on iOS: the open-source Multi OS Engine (https://multi-os-engine.org/), which basically brings ART (the Android Runtime) to iOS. Note: It doesn't bring the Android UI toolkit, or any cross-platform toolkit, to iOS, so you have to write UI code for iOS. But I think that's as it should be.
Of course, there's a trade-off between Kotlin Native and Multi OS Engine. Kotlin Native is a lighter runtime. BUt with MOE, you can use arbitrary libraries that target the JVM (well, the JVM subset that works on Android). So MOE makes a lot more existing code available for iOS. For Kotlin Native to truly deliver on the promise of cross-platform business logic, a Kotlin library ecosystem independent of the JVM will need to develop.
This space is going to be interesting to watch over the next little while.
The Multi-OS engine has a much narrower scope than you describe: really just write apps on Android and run them on iOS.
It's not a way to run a JVM language and certainly not a way to generate Kotlin code for native targets.
Kotlin Native is very exciting because it's a potential threat across the board: not just to run iOS apps written in Kotlin, but also to generate native code from Kotlin in back end system, a domain that's currently heavily contested by both Go and Rust, and also to write Kotlin and generate Web Assembly.
It's going to be a very interesting next lustrum.
> For Kotlin Native to truly deliver on the promise of cross-platform business logic, a Kotlin library ecosystem independent of the JVM will need to develop.
Or someone writes a bridge between native Kotlin code and AOT'd JVM code. Or someone writes a kind of reverse compiler from JVM bytecode to Kotlin. Not sure how practical either is due to sheer JRE stdlib size.
Look at SubstrateVM. It's capable of making fully stripped AOT compiled binaries with a bundled JVM that only use the parts of the JRE library that are needed. Sort of like what Go can do.
Yup. There is also jaotc coming along. Regardless, to use a them from Kotlin Native would require bridging between the two.
> The organizers developed conference apps for both iOS and Android using Kotlin. They also built the API in Kotlin using Ktor, a framework for building server-side business logic with Kotlin.
This is really cool! Excited to dig into their repo: https://github.com/jetbrains/kotlinconf-app
Looking forward to hearing more about Kotlin/Native. We need a proper solution for this problem.
I've done some work with it just recently. Happy to answer any questions, though I am not an expert. Overall, I think it fits very well in the Swift space and the tooling is clean. I wrote a sample DLL in it yesterday to become more familiar with it and work through some of the FFI challenges [0]. I have found it much easier to use than Scala Native (especially if you're a Windows person).
I think Kotlin/Native's approach of sharing business logic while keeping the UI stuff native is probably the right choice. Although something like Flutter which render's all their own widgets is interesting because it allows you to share even more code. The question there is whether they'll be able to truly match the native widgets and have all the accessibility stuff working.
In any case it's good that different projects are approaching this from different angles.
History says no.
Any widget toolkit, on any platform ever, that has tried to provide it's own cross-platform widgets, has been completely terrible and ends up being native-nowhere instead of native-everywhere.
I tend to agree with this. We need a way to natively address the complete set of each platform's capabilities without needing to worry about them falling out of lockstep if some centralized maintenance entity decides they're no longer sufficiently incentivized to maintain their social contract with their framework adopters. It may indeed be the case that we can already accomplish this with properly written (concrete implementation agnostic) modular code but fmpov there's no complete solution being offered to the public at present. My hope is that in the next few years we get to see Google adopt Swift. Then it's just a matter of reinventing the browser so we can build native web apps in Swift as well. :P
I'm curious if this will change now that webapps/electron-apps have become so popular. It may be that users have begun non-native apps as the new norm.
In five years the Electron craziness will be gone.
And, judging from what was going on 5 years ago, whatever replaces it will be even crazier and trendier :)
My bet, browser will be reduced to yet another general purpose VM, with the new trend being WebAssembly + Canvas/WebGL.
Or back to pure native.
what will replace it?
Native apps, just like it happened on Windows with XUL and MSHTML apps.
I'd love to see a React Native style kotlin library to enable cross-platform UI choreography using native widgets. Having done some RN stuff lately, the prospect of going back to go back to Activities and view controllers seems very dreary (I'm with Andy Matuschak on the superiority of the React model). Ditching the whole javascript toolchain for kotlin, gradle et al, while keeping components and UI-as-function-of-state, would be very appealing. I wish I had the chops to create such a library myself.
What exactly is wrong with view controllers..? That strikes me as rather like saying there's something wrong with 3GLs. Are you suggesting React solves the programming language problem completely? If not, I'd like to ask you again what is wrong with view controllers. I've had frankly endless success with them once I got over my lackings.
Well there's nothing absolutely 'wrong' with them. You can write good and bad apps with view controllers (I've done both). But they're an architectural blank slate, mainly offering access to UI objects & lifecycle callbacks. You need some architecture on top in anything but the most trivial app. The naive approach is to have 'no architecture', which actually is an architecture of just throwing masses of state, ad hoc, into the view controller, and using this to effect the UI any old how (so a 3rd party has no idea where to look to find out where things happen). Or you can go maximalist and select from MVC, MVP, etc, all of which are an improvement on the naive approach.
It just so happens that I've found RN (React Native) to be the nicest improvement, to my taste. Simple unidirectional data flow & UI state being a simple function of app state make for a beautifully clean and unambiguous model for how everything fits together.
One can argue the costs and benefits of app architectures all day, but there's really no substitute for trying them out, for the sake of curiosity & learning. All the devs I know who have written RN groan a bit when they're back in iOS and/or Android native development, and absolutely not because they love javascript!
Check out Andy Matuschak's celebrated Tweet on RN (https://twitter.com/andy_matuschak/status/560511204867575808). I point to it not as an argument from authority. But if one of the people who wrote UIKit thinks RN's model is the superior one, surely that should pique curiosity just a bit?
> Are you suggesting React solves the programming language problem completely
I'm not sure what you're getting at here. What 'programming language problem'? And why would an improvement have to solve something 'completely' to be of value?
> Simple unidirectional data flow & UI state being a simple function of app state make for a beautifully clean and unambiguous model for how everything fits together.
Not an iOS expert (I work on Android) but can't you have this in native in the first place ? Many Android apps are already using this kind of arch without React Native. I don't see why it can't be the same on iOS.
Yes, but it doesn't come for free. You have to adopt an architecture & write the relevant boilerplate, or use a library where relevant. In the RN case, the least trivial part is applying UI diffs representing the move from a previous to next app state.
Have a look at my parent post -- what I was expressing a wish for was a cross-platform Kotlin library implementing RN-like UI rendering. I'd love to get a combination of the benefits of the RN approach, but written natively in Kotlin.
Sounds like you're asking for some sort of abstract windowing toolkit ... we might call it AWT ;)
An idea whose time has come (or cyclically returned)?
That is what I do with C++ for sharing business logic.
Only need the SDK tooling, without being forced to debug extra layers of third party tools.
Using extra, non official language X usually overshadows the extra debugging and configuration efforts of adding yet another layer into the overall architecture.