3 ms·
This is arguably already the state of things. Rust might get compiled down through MIR, down through LLVM IR, down to assembly or wasm... which then might be J
by MaulingMonkey 4y ago
This is arguably already the state of things.
Rust might get compiled down through MIR, down through LLVM IR, down to assembly or wasm... which then might be JIT or AOT (re)compiled into other bytecodes... which might perhaps be decompiled back up to C... and C might be retranslated back to horrific unsafe-spamming Rust by the likes of https://c2rust.com/ https://c2rust.com/. We've come full circle!
The main issue is that retranslating high level languages into other high level languages isn't something that there's actually a lot of demand for, especially commercially, especially given the N x M translation matrix going on. So a lot of the projects "stabilize" (get abandoned). And automatically translating between the idioms of those languages gets even nastier in terms of matrix bloat.
Well, you've got stuff like MSIL and JVM bytecodes which are higher level, and preserve more type information, and can be compiled to / decompiled from while still preserving more structure, but they still form competing incompatible ecosystems.
- anyfoo 4y agoThe very premise is bad. You want to use Rust precisely so that you can write Rust code. The selling point of Rust and most other languages is that they provide a sane, safe, convenient, easy... (pick some of them) interface to the programmer.
- l33t233372 4y agoThe Unity game engine created a library that transpiles C#(technically the byte-code) into C++[1]. The generated code isn’t particularly readable and it comes with some security issues[2] but the upshot is you have the benefits of a C++ compiler. [1]https://docs.unity3d.com/530/Documentation/Manual/IL2CPP.html https://docs.unity3d.com/530/Documentation/Manual/IL2CPP.htm... [2] https://github.com/djkaty/Il2CppInspector https://github.com/djkaty/Il2CppInspector
- j16sdiz 4y ago> the benefits of a C++ compiler. Is there any? I think most modern compiler share the same codegen backend. You don't get the benefit of the frontend when you transpile.
- MaulingMonkey 4y ago> Is there any? I think most modern compiler share the same codegen backend. JIT-focused .NET is one of the ecosystems disparate from AOT-focused LLVM. While there's a bit more cross pollination now, at the time the C# to C++ transpiler was authored, there was much less so. I've taken a stab at porting mono to a new platform at a similar time period - it was rather nontrivial (I ran out of time and thus failed.) Worse still, many of Unity's targets (e.g. iOS, XB1, ...) explicitly ban JIT technology in the name of security, which wasn't something I had to deal with. A MSIL bytecode -> C++ translator might be pretty quick and dirty... yet effective, gives you AOT compilation, avoids the need to explicitly target every architecture by hand. For all it's faults, it's not too terribly hard to figure out how to compile C++ for a given platform, typically, generally requiring exactly zero reverse engineering.