15 ms·
Nim 1.6.2
- elcritch 5y agoAlways great to see lots of bug fixes / improvements.
- posharma 5y agoGenuinely curious - why should I care about Nim? There are already a plethora of general purpose languages (both compiled and interpreted). Also, is anyone using Nim today? What's the adoption?
- goodpoint 5y agoIt's expressive and friendly like Python, but fast, statically typed and with powerful templating and macros. It makes me productive and it's really fun to use.
- winrid 5y agoI think others have covered this question well, but for my $0.02 - I've found it easy to write code in Nim that's half the size of and easily out performs (and has increased predictability, which is the big + for me) than Java/Node/etc. The default runtime also doesn't have stop the world pauses and uses a similar message passing mechanism to Go.
- echelon 5y agoNim seems to be targeting the space between Python and Go, which is wide open for disruption. (Also touches at the edges of managed memory systems-y light languages like Java/C#.) Python is a dynamically typed cowboy land and is painfully slow for many applications. People want types, speed, and fixes for decades of baggage, but they like Python ergonomics. Go until recently lacked generics (it still doesn't have full generics), has bad error handling, and other weird features. Rust and Swift also seem to be interested in this space. Rust can be heavy. Swift too Apple-centric. Nim is doing a good job and is growing at a steady clip.
- kitd 5y agoGo ... has bad error handling, and other weird features. That's just, like, your opinion man ;)
- sp33der89 5y agoFor me it's the intersection of performance like Rust, the readability like Python, the ability to generate native executables without dependencies like Go and a very cool type system. All while delivering fast compile speeds! The adoption isn't like Rust and Go, but Nim is growing: https://github.com/nim-lang/Nim/wiki/Organizations-using-Nim https://github.com/nim-lang/Nim/wiki/Organizations-using-Nim and the community is active across all socials. Some downsides: not a big ecosystem(tho can piggyback off C libraries) and tooling isn't great. Advent of Code would be a great way to dip your toes into a language you might not really care about!
- MrBuddyCasino 5y ago> performance like Rust I've just looked at some benchmarks, and even though Nim claims C-like performance, that never seems to be confirmed by independent tests. It is usually a bit behind C / C++ / Rust / Crystal, and roughly on-par with Golang. Fast enough for sure, but "half the speed of C" would be more honest it seems?
- michaelsbradley 5y agoMaybe so, but sometimes benchmarkers forget to employ compiler options like: nim c -d:danger -d:lto --opt:speed ymmv https://nim-lang.org/faq.html https://nim-lang.org/faq.html https://nim-lang.org/docs/nimc.html https://nim-lang.org/docs/nimc.html Also, --gc:arc and --gc:orc are going to bring a stronger game to the table as they continue to mature (already pretty far along).
- carlmr 5y agoDo these activate -funsafe-math on the underlying C compiler? Because if so that's not a fair comparison, since this breaks a lot of code.
- shirleyquirk 5y agono, -d:danger turns off runtime bounds/overflow checks, assertions, and debug info, and passes '-O3 -fno-ident' to the C compiler
- girvo 5y agoI use it extensively for building firmware for an IoT sensor platform
- formerly_proven 5y agoI was a interested in Nim until I learned that getBlochenAngle and get__B_L_O_C_H_E_N_ANGLE are the same identifier. > https://nim-lang.org/docs/manual.html#lexical-analysis-identifier-equality https://nim-lang.org/docs/manual.html#lexical-analysis-ident...
- rakoo 5y agoMy personal blocker is that identifiers are all imported globally by convention, so when you see that there is a call to a method called "get", you have to get to the top of the file or mouse over the call to see what lib it is from. A "get" from the http lib is not the same as a "get" from the kv store lib.
- nerdponx 5y agoDon't Haskell and Go also do this?
- rakoo 5y agoI have no experience in Haskell, but in Go: - if it's a builtin or in the current package, you usie it directly - if it's in another package the identifier is always prefixed with the package
- benjamin-lee 5y agoThere is some logic as to why that is. Here [1] is an explanation for why it makes sense but the tldr is that you don't want to be manually importing functions such as `$` and `+`. In languages like Python, those are defined as methods on the object being imported (e.g. `.__str__()`) so they come along for free. Not so in Nim. If there's a conflict (same name, same signature), the compiler will warn you but it's extremely rare. [1] https://narimiran.github.io/2019/07/01/nim-import.html https://narimiran.github.io/2019/07/01/nim-import.html
- formerly_proven 5y agoArgument-dependent lookup would solve that in a far less global way.
- gyulai 5y agoSeveral years back, I wanted to know what the hype was about with regard to Rust and started looking into Rust a bit. In the process I also stumbled across Nim and decided that Nim suited those needs that I might have had for Rust even better than Rust did. The killer feature for me is that it transpiles both to C and to JavaScript and I like the clean Python-like syntax. I now use Nim whenever I write a decent chunk of "pure logic". By that, I mean something that does something complex and useful without leaving the confines of its own codebase all too much. In those cases it's nice to have the option of portability between the C ecosystem and JavaScript ecosystem. When I write "glue code" (and, unfortunately, most code that most people write falls into that category) where I basically just put bits of language ecosystem together in a trivial way to achieve something useful, then I use Python because for such tasks the sheer size of the language ecosystem is king.
- DeathArrow 5y agoFast as C, slick as Python. Highly productive with great performance.
- thom 5y agoOf the current crop of new(ish) systems languages, it’s the one that feels most fun to me. It reminds me of Ruby, not necessarily technically (obviously there’s Crystal for that), but in the sense that it’s a breath of fresh air coming from more austere languages. I wouldn’t make a career or company bet on it (compared to Rust which I think is a very sensible choice) but I’m always keen to noodle away at new hobby projects in Nim.
- jokoon 5y agoIf I would pick one, I would pick Zig. The language that is missing is a simple language that can work well with C or C++, compiles fast, is easy to read, has a good lib, etc. There are not enough non-GC languages that are statically compiled. I really, really want a pythonic, statically compiled language. I don't want templates, OOP, abstract stuff, just A C-like language, more readable, with good syntactic sugar. My dream is that there would be as much time money and effort spent on python, than was spent en js engine like v8 and spidermonkey. There are barriers that make python not really viable everywhere, and I wish it would not be the case.
- knuthsat 5y agoI always thought of Python as being a massive language. If it was simple, it should be easy to compile and optimize. I mean, I would feel like an idiot when someone would point out a feature that makes Python code faster. Python classes are quite massive and complicated (with a bunch of tweaks one can do through attributes).
- amedvednikov 5y ago> The language that is missing is a simple language that can work well with C or C++, compiles fast, is easy to read, has a good lib, etc. https://vlang.io https://vlang.io ?
- jokoon 5y agoit has a GC
- dflock 5y agoNim's GC is optional - you can switch it off and do manual memory management, if you want. There's also no need to use any of the language features that you don't want?
- Mikeb85 5y agoWhy do people bother with questions like this? Araq created Nim because he wanted to. Others use it because they want to. Why does it need a raison d'être ? What it has: garbage collection with option to turn off, small binaries, compiles to C (and other languages) as intermediate step so it's easy to integrate into existing codebases, it's very fast without needing much trickery, it has all the features everyone always asks for with more being added all the time, etc... Is it better than Rust, C++, Go, Java, whatever? Probably not in a strict sense. But it's pleasant to write plus above features. It's like Pascal meets Python meets Go but compiles to C and JS.
- pietroppeter 5y ago> why should I care about Nim? it depends a lot on where you are coming from. If you are a Python developer/user (without any other information it is possibly the most likely case nowadays), you might find it solves a lot of current Python pain points (speed, portability, lack of typing, package system) and it has some added bonuses (great macro system, compiles to JS, works great for embedded). If you are not a Python developer/user but you are somehow interested in new languages like Rust, Julia or Zig (you might be both), you might want to hear a different take on how Nim is also able to solve some of the problems they solve (a better C++, a better Python/R/Matlab for scientific computing, a better C - not that those languages reduce to those aspects...). I think that what is happening now with Rust, Julia and Zig is great and I am happy that many people are looking at those languages and growing their ecosystem and their communities. Part of the drive of people there is to be able to make a significant improvement in the evolution of those languages (harder to do that in C, C++, Java, Python, C#, Swift, ...). I just happen to particularly like Nim and love being involved in it so far. A recent article that explains the philosophy of Nim is the Zen of Nim by Araq (Nim's BDFL) [0]. Nim has some universal vision in the sense that it can be really used for everything (from kernel programming to web development, from scientific computing to game development, from embedded to devoping compilers and interpreters, from short throwaway scripts to critical infrastructure). Not necessarily it is for _everyone_. Taste of people varies a lot and that is a good thing. [0]: https://nim-lang.org/blog/2021/11/15/zen-of-nim.html https://nim-lang.org/blog/2021/11/15/zen-of-nim.html
- sdmac99 5y ago> Also, is anyone using Nim today? Sure. I maintain an internal performance dashboard web app that is fully Nim. Backend uses Jester and the frontend uses Karax + Vega-lite for charts.
- sergiotapia 5y agoSuper high level elevator pitch: It's as fast as Rust, nice to look at like Python, easy to write like Python, and compiles to static binaries for any platform you can think of. There are a lot of other great things about the language but this should get anyone excited.
- amw-zero 5y agoIt’s just subtly different than anything else out there. It for the most part feels like a Python-like language, but compiles to C so is very fast. It also has one of the better macro systems out there. I was interested in developing a programming language with macros, and it has a ton of documentation about it. It’s really well thought out. I’m not saying to run a business on it, but there are lots of interesting things out there. Language design is still a very active area of innovation.
- klibertp 5y ago> Genuinely curious - why should I care about Nim? You definitely shouldn't. If you need a reason to care, then Nim is simply not for you. You won't benefit from Nim, and Nim won't benefit from you. It's best to agree to disagree and walk away from each other (assuming Nim can walk). EDIT: I got downvoted a bit here, probably because the above seemed rude and/or dismissive? If so, sorry, that wasn't my intention. What I meant to say is that with languages like Nim it doesn't make sense to be interested in them if you're not already interested in programming languages. It'll be another 10-20 years before Nim becomes something the general populace of programmers should (or, if we're lucky, would have to) care about. So if you don't have a particular reason to be interested in Nim, chances are you won't get such a reason from anything that can be said about Nim at this time. Basically, asking the quoted question already means that there's nothing you'd care about in Nim.
- iffycan 5y agoNim can walk: https://nim-lang.org/docs/os.html#walkDir.i%2Cstring https://nim-lang.org/docs/os.html#walkDir.i%2Cstring
- posharma 5y agoNot sure why I'm getting downvoted for asking a genuine question. The objective is not to deride Nim in any way.
- esimov 5y agoSeeing that the team behind Nim is accepting Bitcoin is not a good sign.
- girvo 5y agoWhy’s that?
- k__ 5y agoJust the general disdain for crypto here at HN.
- WesolyKubeczek 5y agoI still see more crypto/blockchain adoration here than disdain, although the tables might be turning slowly now. HN users are much like magpies: once an idea shoots up, you can't swing a cat without hitting a zealot. If you are ambivalent or skeptic, you'll be furiously explained into the corner. Then, when the fad fizzes out and its inevitable drawbacks are publicized by more and more sources, the "told you so" camp starts merrily chasing the dwindling numbers of zealots around, while some former zealots get depressed from their high hopes being squandered and the resulting dopamine deficiency. A new shiny comes in (say, "rewrite everything in Rust"), the cycle repeats.
- k__ 5y agoIn the web3/blockchain space, HN is known as a prime example of a place you should go to ground yourself, because HN hates it with passion.
- WesolyKubeczek 5y agoYou say "web3/blockchain", I hear "homeopathy", "astrology", and "bioenergetic therapy". The HN crowd might be fad-gullible, but stupid-gullible? I don't think so.
- mcc1ane 5y agoSo did anyone decode the "It combines successful concepts from mature languages like Python, Ada and Modula." blurb yet?
- michaelsbradley 5y agoSomething I'm excited about: v1.6.2 integrates support for (not yet released) Nimble[1] v0.14, which will introduce project lockfiles. I've had terrible experiences with lockfiles in JS land, but they are sorely needed for Nim projects as (fingers crossed) they'll allow for reproducible builds without having to resort to the nimbus-build-system[2]. The latter isn't completely horrible — a lot of much appreciated hard work has gone into it, and it's been a real workhorse — but some days it feels like a big ball and chain. I'll be much happier when I can cruise along with choosenim[3] and lockfiles and not have to worry about Makefile + submodules shenanigans. [1] https://github.com/nim-lang/nimble#readme https://github.com/nim-lang/nimble#readme [2] https://github.com/status-im/nimbus-build-system#readme https://github.com/status-im/nimbus-build-system#readme [3] https://github.com/dom96/choosenim#readme https://github.com/dom96/choosenim#readme
- dom96 5y ago> reproducible builds without having to resort to the nimbus-build-system[2] A giant makefile shudder, that's the complete anti-thesis of Nim :) Lock files have definitely been needed for a while though, I agree.
- DeathArrow 5y agoI sincerely hope Nim will pick up more steam. I find it quite enjoyable and a good jack of all trades. You can literally write anything in Nim, in a reasonable amount of time while having decent performance if you have good libraries, frameworks and documentation.
- pietroppeter 5y agoother interesting activities going on currently in the nim space: - advent of nim (advent of code with nim): https://forum.nim-lang.org/t/8657#56695 https://forum.nim-lang.org/t/8657#56695 - call for participation to FOSDEM: https://forum.nim-lang.org/t/8671 https://forum.nim-lang.org/t/8671
- deleted 5y ago[deleted]
- jimmyed 5y ago> Macros cannot change Nim's syntax because there is no need for it — the syntax is flexible enough. Erm, what? How about letting the user decide that?
- xigoi 5y agoIt's much easier to write macros when you don't have to parse anything.
- shirleyquirk 5y agoit does come across as arrogant. A humbler way to put it would be "Macros cannot change Nim's syntax because they transform the AST after it has already been parsed"
- dom96 5y agoThat's not the reasoning though. Not allowing macros to change the syntax gives Nim programmers an anchor and reduces friction from needing to learn brand new syntax rules for any big DSLs.
- kajiryoji 5y agoI see nim being compared with the same languages as zig. Does anyone has any opinios regarding how nim vs zig?
- qalmakka 5y agoThey kind of occupy two different niches, IMHO. I see Nim more as a competitor to Go, whole Zig wants to replace C mostly and somewhat competes with Rust in that regard.
- vegai_ 5y agoThey have the same amount of letters in their name, both have "i" as the second letter. Zig is (a much) better C. Few solid features. Nim is a better (Pascal+python+lisp)/3. Lots of features. Some are solid.
- shirleyquirk 5y agozig's IR is llvm, while Nim's IR is C/C++/javascript. C supports more platforms than llvm. zig: no macros plz nim: macros are amazing
- FridgeSeal 5y agoNim is everything Python and Go should be/want to be, as far as language features and semantics go (haha). It has their easy-to-learn properties, but has a better type system, the generics system and macros are arguably more useful, and more usable than what is offered in either language. It deserves far more attention than it currently gets.
- spaniard89277 5y agoAs someone learning programming, should I try nim for my first compiled language, instead of C++? I know it's likely harder to find answers in the Internet, but at the same time it looks easier, coming from Python and JS. If nim picks up pace in a few years and I already have a sense of it, it may be a good for prospects too.
- galangalalgol 5y agoIf you already know python and JS I think you probably won't have too much trouble with Nim, but why not add something new like memory management to learn about? Rust is complicated, but it has training wheels, and its wasm support would integrate with your JS knowledge. Alternatively modern C is still used everywhere and will teach you a lot about hardware.
- juki 5y ago> but why not add something new like memory management to learn about? You can learn that with Nim too. It supports manual memory management like C. The new ARC/ORC GC also works more like modern C++ than a traditional GC. > its wasm support would integrate with your JS knowledge Nim can also compile to JS. Or you could compile it first to C and then compile that to wasm, although that's not supported out of the box.
- galangalalgol 5y agoThose are good points. I have found that languages that don't force me to use a feature don't teach aa well as ones that do. I usually don't want to use those languages later though ( java and oop or Haskell and functional) because I like having options. Nim gives you lots of options it sounds like.
- warent 5y agoI've vaguely heard of Nim in the past and for some reason always thought it was some limited scripting language. But this looks like a pretty serious candidate for a nice backend language. I'm getting tired of how cumbersome Go is and have had my eye on Crystal. Anyone have any insight on how Nim stacks up to Crystal?
- nerdponx 5y agoI have written toy programs in Nim and Crystal, and the Nim experience is much more polished. The Nim compiler is as fast as the Crystal compiler is slow! I think Crystal is more enjoyable to use, personally. I am not a Ruby programmer, but Crystal just somehow feels fun to use. Nim by contrast feels very utilitarian, and frankly more practical. I found the Nim language documentation better than Crystal, the Crystal standard library docs are just as good as Nim. Nim overall feels like an "early 1.0-ish" language. Crystal feels like they went to 1.0 m too early. I would probably consider using Nim in a medium-sized application for work, whereas I wouldn't feel comfortable with Crystal for more than a personal hobby project. They do have some things in common (macros, C interop, static types), but aren't really similar languages. I used to lump them together in my head as "those two new languages", but I don't anymore after trying them both. If you are checking out new-ish languages, I hear Kotlin has some good design decisions that people appreciate (but that the tooling is pretty bad outside of Jetbrains IDEs).
- rickstanley 5y agoThere's Kotlin script if I recall correctly. But not that developed yet nor easy to use outside jetbrains ecosystem (IDEA).
- ajusa 5y agoIn case you want a quick example of a backend application in Nim, I've written a small post[1] describing how to create a room based chat using it and HTMX. In total, it's around 70 lines of code (though it doesn't cover more advanced use cases, like username collision). I too have moved from Go to Nim, the syntax and ease in which I can turn a feature into code has been much better. [1]: https://arhamjain.com/2021/11/22/nim-simple-chat.html https://arhamjain.com/2021/11/22/nim-simple-chat.html
- samwillis 5y agoWhat’s the story like using Nim for WASM? I’ve always meant to take a proper look at Nim, and maybe WASM could be the perfect place for it.
- dom96 5y agoIt works, just as it does for C. Although I'd say it depends what you want it for, Nim already supports being translated to JS natively.
- Atomskun 5y agoI love Nim's syntax, but is there a specific reason why e.g. the SFML binding cannot imitate C++ RAII approach of handling resources? There is .close everywhere.
- generichuman 5y agoDestruction used to be nondeterministic in Nim. Right now though, if you use the ARC/ORC instead of the default GC (ORC will be made the default GC soon) you can have RAII for reference types (RAII is available for value types by default, just write a destructor for your type). SFML binding probably will be updated to use RAII when ORC is made the default GC. See this document for more info on Nim's destructors: https://nim-lang.org/docs/destructors.html https://nim-lang.org/docs/destructors.html
- wontruefree 5y agoI like nim and have tried it a few times. But I like Crystal more. Has any anyone here tried Crystal?
- sireat 5y agoI would like to use Nim for data wrangling tasks - for shipping compiled data munging CLI utilities. Looking at https://nim-lang.github.io/Nim/lib.htmlIt https://nim-lang.github.io/Nim/lib.htmlIt seems to have many of the batteries built in - HTML, JSON parsing, nice set of collections. I wonder how good SQL and especially noSQL support is. My worry is that there must be rough edges. Plus pandas (not just numpy) is just so convenient at times.
- vasili111 5y agoI think this is correct link: https://nim-lang.github.io/Nim/lib.html https://nim-lang.github.io/Nim/lib.html