News for hackers. Stuff that matters.
Re:Nim Programming Language v0.15.0 released by qwertyuiop924 on Saturday October 01, 2016 @08:00AM (#12617508)
True enough about Haskell. As for Rust, as awkward as it can be at times, it feels more pleasant than Nim to me much of the time.
Re:Nim Programming Language v0.15.0 released by progman on Saturday October 01, 2016 @08:28AM (#12617582)
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.

Re:Nim Programming Language v0.15.0 released by pcwalton on Saturday October 01, 2016 @12:54PM (#12618697)
> 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.

Re:Nim Programming Language v0.15.0 released by Araq on Saturday October 01, 2016 @03:27PM (#12619477)
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.
Re:Nim Programming Language v0.15.0 released by pcwalton on Sunday October 02, 2016 @12:31PM (#12623075)
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.

Re:Nim Programming Language v0.15.0 released by Araq on Tuesday October 04, 2016 @02:55AM (#12633746)
> 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? ;-)

Re:Nim Programming Language v0.15.0 released by steveklabnik on Saturday October 01, 2016 @05:21PM (#12619939)
Wouldn't you just use libc directly from Rust if you wanted that?

(I agree that it's a tradeoff generally, I'm just not sure this example is particularly motivating.)

Re:Nim Programming Language v0.15.0 released by SamReidHughes on Saturday October 01, 2016 @09:52PM (#12620744)
> Wouldn't you just use libc directly from Rust if you wanted that?

No, because the interface is

    int stat(const char *path, struct stat *buf);
Re:Nim Programming Language v0.15.0 released by steveklabnik on Saturday October 01, 2016 @10:37PM (#12620822)
Re:Nim Programming Language v0.15.0 released by SamReidHughes on Saturday October 01, 2016 @11:00PM (#12620870)
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.
Re:Nim Programming Language v0.15.0 released by steveklabnik on Sunday October 02, 2016 @08:46PM (#12625010)
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. :)

Re:Nim Programming Language v0.15.0 released by qwertyuiop924 on Saturday October 01, 2016 @08:50AM (#12617636)
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.