Hacker News new | ask | show | jobs
by dom96 2958 days ago
Nim is small enough to be used for this purpose. You can easily use it as a nice layer on top of C.

Why do you consider it too big?

1 comments

I haven't looked at Nim in detail, but since Nim does garbage collection, it didn't read to me like a thin layer over C. For instance, is it possible to instantiate a struct on the stack? I'd also have liked the compiled C code to be readable, which if I'm not mistaken, Nim doesn't do.
> For instance, is it possible to instantiate a struct on the stack?

Yeah, it is. You can easily avoid the GC as long as you don't mind managing memory yourself (unfortunately this means that you cannot use the stdlib either, or at least parts of it, if you disable the GC with the `--gc:none` flag you'll get warning messages from the compiler about procs that need the GC which is nice).

> I'd also have liked the compiled C code to be readable, which if I'm not mistaken, Nim doesn't do.

Yeah, that's one thing that Nim definitely doesn't do. I don't think there are many languages that do. It would be an interesting experiment to see how pretty you could make the generated C by either fixing things in the compiler or just running a C formatter on it.

> unfortunately this means that you cannot use the stdlib either

This is the kind of friction I expect from a language which uses GC, for my usecase. I think it might make sense for Nim to support a GC-less stdlib for people who do not want GC in their code.

This is giving me D flashbacks.