Rust is an awesome language. It has the power to replace C++ and Java as industry standard.
However, there are three points which annoy me. First, the Rust compiler is huge (LLVM based). Second, it requires a native Rust compiler for bootstrap. Third, it doesn't compile to C which makes porting to other platforms difficult. Nim doesn't have these problems. It is small, self-hosting, and easily portable.
> Third, it doesn't compile to C which makes porting to other platforms difficult.
Not compiling to C is a feature. It insulates us from the undefined behavior of C (signed overflow never results in UB in Rust, for example) and allows us to actually get proper debug info.
Compiling to C vs using LLVM is a complex design tradeoff. For example, the Posix standard specifies a C interface. Quote: "The stat structure shall contain at least the following members..." This means you can wrap 'struct stat' in Nim once and be done with it (since the mapping to C is by generating C code) whereas for eg Rust you need to wrap it once for every different OS (and potentially even for every OS version+CPU combination), since the offsets and sizes can differ. So yes, porting to other platforms really is easier when you have a C code generator.
There are other ways to address this issue. You can do what Swift does and call into libclang so that you can pull out the structure definitions, for instance.
Furthermore, if your frontend doesn't know about structure layout then you forgo some important systems language features. For example, you can't implement sizeof as a compile time constant.
> There are other ways to address this issue. You can do what Swift does and call into libclang so that you can pull out the structure definitions, for instance.
Sure and you only need to call libclang for each different platform. Or is it on every platform? ;-)
It would be physically impossible for a call to that function to work with a single definition of the struct stat, because the set of fields (and their ordering) and struct size differ between platforms. So that libc wrapper must provide separate definitions of the struct for each platform.
Ah, sorry! I was thinking about things like "the size of this type is different per-platform," not "every single platform has a different definition of this struct."
I still think that, given Cargo, the one-time cost makes it worth it, but after seeing my error, think that the point makes more sense. Thank you for being patient. :)
That's true, but Rust and its compiler components are fairly well ported, LLVM's going to be near the top of the porting list for any new architecture, and processors are almost a monoculture at this point.
However, there are three points which annoy me. First, the Rust compiler is huge (LLVM based). Second, it requires a native Rust compiler for bootstrap. Third, it doesn't compile to C which makes porting to other platforms difficult. Nim doesn't have these problems. It is small, self-hosting, and easily portable.