News for hackers. Stuff that matters.
Re:Maintain It with Zig by sandwichbop on Wednesday September 08, 2021 @12:09PM (#28459129)
Interesting read and I agree that growth in technical debt is something to worry about. I want to get more involved and been trying my best to learn the skills needed but there’s so much to consider that it’s a bit overwhelming. I’m not familiar with Zig, it’s neat that it has a toolchain that can compile C/C++ but it reminds me a lot of Nim. Could someone explain to me some differences between the two and why you would pick Zig over the other besides personal preference?
Re:Maintain It with Zig by cassepipe on Wednesday September 08, 2021 @12:37PM (#28459536)
I'd say Zig wants is really serious on wanting to be a better C, that is have the same (better?) access to bare-metal, memory and bits but with a better type system and error management and without C's footguns and cruft (build system, memory errors, preprocessor). I don't know Nim that well but it seems more ambitious and seems to cater to be more "general purpose" if that means anything. For example there's no hidden flow control in Zig.
Re:Maintain It with Zig by habibur on Wednesday September 08, 2021 @12:57PM (#28459828)
Nim is garbage collected, thus is a higher level language but doesn't fit the high performance low overhead of "systems programming" requirement.

While Zig is manual memory managed like C and nearer to the core, but harder to program.

Re:Maintain It with Zig by michaelsbradley on Wednesday September 08, 2021 @02:44PM (#28461386)
I think the maintainers of Nim would disagree with your assessment given that the first sentence on the front page of Nim's official website is:

"Nim is a statically typed compiled systems programming language."

As someone else pointed out, when using Nim with its ARC/ORC and move semantics (which will eventually be the default), it's closer to Rust than to Go.

That being said, Nim's current default GC does well for many kinds of workloads. If it's really causing a performance problem, it's possible to disable it and manage memory manually (or use a different language for the task at hand, of course).

Re:Maintain It with Zig by sa1 on Wednesday September 08, 2021 @01:31PM (#28460354)
With ARC, Nim's memory management would be closer to Rust than to Go.
Re:Maintain It with Zig by vips7L on Wednesday September 08, 2021 @07:14PM (#28464226)
Automatic Reference Counting? I’m not sure. Swift spends a lot of its execution time doing reference counting.
Re:Maintain It with Zig by sa1 on Wednesday September 08, 2021 @11:00PM (#28465731)
Nim does it compile-time to insert destructors in the correct places. (except for cycle collection, which needs a runtime GC)
Re:Maintain It with Zig by vips7L on Thursday September 09, 2021 @08:53AM (#28469124)
Are there benchmarks?
Re:Maintain It with Zig by goodpoint on Wednesday September 08, 2021 @02:46PM (#28461413)
Not at all: Nim always targeted system programming. Even before the new ARC/ORC, the GC was optional and done independently in each thread.
Re:Maintain It with Zig by nimmer on Wednesday September 08, 2021 @02:49PM (#28461439)
Nim targets all the architectures that GCC targets, including less common microcontrollers.