6 ms·
I don’t know much about Nim, does it have a mandatory gc, like go? How good is Nim’s gc? Those who have written some Go and Nim, home does the code look like v
by mrath 5y ago
I don’t know much about Nim, does it have a mandatory gc, like go? How good is Nim’s gc?
Those who have written some Go and Nim, home does the code look like vs go?
- BiteCode_dev 5y agoAs a python dev, nim was much easier to get into than Go, Rust, or even Zig. If you squint, it looks like a toddler Python with strong typing, compilation and a few different API, espacially for managing finalisation.
- ijlx 5y agoI may be splitting hairs here but Python is actually a strongly typed language. It would be better to say nim has static typing: https://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic%20language%20and%20also%20a%20strongly%20typed%20language https://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic...
- sp33der89 5y agoNim is the most readable language I've ever seen. I've dabbled with Go, but Nim is almost like pseudocodes+types. Highly recommend you take a look and try it out! You can use libraries like https://github.com/planety/prologue https://github.com/planety/prologue or https://github.com/treeform/pixie https://github.com/treeform/pixie to create something quickly and fun(compile times are faaasst!). And Nim does not have a mandatory GC, you can go as low-level as you want, but in case you don't want that you can choose from several great GC's(a capable soft real-time GC and Boehm for example). Or you could combine the best of both worlds and take a look at the shiny fancy ARC/ORC deterministic memory management: https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
- mrath 5y agoLooks like you know a bit of Nim. Apart from ecosystem and IDE what are the some of the disadvantages of Nim compared to Go?
- auxym 5y agoI have not done a lot of Go, but I'm pretty sure Nim's concurrency story isn't up there with go, at least not yet. Nim has other advantages, including great Interop with C or C++ as it compiles to these languages and allows low level, unsafe features like raw pointers when needed.
- sp33der89 5y ago* Goroutines are probably a lot more easier to use. Work is being done to make Nim even better in that area: https://github.com/nim-works/cps https://github.com/nim-works/cps but don't expect it soonish. * I feel like Go has less 'edge cases', but the Nim compiler is steadily getting more stable, especially consider it's not backed up by a major company! * Metaprogramming is really powerful, but not beginner friendly. The documentation says use macros when necessary, but personally I don't think that really happens in practice. The advantages by far outweigh the disadvantages, especially if you are looking for a clean Go alternative(except maaaaaaybeee web application). EDIT: my own wishlist, but they aren't relevant compared to Go: * Better sum types * Builtin pattern matching
- zoidb 5y agoI have written a bit of both, recently re-wrote a command runner for a side-project https://gitlab.com/jarv/cmdchallenge https://gitlab.com/jarv/cmdchallenge in Nim and found it very pleasant and much less verbose, which was a nice change from GoLang while keeping type safety. A good example is parsing JSON https://nim-by-example.github.io/json/ https://nim-by-example.github.io/json/ as you can do a lot with fewer lines of code. I think the main disadvantage of Nim is that there is less out there in the ecosystem, libraries, and it's more likely you will run into quirks and bugs in the standard library.
- andybak 5y agoI really like the look of Nim but every time I dig into it I find a really strange syntax decision. For example: > The json module provides the %* operator which is used to create JSON objects I'm curious what the benefits are here of an operator over some more readable syntax. I have a dislike of languages where ascii noise seems to be favoured over readable english tokens.
- zoidb 5y agoYeah, I tend to agree with you here especially after a take a break from writing Nim I need to re-learn a lot because it is impossible to hold it in my head for very long.
- k__ 5y agoThis is interesting, especially for a language like Nim that favours familiarity with Python. Even Rust dropped most of its strange operators/sigils early on in the experimentation phase, because they confused people and Rust doesn't step back from confusing people lightly, haha.
- elcritch 5y agoProbably because Rust already has too many ascii symbols! ;) I still get brain mush remapping Rust's & from C's &. But yah Nim's % is a bit strange at first, but becomes fairly handy in practice when dealing with lots a small bits of JSON. There's the % "to json" operator that mimics the $ "to string" operator for a single value. Then %* was added to handle multiple json items (I read it like apply % to all items). So it has a decent symmetry. Other than % and $ ascii operators are pretty rare in Nim code. Even bitops use or, and, shl, shr, etc over ascii operators.
- sdmac99 5y agoCheck out this Nim talk. Addresses some of your questions. https://www.youtube.com/watch?v=d2VRuZo2pdA https://www.youtube.com/watch?v=d2VRuZo2pdA
- mrath 5y agoThanks I’ll check it out.
- DeathArrow 5y agoNim has multiple memory management strategies and you can pick any. A few types of garbage collectors, reference counting and manual memory management.[1] Nim is less verbose than Go and more expressive. [1] https://nim-lang.org/docs/gc.html https://nim-lang.org/docs/gc.html
- mst 5y agoNim can be mark/sweep collected but also has a collector called ORC that's reference counting plus a version of the Recyler algorithm for cycle collection. ORC turns out to be rather nice to use: https://nim-lang.org/blog/2020/12/08/introducing-orc.html https://nim-lang.org/blog/2020/12/08/introducing-orc.html