4 ms·
This will happen. Rust is going to be the language that runs everywhere, easily, and interops with everything. In the next year or two Rust devs will be able to
by brson 11y ago
This will happen. Rust is going to be the language that runs everywhere, easily, and interops with everything. In the next year or two Rust devs will be able to easily build and test for Linux, Windows, Android, OS X, iOS, and asm.js/webasm from a single unified toolset.
- haberman 11y agoYour statement is so optimistic that I am almost worried you are being sarcastic and making fun of me. :) Is this really going to happen? I notice you left C, JVM, and .NET off the list. What's the story for how you could run Rust on a JVM, or on a platform that has nothing but a C compiler?
- GFK_of_xmaspast 11y agowhat platforms in 2015 only have a c compiler (and not, for example, an assembler)
- haberman 11y agoAn assembler is probably pretty common. But assemblers aren't standardized or portable. I can believe that the Rust toolchain is pretty portable. But it's also big. Say someone wants to install my software on some weird platform like, say QNX. I'm not comfortable saying that step 1 for installing my (relatively small and simple) thing is: install the (very large and complex) Rust toolchain. I want to be able to ship C source that will compile anywhere. Though I am comfortable needing two separate C sources: a 32-bit source and a 64-bit source.
- mrec 11y agoLLVM has a C backend [1], though I don't know how complete/stable it is. Getting a bit sillier, it's possible (albeit probably not sensible) to decompile asm to C [2]. [1] https://github.com/draperlaboratory/llvm-cbe https://github.com/draperlaboratory/llvm-cbe [2] http://boomerang.sourceforge.net/ http://boomerang.sourceforge.net/
- haberman 11y agoYes I have been watching the revivied C backend with a great deal of interest! Haven't gotten it to work for me yet, but I haven't tried it for a little while. I would love to see it become a more common and well-supported part of the overall LLVM ecosystem.
- dbaupp 11y agobrson isn't being sarcastic. He's the driving force behind getting to that goal. (I personally wonder if the MIR work mentioned elsewhere in this thread would allow for creating a simple compile-to-C backend without too much effort.)
- brson 11y agoI am serious, but as you observed I also did not quite address your specific use case. Rust as-is with it's LLVM backend and lack of runtime has a clear path forward for anything LLVM can target (which is a lot now, and will be more in the future). This should get us into many platforms. The compile-to-C case is the most straightforward of the three you mention, but also the one I'm most skeptical of. I do understand that there are some venerable old and/or small platforms where C is the only option. I don't know any specific examples of what people want to do by transpiling to C though. The only thing I know with any certainty is '8-bit microcontrollers', and this is one case that Rust is likely to be a tough fit for (largely because it wants pointer-sized things to be 'big enough', as well as other reasons I've forgotten). Still, if it's necessary, it can be done with great effort (see the perennially broken LLVM C backend), but it's very low priority as of now. I'm not sure yet the role of a JVM/.NET backend for Rust (besides the coolness factor) and I don't think people have put a great deal of thought into it. What we will have though is easy ways to bridge between the managed runtimes and Rust for accelerating your managed code or binding to system APIs. This will be necessary for creating decent Android/Windows environments. (On the .NET topic a MSIL backend would also get us non-asm.js JS via [JSIL](http://www.jsil.org/ http://www.jsil.org/) which would give Rust access to the DOM. This is quite a flight of fancy though).
- yazaddaruvala 11y agoI think more than a C backend, LLVM needs "C as an IR". Which LLVM can internally use to "trivially" add support for embedded-type platforms that only have a C compiler. That is what most people want it for anyways.
- mackwic 11y agoBackend is the correct term: C is by no mean an IR which means "intermediate representation", from which you can more or less easily understand the thing behind the code (eg: types, control flow, variable bindings). An IR is a data-structure that obey some rules, a C file is flat text that needs parsing. Not the same. If C is the output of the compiler, then we speak of a C Backend, which means the part that transform the final IR in the other language we want to translate to (eg: x86, arm6, sparc, ... C :) As a final note, it's likely that platforms so conservatives that they only provide a C ansi compiler, will not be aroused by Rust.