5 ms·
I'm more interested in a compiler that takes any of these languages (C#, Kotlin, Swift) that do the same thing slightly differently, converts them into a lowest
by alexashka 6y ago
I'm more interested in a compiler that takes any of these languages (C#, Kotlin, Swift) that do the same thing slightly differently, converts them into a lowest common denominator language that can then compile into any target I choose.
For example write code in Swift, compile to X, compile to Kotlin. Voila, I have cross platform code, just need to write some cross platform libraries that wrap UI, networking, etc for each platform.
Elements compiler [0] seems to do just that. Does anyone have experience using it in production? Why is this not being adopted as a viable cross platform solution?
[0] https://www.elementscompiler.com/elements/#platforms https://www.elementscompiler.com/elements/#platforms
- jug 6y agoSounds a bit like developing in Haxe: https://haxe.org https://haxe.org
- alexashka 6y agoHaxe seems to have no Swift or Kotlin support :( I'd be curious to know why that is, given that once you have a few languages working, adding more on, intuitively (I have no experience in this) wouldn't be too difficult, given how many features the languages share?
- ckok 6y agoSort of. I can't comment on Kotlin, but Swift is a different beast though. Swift's generics are very different from say c#, java or even c++ templates, especially when you mix them with protocol associated types, which are also sort of, but not exactly generics. In Elements we spent a lot of time on getting it right, and I think we have most edge cases covered for user code. The way generics are used in the Swift runtime library seems impossible to map perfectly on top of the concept of generics as C# has them though.
- bsaul 6y agoI have the impression that « finding cross platform librairies » for every types of I/O is actually a very very painful step, judging by the time it takes to get the swift stdlib work across all platform. The « low level language » is actually LLVM intermediate language, and LLVM already support building for all the major targets.
- nl 6y ago> I'm more interested in a compiler that takes any of these languages (C#, Kotlin, Swift) that do the same thing slightly differently, converts them into a lowest common denominator language that can then compile into any target I choose. For JVM and .NET/CLR based languages this is pretty easy and common. > just need to write some cross platform libraries that wrap UI, networking, etc for each platform. Congratulations, you've invented the JVM.