Hacker News new | ask | show | jobs
by klibertp 2942 days ago
> It has (almost?)

No, it has all the features mentioned in GP. It's worth noting, though, that Nim is a higher-level language than Zig appears to be. Nim is garbage-collected, has an object system with multi-methods, has proper lambdas and higher-order functions, uses a kind of uniform access principle (`foo.func()` is the same as `func(foo)`, basically), has destructors and defer blocks, exceptions, iterators, generics, operator overloading, AST based (but procedural) macros and templates, a kind of type-classes (called concepts), built-in concurrency (thread pool) support, and more.

I'm not sure how well it would work on microcontroller, for example, although its garbage-collector is tunable in terms of memory and times constraints. But for anything higher-level than that, Nim is a really nice language, which reads very similar to Python but is natively compiled and much faster (among other features). A quick example to back up the similarity claim:

    proc getMem() : tuple[total: int, free: int] =
      let
        (output, _) = execCmdEx("free")
        fields = output
          .split("\n")[1]
          .split()
          .filterIt(it != "")
      return (fields[1].parseInt(), fields[^1].parseInt())
Really worth taking a look at, if you want conciseness and performance without compromising readability.
1 comments

It works on microcontrollers just fine using the new GC or by disabling it.