News for hackers. Stuff that matters.
Re:Swift on Windows by alexashka on Tuesday September 22, 2020 @05:29PM (#24560171)
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

Re:Swift on Windows by nl on Wednesday September 23, 2020 @02:27AM (#24563643)
> 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.

Re:Swift on Windows by jug on Tuesday September 22, 2020 @06:09PM (#24560561)
Sounds a bit like developing in Haxe: https://haxe.org
Re:Swift on Windows by alexashka on Tuesday September 22, 2020 @06:24PM (#24560700)
Haxe 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?

Re:Swift on Windows by ckok on Wednesday September 23, 2020 @02:15AM (#24563560)
Sort 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.

Re:Swift on Windows by bsaul on Tuesday September 22, 2020 @06:19PM (#24560654)
I 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.