News for hackers. Stuff that matters.
Re:Mastering Nim – now available on Amazon by 127 on Thursday June 30, 2022 @01:11AM (#31928902)
My experience after a couple of weeks:

Pros: Extremely good C and C++ interop Significant indentation Very good performance Quick compilation Terse, but readable Easy cross platform Powerful macros and close to trivial DSL construction Very little code to do a lot of stuff Incoming future features look very promising

Cons: Hard to predict and control program performance, LTO does a lot of heavy lifting Immature ecosystem, because only few users. Many libraries have bugs, missing features or just a very clunky API. Or maybe they are deprecated or abandoned all together. Many different ways to do the same thing everyThingIsCamelCase, ambiguous variable names (subjective) Documentation and tutorials is mostly reading through the code and googling forum posts outside the core language You compile either for C or C++, some libraries simply won't work without C++ compilation

Re:Mastering Nim – now available on Amazon by jasfi on Thursday June 30, 2022 @01:33AM (#31928986)
Nim has several GCs available. For predictable performance you may want to use ARC. See: https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...

For my contribution to the ecosystem see Nexus mentioned in another comment. If you see bugs please report them. Sometimes libraries are deprecated/abandoned because of new ideas, this happens in every ecosystem.

I personally use camelCase/PascalCase, but Nim is style insensitive, meaning you can call procs written in camelCase using snake case. However this is controversial and under discussion, my personal opinion is to make style sensitivity optional, with insensitivity the default.

Ambiguous variable names I hate, you won't see that in Nexus, if anyone does they should file an issue. That's really developer dependent.

For my part Nexus has some docs and a basic tutorial. But if people want more they need to ask for it. Why write docs nobody wants or will read? Anyway, this book (Mastering Nim) is one more definite step forward for learning Nim.

I think compiling to C is what mostly happens, C++ is probably an outlier. Even then, a C++ compiler isn't difficult to install if needed.

Re:Mastering Nim – now available on Amazon by planetis on Thursday June 30, 2022 @06:46AM (#31930776)
> Many libraries have bugs, missing features or just a very clunky API. Or maybe they are deprecated or abandoned all together.

For me missing libraries never stopped me, I could always port/wrap whatever I needed. However with the advent of AI assisted coding, working on libraries is even faster and at some point I hope I wouldn't spend much time rolling decent libraries that are ports of existing github projects.

Re:Mastering Nim – now available on Amazon by greybox on Thursday June 30, 2022 @06:02AM (#31930510)
I love nim, but I disagree with the "quick compilation" point here. The compilation is horrendously slow. (by default it compiles down to C, then to exe from there).
Re:Mastering Nim – now available on Amazon by cb321 on Thursday June 30, 2022 @08:16AM (#31931429)
As with most things, "it depends". If you compile very macro compile-time virtual-machine heavy code that can be slow. If you compile to the c++ backend then that backend process can be slow. If you invoke some macro that generates mountains of Nim code translated to continents of C code it can be slow. If you use the default `nim.cfg` that has gcc -Og it can take a lot longer than gcc -O0, for example. Meanwhile, if you use the `tcc` backend even without incremental compilation it can be close to immediate feedback:

    $ touch foo.nim
    $ /usr/bin/time nim c foo.nim
    CC: ../usr/lib/nim/lib/std/private/digitsutils.nim
    CC: ../usr/lib/nim/lib/system/dollars.nim
    CC: ../usr/lib/nim/lib/system.nim
    CC: foo.nim
    Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
    36891 lines; 0.154s; 39.434MiB peakmem; proj: /tmp/foo.nim; out: /tmp/foo [SuccessX]
    0.24user 0.02system 0:00.27elapsed 101%CPU (0avgtext+0avgdata 44360maxresident)k
    0inputs+0outputs (0major+13676minor)pagefaults 0swaps
(I point my default backend compiler to tcc in my $HOME/.config/nim/nim.cfg.) There are some more details in this nim forum thread: https://forum.nim-lang.org/t/8677

Unless your standards are "single digit milliseconds per file like tcc itself, please!", 240 ms is not so bad. (EDIT: And this is just on some 2016-era Intel i7-6700k box, not some liquid helium cooled 10 GHz whatever.)

Re:Mastering Nim – now available on Amazon by nimmer on Thursday June 30, 2022 @06:35AM (#31930705)
It's much faster than C++, Rust, Go and many others.
Re:Mastering Nim – now available on Amazon by zimpenfish on Thursday June 30, 2022 @07:00AM (#31930875)
I'm assuming this must be for huge projects?

I just compiled my toy project (detecting anomalous parity in integers) in nim 1.6.6 (4.23s), go 1.17.7 (2.43s to create both aarch64 and x86_64 binaries), zig 0.8.0-dev.1140 (2.04s to create aarch64 and x86_64 binaries) and C via clang 13.1.6 (0.14s).

nim's compilation is 175% of Go, 207% of zig, and 3021% of clang.

Re:Mastering Nim – now available on Amazon by machinekob on Thursday June 30, 2022 @03:33PM (#31937428)
how are u compiling (optimization, custom compilation flags etc.?) In my case https://github.com/mratsim/Arraymancer big project compile under your 4.2s so or you have like 10k+ lines of codes with macros or you just pass some debug flags to compiler :D
Re:Mastering Nim – now available on Amazon by zimpenfish on Friday July 01, 2022 @04:53PM (#31952732)
Compilation command is:

    nim c -d:release --passC:"-flto" --gc:markAndSweep --out:ap ap.nim
I will add that once it's been run a few times, it does go a bit quicker (down to ~0.7s) but the Go also gets quicker (down to 0.28s for two outputs when files are cached.)
Re:Mastering Nim – now available on Amazon by nimmer on Thursday June 30, 2022 @07:17AM (#31931007)
No, even small files. You must have issues with your setup. Are you sure your compiler is not built in debug mode?
Re:Mastering Nim – now available on Amazon by zimpenfish on Thursday June 30, 2022 @07:46AM (#31931196)
How would I check that? I installed it through homebrew via https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/... which doesn't seem to mention debug mode anywhere?
Re:Mastering Nim – now available on Amazon by dom96 on Thursday June 30, 2022 @12:40PM (#31935098)
Run `nim -v`, if it's not in debug mode you should see "active boot switches: -d:release".
Re:Mastering Nim – now available on Amazon by zimpenfish on Thursday June 30, 2022 @02:07PM (#31936221)
Looks like it isn't in debug mode after all.

    $ nim -v
    Nim Compiler Version 1.6.6 [MacOSX: arm64]
    Compiled at 2022-05-05
    Copyright (c) 2006-2021 by Andreas Rumpf
    
    active boot switches: -d:release -d:nimUseLinenoise
Re:Mastering Nim – now available on Amazon by Rochus on Thursday June 30, 2022 @07:06AM (#31930930)
Thanks for the data; that's what I call an elegant rebuttal.
Re:Mastering Nim – now available on Amazon by hahaitsfunny on Saturday July 02, 2022 @10:42AM (#31959389)
No, it is not - Nim's compiler backend is extremely complex and full of cruft. I've been around Nim for 7+ years now and there's a reason the compiler was hard forked.

Nim's compiler is definitely not speedy, and this is why so much effort has been spent on incremental compilation, which tmk, still isn't working - https://github.com/nim-lang/Nim/issues/19757.

Re:Mastering Nim – now available on Amazon by boongeheYOE on Thursday June 30, 2022 @06:18AM (#31930595)
In comparison to languages like Rust and C++ it compiles pretty fast. Or maybe you built the compiler in debug mode.