The project for which I'm evaluating Nim does a lot of concurrent network I/O (over WebSockets) and database access. It needs to run on most mainstream platforms (iOS, Android, Mac, Windows, Linux.) The current implementation is in C++17, using a homemade Actor library. The other language I'm seriously considering is Rust.
Nim seems to have the necessary pieces, like the `async` macro and the `asyncnet` module. But are they mature enough to use in production code? I have a few specific questions: 1. The asyncnet module documentation has a couple of caveats about Windows, like "on Windows it only supports select()" and "In theory you should be able to work with any of these layers interchangeably (as long as you only care about non-Windows platforms)." I'm not clear on how this would impact clients, and whether these caveats apply to using asyncnet or just the lower-level modules. 2. The async examples I've seen run on a single thread. Is there any support for distributing async calls across a thread pool? 3. The `spawn` function's thread safety seems to be based on segregating heap objects per thread (Erlang-style.) This can involve a lot of copying, especially when passing data buffers around. Is this something baked into the language or is it specific to the `spawn` function? Are there alternatives to this, like the more Rust-style model using move semantics? We found [an interesting quote on r/nim](https://www.reddit.com/r/nim/comments/giaeev/what_are_the_biggest_weaknesses_of_nim_in_your/fqdlmhf/) from a few days ago: > What ... caused my last team to abandon Nim in favor of Haskell ... was the > weak concurrency story. There is _a_ story there (thread-local heaps) but we > found it far too easy to get yourself into very confusing situations where > behavior wasn't as expected (especially since you can pass around pointers > which breaks the thread safety checker). To be fair, our C++ code has almost no built-in thread safety at all; you have to be careful what types you pass to Actor methods. But that's one of the things I'd like to improve on! I've written some prototype code in both languages (C API bindings, not any async or net code yet) and I have to say I really enjoyed Nim a lot. Rust I found frustrating, and ugly due to lack of function overloading and the need to convert between equivalent types like str/String. Nim also builds faster, and seems to generate much smaller code. But Rust does have huge momentum behind it so it feels safer for that reason, and the ironclad memory safety is a good thing to have. Any comments or perspective from those who've been using Nim a lot? \--Jens| ---|---
