Live data from Hacker News

Nim 2.0

nim-lang.org

41–50 of 213 posts

Re: Nim 2.0

#41

Earlier quoted context omitted.

And I'm surprised by how terribly it ranks – basically dead last against everything, even the Python frameworks, which is impressive.

Possibly it wasn't compiled with `-d:release`. I only looked briefly — is there a way to see the source code and cli flags used for the various implementations?

https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...

That appears to be the docker file they used, it's compiled with -d:release.

Re: Nim 2.0

#42
post #8

Earlier quoted context omitted.

> “It prefers the stack so strongly that dynamic data structures (sequences and tables, basically its lists and dictionaries) are pointers on the stack to heap data, where the lifetime is managed by the stack frame.” Isn’t that the same as a C++ vector or map on stack? They allocate internally as needed, and the whole container is destroyed when it goes out of scope.

Basically, but it requires no extra syntax. `var some_seq = @[1, 2, 3, 4]` is a stack-managed sequence. That's all there is to it. There's no unwrapping any pointers or boxes or what-not, the type is just `seq[int]`. Put another way, things that have become best practice in C++ are default in Nim with no syntactic noise.

There's no unwrapping any pointers or boxes or what-not

That doesn't happen by default in C++ either.

std::vector some_seq{1, 2, 3, 4, 5, 7};

Re: Nim 2.0

#43
Nim has been my favorite language for a while now, and I'm very excited to see version 2.0 finally released. A lot of these features have been items I've been looking forward to for some time.

The only downside is some of the included modules being moved to 3rd party repositories, as mentioned at the very bottom. It's not a big deal, but it was nice having SQLite support built into the library. I suppose once you support some databases, you'll be pressured to support more and more. I am a bit surprised to see MD5 and SHA1 support moved out though.

Re: Nim 2.0

#44

If your Python programs heavily use Pandas and Numpy, could there still be speed benefits to translating them to Nim?

That might depend on how many raw Python loops and functions you use. Even if most of your code uses pandas and numpy, things like string processing could still benefit from a compiled language.

Re: Nim 2.0

#45
post #38

Earlier quoted context omitted.

Dynamic data structures by their nature have to be allocated to the heap. What I mean by "prefers the stack" is that you don't have to make a managed ref and dereference a managed pointer type. You just make a `seq[int]`, use it as a `seq[int]`, and pass it as a `seq[int]`, just like stack data. Behind the scenes, it has a unique scoped pointer with no mental overhead.

Sounds like a vector/array/list in any other language after C++, like Go slice, Java ArrayList, Javascript array, Python list, Rust vec. Is there something I'm missing?

I think they're discussing the lifetime of that heap data, not whether the data is heap allocated.

Re: Nim 2.0

#46

Earlier quoted context omitted.

Basically, but it requires no extra syntax. `var some_seq = @[1, 2, 3, 4]` is a stack-managed sequence. That's all there is to it. There's no unwrapping any pointers or boxes or what-not, the type is just `seq[int]`. Put another way, things that have become best practice in C++ are default in Nim with no syntactic noise.

There's no unwrapping any pointers or boxes or what-not That doesn't happen by default in C++ either. std::vector some_seq{1, 2, 3, 4, 5, 7};

or even just

     std::vector some_seq{1, 2, 3, 4, 5, 7}; 
nowadays (for a value of nowadays that is 5 years old for GCC and 6 years old for Clang)

Re: Nim 2.0

#47
post #31
post #4

Anyone have working experience with Nim and Zig? I'd love to hear how they are similar and contrast. I'd also would like to see some idiomatic web server benchmarks between the two (now with Nim v2).

I've used both to work on a hobby OS project (Nim[1], Zig[2]). I very much prefer Nim. Code is succinct, elegant, and lets you focus on your core logic rather than fighting the language. Zig is nice and I like its optionals support and error handling approach. But I was put off by its noisy syntax, e.g. !? [ ]u8 to represent an error union of an optional pointer to a many-pointer of uint8. Also having to prepare and…

> Zig also doesn't have dynamic dispatch

It doesn't have it as a language feature, but it does have VTables just like C would. The `std.mem.Allocator` is an example of this.

Re: Nim 2.0

#48

Earlier quoted context omitted.

Zig doesn’t seem to have an implementation for the TechEmpower Benchmarks but Nim does: https://www.techempower.com/benchmarks/#section=data-r21&l=y...

And I'm surprised by how terribly it ranks – basically dead last against everything, even the Python frameworks, which is impressive.

Nim's default json library is terrible in performance, but there're much faster drop-in replacements like jsony[1]. I'm not sure that's the main issue for low rank, but it's definitely one of them.

1. https://github.com/treeform/jsony

Re: Nim 2.0

#49

Nim looks awesome. Does anyone know why it doesn't have first-class support for wasm? That's the only thing that would keep me from diving into it more.

I suspect it's simply a size-of-community thing. If you want it, you should take a crack at implementing it! Or least start a thread about on the official developer forum.

Re: Nim 2.0

#50
post #3

Congrats to all involved. I find Nim to be an absolutely fascinating language. I've been trying to find a reason to use it on my job (my work is mobile-adjacent so the idea of compiling to JS and to ObjC is fascinating) but haven't gone beyond playing around with it so far. I've been comparing it to Rust and it's just so much simpler to get started with.

Somewhat related, you can call Nim code from Node.js/Bun using Denim: https://github.com/openpeeps/denim. It works by creating a Node add-on.

This is great for reusing Nim code in a web app, and possibly for performance critical code.

Post reply on HN