5 ms·
Quickly scanning Nim page, there is a couple of things that bothers me in Nim. The python style blocks making multi line lambda awkward, Garbage collection, "Id
by skywal_l 5y ago
Quickly scanning Nim page, there is a couple of things that bothers me in Nim. The python style blocks making multi line lambda awkward, Garbage collection, "Identifier equality" (some_variable == someVariable)...
So because of the quirkiness I would understand why it is not a universally adopted language.
Do you have pointers to the comparison with other languages?
- elcritch 5y agoI think the biggest issue is that Nim took a long time to “find its feet”. There was a lot of experimentation before the current sweet spot. Due to its new GC system ‘ARC’ it’s now broadly useable as a systems language, which wasn’t true before with a regular GC. ARC is non-atomic/non-locking reference count based, meaning it can be used to as a systems language (no GC pauses) or for system libraries (C programs can use it). There’s a few awkward-ish parts of the syntax, but in practice those items aren’t big issues (compared to say Rust async syntax issue). For example multi-line lambdas can be done with ‘do’ blocks or just wrapping parens. Identifier equality has actually saved me from a few bugs by accidentally creating a new similarly named variable, say an ‘isDone’ when I already had an ‘is_done’ following the style from C FFI. Though the compiler warns by default when mix naming styles, and can be set as an error if desired. Iterators usage can be a bit annoying though. I also really enjoy UFCS: https://en.m.wikipedia.org/wiki/Uniform_Function_Call_Syntax https://en.m.wikipedia.org/wiki/Uniform_Function_Call_Syntax Python comparison example: https://narimiran.github.io//2018/05/10/python-numpy-nim.html https://narimiran.github.io//2018/05/10/python-numpy-nim.htm...
- coliveira 5y agoARC is not new, it was used by Apple in their languages for at least 10 years now.
- ______-_-______ 5y agoObviously parent is not claiming that Nim invented the concept of reference counting. They're saying that it's a recent addition to Nim, and Nim's other memory management strategies have been part of the compiler for longer.
- elcritch 5y agoThat and that Nim's ARC system extends the concept a bit further to include move semantics and limited ownership rules. Nim had a traditional RC garbage collector before, but ARC is case where "the whole is greater than the sum of parts". Swift and Obj-C's ARC system relies on atomics and their associated issues (explained well here: https://news.ycombinator.com/item?id=15046481 https://news.ycombinator.com/item?id=15046481). Nim's ARC system relies on ownership rules that require a single thread to "own" any ARC-managed memory which removes the need for locks or atomics in the reference counts. That eliminates the non-determinism of locks & atomics when doing the RC accounting, overall improving latency and performance. Move semantics increase performance and enables "giving" ownership of ARC-managed memory to another thread.
- dom96 5y agoWhat's so awkward about multi line lambdas? You can achieve them in the same way you can in JavaScript, can't get easier than that. import sequtils let x = [1,2,3,4,5] echo x.map( proc (num: int): int = num*2 )
- throwaway234272 5y agoThe lambdas are terrible in nim, you currently have to `import sugar` for bandaid fix. Nim is in progress to fix them, see here: https://github.com/nim-lang/Nim/pull/11992 https://github.com/nim-lang/Nim/pull/11992 I don't see why people can't admit to shortcomings in languages? I like Nim a lot, doesn't mean I'm blind to where it falls short or needs improvement...
- poulpy123 5y agoI just started to (very slowly) learn Nim, and it's quite nice for the moment. Of course there are some points of friction, but which language doesn't have ? The documentation page has comparison with C, python and typescript/JavaScript https://nim-lang.org/documentation.html https://nim-lang.org/documentation.html
- MercurialBlue 5y ago>Identifier equality This is a very surface-level complaint, and it is no surprise that almost everyone who complains about this hasn't actually used the language. I will admit it is indeed a peculiar feature, I wouldn't be able to name another language that did this before, but as it turns out, it has yet to be a problem in practice. Do you fear some crazy person might mix identifier styles? They could do that in any language, Nim has nothing to do with that. The pro of this feature is that you can write your library in whichever style you prefer, and people can use your library and still use their preferred style, I always hated how in python you often end up having to use libraries written in camelCase for your snake_case project (or vice versa). Once again, it is a rather peculiar feature, like who asked for this? I don't know, but then again, why not? it did make me raise an eyebrow at first, but in practice, Nim gets it just right. The one valid scenario where it could get in the way is when searching your source files for an identifier, but even then Nim has solutions for that (there's nimgrep, and mainstream editors/IDEs are already nim-aware anyways).
- deleted 5y ago[deleted]
- MercurialBlue 5y agoMay I ask what exactly do you dislikes about Nim's garbage collection? You said you "quickly" scanned Nim's page, so I assume you just don't want a GC period? If you're dealing with hard-realtime constraints then I understand. But otherwise, as long as you aren't dealing with cyclic data structures, Nim's GC is just reference counting, which is very widespread in even C++ and Rust code, and if you really want to you can just not use the cycle collector and break the cycles yourself. The way I see it, the GC is just nice to have for productivity, and for those cases where you really need to optimize your program, there is nothing stopping you from managing your memory yourself, you can write your own types with their own constructors/destructors (Nim has "scope-based" memory management akin to RAII in C++), of course, you must be aware that using pointers will lead to potentially unsafe code, Nim can't hold your hand there.