5 ms·
I read the article. Still no idea what Nim is good for and why it's better than some other language.. and for which use cases?
by ducklingslicks 8y ago
I read the article. Still no idea what Nim is good for and why it's better than some other language.. and for which use cases?
- dom96 8y agoThis might sound strange but Nim is good for everything. From writing backend services to creating web apps running on the client side. I've built emulators, CLI apps, a full blown forum and much more in it. It's particularly great for systems programming tasks that require high performance and zero dependencies. For example, Status is currently writing an Ethereum 2.0 sharding client for resource-restricted devices[1] in Nim. Nim is also awesome if you've got an existing C or C++ codebase, the interop that Nim offers is one of the best (if not /the/ best), especially when it comes to C++ interop. As far as I'm concerned no other language can interoperate with C++ libraries as well as Nim can. 1 - https://github.com/status-im/nimbus https://github.com/status-im/nimbus
- iTokio 8y agoWhat are Nim’s main weaknesses?
- dom96 8y agoThese affect people in different ways but off the top of my head: - No Nim v1.0 yet, despite this we do our best to create a deprecation path for everything that's possible. - No big company like Google/Apple supporting the language. - Community is smaller than that of Go/Rust.
- nicoburns 8y agoA biggy is that it only really has a single developer, and no big corporate users. And relatedly the library ecosystem is relatively weak. It also has a GC, so it can't be used for really low-level stuff where that is a problem. It's looking pretty promising though. Especially if you are a fan of python's syntax.
- andrewchambers 8y agoThat is not totally true. Nim's own GC is written in Nim. You can turn the GC off.
- mratsim 8y agoI use Nim for Cuda, OpenCL and cache-sensitive/memory-bound multithreaded computation. You can mix and match manual memory management and GC-managed types in the same codebase.
- interfixus 8y agoTwo developers at least. One of whom is in this very thread. It's a concern, yes, but actually has been around for more than a decade, and is showing absolutely no sign of slowing down or going into hibernation. I have just seen a ... competing language team spending developer time on purging the code of what they call ableism. apparently it's now offensive to talk of a sanity check ot to facetiously refer to OCD in a comment. At least we may hope the Nim team lacks manpower for such idiocy.
- tzs 8y agoWhich competing language team? All I found on Google was this gist of someone saying "sanity check" should be avoided. ("health check, too) [1], and some issues and pull requests in projects that were not languages. One of the latter is clearly trolling to test Linus Torvalds' resolve to be polite [2][3][4][5], complaining about "ableist/saneist" terms, including "silly", on several of Linus' repositories. You can tell it is a troll because it is just copying/pasting the exact same complaint, just changing the name of the project. It is not even bothering to change the list of alleged problematic words and their counts, so for example it is claiming that perconvert has 144 occurrences of "sanity check" when it actually has 0. In fact every single claim on that one is wrong. The only word from the complaint actually in pesconvert is stupid, which occurs one time, not the six times claimed. Second sign it is a troll is that it is from a GitHub account created just before the complaints were posted. [1] https://gist.github.com/seanmhanson/fe370c2d8bd2b3228680e38899baf5cc https://gist.github.com/seanmhanson/fe370c2d8bd2b3228680e388... [2] https://github.com/torvalds/uemacs/issues/16 https://github.com/torvalds/uemacs/issues/16 [3] https://github.com/torvalds/linux/pull/595#issuecomment-423660617 https://github.com/torvalds/linux/pull/595#issuecomment-4236... [4] https://github.com/torvalds/pesconvert/issues/4 https://github.com/torvalds/pesconvert/issues/4 [5] https://github.com/torvalds/test-tlb/issues/5 https://github.com/torvalds/test-tlb/issues/5
- kryptiskt 8y agoIt has no algebraic data types and pattern matching.
- andrewchambers 8y agoSomeone wrote pattern matching as a macro - nim is pretty powerful.
- mooreds 8y agoThis library? https://andreaferretti.github.io/patty/ https://andreaferretti.github.io/patty/
- andrewchambers 8y agoThat's the one.
- ColinWright 8y agoDo you have a reference for that immediately to hand, or should I search for it ...
- chi3 8y agoThis is enough to make me keep using C++ for the use cases where Nim is meant to shine, or choose Rust instead. If I'm to learn a modern language, I really expect it to support modern paradigms. I can see why it'd be interesting to someone with no C/C++ knowledge to get into systems programming though.
- mratsim 8y agoWhat algebraic datatypes is Nim missing? It has generics, tuples, tagged and untagged unions, it even has C++20 concepts.
- inportb 8y agoTabs are not allowed for indentation.
- skellock 8y agoPost author here. A few things that make me sad in the pants: - js doesn't have source maps (kinda of a big deal to me) - some error messages are head scratchers (seem to remember trying to add things to an immutable array not being clear) - docs could use love (eg seeing more examples of macros in action) - devel (their nightly compiler) can be rough (e.g. i found the "strings cannot be null" cutover a bit rocky -- my own damn fault, i can't go back to 0.18 after being on 0.18.1) - the big one I think, however, is adoption. I keep hearing "i'll just use rust or go". That's legit as they're also awesome. nim's stdlib is massive (too big?) and there's tonnes of high quality packages out there. You won't be left thinking... well, crap, looks like I need to talk to roll this redis layer myself. EDIT: Formatting. How does it even work?
- kungtotte 8y agoThe docs issue and devel being rough are both due to the pre-1.0 status and the smaller community. It's a little bit of a catch-22; you need adoption to gain contributors but people won't adopt until there's enough contributions to make it stable.
- dom96 8y agoyeah, which is usually where big companies help out. Their respect in the tech communities makes people take note of the new technology. I really really think "underdog" is the best way to describe Nim because of this.
- deleted 8y ago[deleted]
- alehander42 8y agoI have implemented source maps for the js backend : https://github.com/nim-lang/Nim/pull/7508 https://github.com/nim-lang/Nim/pull/7508 They aren't merged yet in the upstream compiler because I wasn't sure if I wanted to refactor the jsgen with them, but otherwise they are almost there: I use them in a personal project in a forked branch
- eeZah7Ux 8y ago
- singularity2001 8y agoconst hand* ^^ is that a pointer? Are we moving backwards?
- narimiran 8y agoNo, it isn't. `*` after a name means that the variable/function/type/etc. is public and can be seen/used when you import a module. So the whole expression just means "a public constant string (automatically inferred type) named `hand`".
- singularity2001 8y agooh, that was a surprise. thanks
- sushidev 8y agoHow about the garbage collector? For really performance sensitive applications you'd turn it off and resort to manual memory management?
- dom96 8y agoYes, but the GC is very flexible so you might get away with using its soft real-time features[1]. 1 - https://nim-lang.org/docs/gc.html https://nim-lang.org/docs/gc.html
- andrewchambers 8y agoNim also has a stack based region allocator, but it didn't seem too well documented when I tried to use it.
- mratsim 8y agoYou can also mix GC-managed and manually allocated types in the same codebase.
- qznc 8y agoInteresting claim. For me, D has the best C++ interoperability. Small test which D failed: Create a std::vector<Foo> in Nim. Create some Foo objects and append them. Pass the vector to C++, create some Foo objects there and append them as well.
- dom96 8y agoI think this is possible. I'm boarding a flight right now but I'll try to get back to you with an example later :)
- k__ 8y agoIs it the best? I read Rust is basically a safer drop-in replacement for C.
- sullyj3 8y agoLearning rust is difficult, and takes time. It's debatable whether it's worth it, but a learning a new paradigm (automatic memory management via borrow checking) hardly qualifies as a drop in replacement if you don't know how to use it already.
- sidstling 8y agoI read the article, and I’ve been spending the past 20 minutes looking at the SPA framework. I’m still not sure what it is or why anyone would use it. It looks extremely complicated and verbose.
- antonkm 8y agoDon't know why you're being downvoted. I had the same experience reading through Karax GitHub. I might be spoiled by other docs.
- dom96 8y agoKarax needs a promotional website, badly. It's a really great SPA framework and IMO is totally competitive with React.
- vindarel 8y agoKarax is very promising to me. The Nim forum was re-built with it recently: https://github.com/nim-lang/nimforum https://github.com/nim-lang/nimforum However, it has no totally no documentation, and seems super alpha.
- jhbadger 8y agoI've played with it, and have written a basic fasta/fastq bioinformatics library in nim (https://github.com/jhbadger/nimbioseq https://github.com/jhbadger/nimbioseq) What I find appealing is that seems to reach the goal of "a compiled typed language that feels like a scripting language" more so than other similar languages like Kotlin and Swift. There is just so little "boilerplate" code that always seems to have to be included in compiled languages and yet it seems to generate decent smallish binaries (via C). There's also a Javascript backend for web development, but I haven't used that.
- JohnStrangeII 8y agoI've tried it out and read the Nim book, but I'm not using it for any larger project right now. So here is a biased opinion. Pros: Nim is about as easy to program as Python, has the same speed as C, a working FFI, and all the usual bells and whistles of modern "battery included" languages like a package manager with lots of packages. It is garbage collected, which is good -- about this, some will disagree, of course. It has nice high level constructs and doesn't attempt to reinvent OOP or something like that, the language is fairly straightforward. It also has a powerful macro programming facility, which is cumbersome to use though. Cons: The community is too small and so far has not attracted CS people or many professionals, and there is the usual bulk of abandoned or undocumented packages you get with these kind of languages (more on that below). It has a few controversial syntax choices (e.g. identifier case rules) and also a number of semantic misfeatures that ease compatibility with C. It has support for native threads but no Green threads like Go, and consequently also no Green thread -> OS scheduling that would be ideal. (You'd like the language to do some flow and dependency analysis and parallelize to Green threads automatically, which are then mapped to OS threads, but AFAIK only few experimental languages can do that by now.) Its garbage collector is not optimal and not as performant as Go's, I believe. It uses whitespace for blocks, like Python. Overall, Nim is a pretty good general-purpose programming language. I should say that I have a long-term interest in esoteric languages and have been working on my own for a while. However, my main use case is desktop application development and unfortunately so far there is not a single new language that I would really recommend for developing desktop applications, unless you're fine with bindings to some monstruous web interfaces (Elektron, Sciter, etc.) and want to program half of your application in Javascript. Rust, Go, Nim, Elixier, Julia, Crystal, etc. do not have GUI frameworks that are ready for prime-time use in production, except maybe for a few interfaces to web apps. Their native libraries (like Nimx for nim, duit for Go, Conrod for Rust) are unfinished, limited or simply too impractical, and bindings to Qt and wxWidgets are either undocumented, incomplete, or suffer from weird license restrictions (like a Go Qt binding I've taken a look at, I forgot its name). Some of the libraries also create monstrously large executables. For command-line tools you can use any of them, just like thousands of other languages. For web programming, you can also use them but then there is also Common Lisp, Racket and plenty of other languages good for that. For desktop applications with modern GUI, on the other hand, you will be too limited with any of these languages and constantly chase some incomplete bindings or try to figure out how the bindings work. (Most docs for bindings simply assume that you've used the respective library a thousand times in C or C++, in case of which you could, frankly speaking, probably safe yourself the trouble and do it in C or C++ anyway.) For this reason, I've decided to use Lazarus for my GUIs. Qt with C++ or Python is also a good choice. I also use Racket, but its native GUI is too limited, and still have hopes for Go.
- k__ 8y agoWhat Crystal is for Ruby devs, Nim is for Python devs, I guess.
- galfarragem 8y agoIn theory yes, in practice it's not that clear. You make a fast Rails in Crystal and a large percentage of Ruby community will jump in. In Python you can't do that, the community is fragmented. And you have already Julia..
- dom96 8y agoIn some ways, yes. But in practice Crystal is far closer to Ruby than Nim is to Python.
- keypusher 8y agoI like Nim, although I don't think it's great for everything and I do think it fills a particular niche. For me, that is a systems-programming language akin to Go or Rust with a familiar syntax. Coming primarily from Python, sometimes I need a language that is a) safe b) fast c) easily capable of producing a cross-platform executable. Nim provides all of these with a Pythonic syntax and style, and that is really the main reason I like it. It lacks the sponsorship and audience of the other two, but is still a well maintained language with an active community and all the core functionality you would likely expect. That being said, a few years ago I was a strong proponent of Nim, while today it is clear that Rust and Go have captured the mindshare and continue to grow momentum. In fact it becomes hard to recommend Nim when I think of where these 3 languages will likely be in 5 years.
- narimiran 8y agoA year ago I've started experimenting with Nim as a "faster Python" — put some declarations, change some keywords and you're ready to go — your "compiled Python" is now ~30x faster. Recently I've used Nim for the first time for an official project at my job (at university). Instead of doing a simulation with Python+Numpy, I've decided to do it with Nim, and just plot the results with matplotlib. The whole experience was very pleasant. Speaking of interoperability with Python, there is a great Nim library called Nimpy [0], which makes possible to use Nim as a more pleasant Cython — you can keep writing Python, and just use Nim for the intensive/slow stuff. [0] https://github.com/yglukhov/nimpy https://github.com/yglukhov/nimpy