4 ms·
Nim is probably the most easiest language I've picked up. It's a delight to program in Nim and the performance is stellar (beats hand coded C in many cases). It
by rwbt 9y ago
Nim is probably the most easiest language I've picked up. It's a delight to program in Nim and the performance is stellar (beats hand coded C in many cases). It's a rare feat really.
- swah 9y agoBe very careful about stating that GC'ed languages beat C - jblow might appear suddenly to correct you... with pure common sense.
- rwbt 9y agoComing from C++ (with C experience too), I too was hesitant about Nim because of GC. But I can turn it off completely or even better "--gc=stack" which makes it behave like C++ (dealloc when going out of scope). The compiler is also good at telling you what calls use GC'ed memory, so you can work around them if necessary. But even with GC on, Nim is super fast. I use it in real time rendering and I honestly didn't see any significant performance loss. In fact, it made some routines much faster because the Nim compiler produced much better C code than I ever did.
- pjmlp 9y ago> But even with GC on, Nim is super fast.... This is what I experienced with GC enabled systems programming languages (Oberon family of languages) back in the late 90's, just with C++ as comparison on my case. The main problem is the culture of micro-optimizing code without profiling it, that is so prevalent in those communities.
- captainmuon 9y agoCommon sense says that non-GC languages should beat GC languages, but there are actually cases where GCs can be faster. In particular, allocating memory can be just incrementing a pointer with a GC, whereas malloc does some more bookkeeping. You pay the price later during garbage collection, but if you are lucky your process is idle at that time, or even better, it is finished, and you get cleanup for free. See also https://stackoverflow.com/a/6977194/143091 https://stackoverflow.com/a/6977194/143091 What's faster will vary a lot from case to case. (Of course, deep down the stack is always a non-GCed language, or at least assembly, so if your GC language wins a benchmark, you can always write that same program + the GC runtime in a non-GC language... but that is a trivial observation. Nim compiles to C, so is it GC'ed or not?)