17 ms·
Nim 2.0
- netbioserror 3y agoBeen happily crunching away at Nim in production. I'm working on what is mainly a data analysis and report generation tool, compiled as a CLI executable that gets called by server scripts. Nim makes fast, small executables. It has an excellent heterogenous JSON data structure and a good dataframe library. It prefers the stack so strongly that dynamic data structures (sequences and tables, basically its lists and dictionaries) are pointers on the stack to heap data, where the lifetime is managed by the stack frame. I don't think I have any dynamic references anywhere in my program, and don't have to worry about GC at all. The type system is simple, sensible, and guides you to correctness with ease. Nim also defaults to referential transparency; everything is passed immutably by-value unless you opt out. Generics are powerful and work exactly as you expect, no surprises. Universal function call syntax is ridiculously powerful: You can write the equivalents to methods and interfaces on types just by making procedures and functions that take a first parameter of that type; not needing those abstractions greatly simplifies and flattens code structure. It's just procedures and objects (functions and structs) all the way down. It's been a real joy to work with and reminds me of when I discovered D back in the day, only it's even better. If you imagine native-compiled type-annotated Python where nearly 100% of your code is business logic with no cruft, you're getting close to the Nim experience.
- pavlov 3y ago> “It prefers the stack so strongly that dynamic data structures (sequences and tables, basically its lists and dictionaries) are pointers on the stack to heap data, where the lifetime is managed by the stack frame.” Isn’t that the same as a C++ vector or map on stack? They allocate internally as needed, and the whole container is destroyed when it goes out of scope.
- remram 3y agoAgreed, only being able to put pointers on the stack, no data, would make me think it "prefers the heap".
- netbioserror 3y agoDynamic data structures by their nature have to be allocated to the heap. What I mean by "prefers the stack" is that you don't have to make a managed ref and dereference a managed pointer type. You just make a `seq[int]`, use it as a `seq[int]`, and pass it as a `seq[int]`, just like stack data. Behind the scenes, it has a unique scoped pointer with no mental overhead.
- jitl 3y agoSounds like a vector/array/list in any other language after C++, like Go slice, Java ArrayList, Javascript array, Python list, Rust vec. Is there something I'm missing?
- gcoakes 3y agoI think they're discussing the lifetime of that heap data, not whether the data is heap allocated.
- chc 3y agoI don't see them drawing any distinctions from C++ or Rust there either. It really sounds to me like most of their low-level experience is in C, where the contrasts they appear to be drawing really do apply.
- kragen 3y agoit depends on what you mean by 'dynamic' and 'stack'; certainly, outside of nim, you can allocate a list of, say, integers entirely on a stack in any of the following cases: - the size of the list is known when you create a stack frame, as in c: int xs[n] = {0}; - when the list grows, it grows in that subroutine and not some callee, for example using alloca(); - the list is built on a stack that isn't the one you have to pop your return address off of; examples include perl's data stack, ada's secondary stack, forth's operand stack, forth's dictionary, or an mlkit region. in these cases you can even return the dynamically built structure to a caller; - each new callee adds some fixed number of items to a linked list, such as, in c void with_fill(color *c, env *e, void (*cb)(void*, env*), void *userdata) { env ne = { .prop = PROP_FILL_COLOR, .val = c, .parent = e }; cb(userdata, &ne); } look ma, no heap
- netbioserror 3y agoBasically, but it requires no extra syntax. `var some_seq = @[1, 2, 3, 4]` is a stack-managed sequence. That's all there is to it. There's no unwrapping any pointers or boxes or what-not, the type is just `seq[int]`. Put another way, things that have become best practice in C++ are default in Nim with no syntactic noise.
- CyberDildonics 3y agoThere's no unwrapping any pointers or boxes or what-not That doesn't happen by default in C++ either. std::vector<int> some_seq{1, 2, 3, 4, 5, 7};
- jcelerier 3y agoor even just std::vector some_seq{1, 2, 3, 4, 5, 7}; nowadays (for a value of nowadays that is 5 years old for GCC and 6 years old for Clang)
- seertaak 3y agoIndeed there's no question that Nim is basically following C++'s lead on this. Nim iirc always had constructors and destructors. Final piece of the puzzle is move semantics, and I recall a blog post where Araq came up with something very similar.
- shirleyquirk 3y agoyes, Nim has move semantics, but takes care of you more than c++ does. for example, if you use an object that was previously moved, you dont get garbage, the compiler turns the first move into a copy (and tells you) the relevant docs are here: https://nim-lang.org/docs/destructors.html https://nim-lang.org/docs/destructors.html
- echelon 3y agoSame as Rust. Vec and HashMap are stack pointers to the heap-allocated container storage space.
- seertaak 3y agoIt very much is, and the point is, it _used_ to be more like java. Araq basically pulled off a very daring switchover from reference based language system to a value based one. So now the language can credibly claim the same as c++ - no room left closer to the metal. But it's packaged in a much nicer syntax (imho), and has features like macros which we can expect I'm C++ in maybe 10 years, if we're lucky.
- 999900000999 3y agoIt does indeed look like Python! I hope it gets more popular, seems like a much much easier to use Rust
- shmageggy 3y agoThis sounds great. How is the package management story, and how robust is the ecosystem currently?
- FireInsight 3y agoYou can check out the list of Nim packages at https://nimble.directory https://nimble.directory
- m0do1 3y agoThis provides a good overview of packages for various applications: https://github.com/ringabout/awesome-nim https://github.com/ringabout/awesome-nim I think most of them are available via nimble.
- shirleyquirk 3y agoThe ecosystem is smaller than some, but wrapping libraries is mostly automatable, and there is tooling to assist interop with python, c, and c++
- Zamiel_Snawley 3y agoYou have convinced me to look in to Nim! Can you speak to the build system(s)? CMake is the bane of my existence.
- PMunch 3y agoAnother Nim user here. Typically you just build the project by `nim c <myProject.nim>`, since Nim has such a strong macro system a lot of typical build stuff is just done with macros. Of course there's also the default Nimble package manager which allows you to list dependencies and tasks using Nim itself. This means that if you know how to write Nim managing the build system is a breeze.
- elcritch 3y agoUgh, I just got done spending months fighting CMake before moving back to a position using Nim! You can also compile C projects with Nim like bearssl [1]. Nim takes care to compile the C files and recompile them when config flags change. It's actually really nice. 1: https://github.com/status-im/nim-bearssl/blob/99fcb3405c55b27cfffbf60f5368c55da7346f23/bearssl/abi/brssl.nim https://github.com/status-im/nim-bearssl/blob/99fcb3405c55b2...
- deleted 3y ago[deleted]
- netbioserror 3y agoGotta be honest here, I use a pretty simple Makefile. I don't have anyone else working on this program, so I can afford simplicity.
- inv2004 3y agoI did a lot of nim small projects. All of them are on nimble build system: https://github.com/inv2004 https://github.com/inv2004
- afavour 3y agoCongrats to all involved. I find Nim to be an absolutely fascinating language. I've been trying to find a reason to use it on my job (my work is mobile-adjacent so the idea of compiling to JS and to ObjC is fascinating) but haven't gone beyond playing around with it so far. I've been comparing it to Rust and it's just so much simpler to get started with.
- jasfi 3y agoSomewhat related, you can call Nim code from Node.js/Bun using Denim: https://github.com/openpeeps/denim https://github.com/openpeeps/denim. It works by creating a Node add-on. This is great for reusing Nim code in a web app, and possibly for performance critical code.
- jadbox 3y agoAnyone have working experience with Nim and Zig? I'd love to hear how they are similar and contrast. I'd also would like to see some idiomatic web server benchmarks between the two (now with Nim v2).
- rbjorklin 3y agoZig doesn’t seem to have an implementation for the TechEmpower Benchmarks but Nim does: https://www.techempower.com/benchmarks/#section=data-r21&l=yxbjen-6bj https://www.techempower.com/benchmarks/#section=data-r21&l=y...
- michaelsbradley 3y agoNim's should probably be redone with mummy (multi-threaded) and chronos (async single-threaded) for a better showing: https://github.com/guzba/mummy https://github.com/guzba/mummy https://github.com/status-im/nim-chronos https://github.com/status-im/nim-chronos
- e4m2 3y agoWhy does the stdlib implementation do so badly in the first place?
- throwbadubadu 3y agoIt is maybe the most simple web server implementation, similar to what you get from "python3 -m http.server"? What sense does it make to compare highly focused web server frameworks to languages most simple stdlib implementations, much apples vs oranges.. (thus also not getting why the proposal to compare with actual web frameworks for nim is that much downvoted?!)
- arc619 3y agoToo much string copying iirc. It was written a while ago. Hopefully it'll get updated/replaced some time, but there's plenty of faster 3rd party ones already.
- davidkunz 3y agoFantastic language, hoping this will lead to increased adoption!
- _xivi 3y agoJust started learning Nim recently and really loving it. Even though it's older than its peers like Rust and Go, it still quite the underdog. Hope more people start paying attention to it.
- 0cf8612b2e1e 3y agoGo had full time engineers designing the language, tooling, docs, etc. Nim has never had huge industry sponsorship, so comparing the languages on age alone is hardly fair.
- synergy20 3y agonim is a better python(syntax wise) that compiles to c(or c++,js,etc but c is the default) with GC turned on by default. I have always been wanting to use it outside of what my job needs(c/c++/python). I hope some big players adopt Nim to make it one of the mainstream language.
- treeform 3y agoReddit was hiring for Nim positions. So demand is growing. New languages have easier time being adopted at startups which grow into big players eventually.
- brodouevencode 3y agoWhat are some noteworthy projects or libraries written in Nim?
- michaelsbradley 3y agoLots of high-quality Nim projects and libs are being worked on and used by the folks at Status: https://github.com/status-im/nimbus-eth2 https://github.com/status-im/nimbus-eth2 https://github.com/orgs/status-im/repositories?language=nim&q=&sort=&type=all https://github.com/orgs/status-im/repositories?language=nim&...
- sphars 3y agoNitter (Twitter frontend) is written in Nim: https://github.com/zedeus/nitter/ https://github.com/zedeus/nitter/
- summarity 3y agohttps://findsight.ai https://findsight.ai is my project, written in Nim I gave a talk about it here: https://www.youtube.com/watch?v=elNrRU12xRc https://www.youtube.com/watch?v=elNrRU12xRc including some more intense use of Nim (for inline PEG grammars and data-parallel processing with Weave)
- sergiotapia 3y agoCheck out my project Torrentinim for a popular but simple enough project if you want to taste what Nim is like. https://github.com/sergiotapia/torrentinim https://github.com/sergiotapia/torrentinim It's easy to understand code.
- hugs 3y agoI don't know if my particular version is noteworthy, but I recently started making updated Nim bindings for OpenCV and it was kinda fun. I don't consider myself an advanced C++ programmer, but Nim made the process easier than I had feared it would be. https://github.com/tapsterbot/mvb-opencv https://github.com/tapsterbot/mvb-opencv
- pzo 3y ago
- turnsout 3y agoNim looks awesome. Does anyone know why it doesn't have first-class support for wasm? That's the only thing that would keep me from diving into it more.
- ilaksh 3y agoI think the short answer is it's built on top of C tooling so it doesn't really need another way to do it because you can use emscripten. Search their forum for "web assembly". I did ask him about it eight years ago: https://forum.nim-lang.org/t/1392#8675 https://forum.nim-lang.org/t/1392#8675 But that was a little early on and there have been other priorities for the language.
- turnsout 3y agoThe reason I ask is that I was poking around and saw some projects to help with wasm compilation, and on this random list of wasm-capable languages [0], Nim is listed as "Work in Progress." Notably, Swift is ranked higher, and I view Swift as extremely experimental when it comes to wasm [0]: https://github.com/appcypher/awesome-wasm-langs https://github.com/appcypher/awesome-wasm-langs
- elcritch 3y agoWith 2.0 out and ORC being default it compiles and works just fine. There's not too many libraries specializing for wasm stuff though, so you gotta use emscriptens or similar.
- hugs 3y agoI suspect it's simply a size-of-community thing. If you want it, you should take a crack at implementing it! Or least start a thread about on the official developer forum.
- moigagoo 3y agoCongratulations to everyone involved and the entire Nim community! Nim has been my language of choice for the past decade and I'm really happy with the new features in Nim 2.0. Some of them are real gamechangers for my projects. For example, default values for objects theoretically allow me to make Norm[1] work with object types along with object instances. And the new overloadable enums is something Karkas [2] wouldn't be possible at all (it's still WIP though). [1] https://norm.nim.town https://norm.nim.town [2] https://karkas.nim.town https://karkas.nim.town
- arc619 3y agoOf all the recent changes, default values is my favorite. Aside from generally useful and further reducing the need for initialisation boilerplate, I lets us guarantee valid state at compile time for things like enums - and, I assume, object variants?
- frou_dh 3y agoSeems like it kinda has Sum Types, so Nim passes the litmus test for respectable static type-system in this day and age. https://nim-lang.org/docs/manual.html#types-object-variants https://nim-lang.org/docs/manual.html#types-object-variants
- jackmott42 3y agoI feel the same way as you! I've seen many language ideas come and go in my career and sum types are one I feel now should be a basic requirement. I miss them in any language without them.
- c-cube 3y agoWhen I looked at it a few years ago, the compiler didn't prevent you from accessing fields from the wrong variant, and didn't provide exhaustivity checks. So I think it still falls short of this (excellent) litmus test :/
- cobby 3y agoAlso Nim requires you to use unique field names across all variants.
- alwaysbeconsing 3y agoThis annoying restriction is lifted in Nim 2; see the linked announcement.
- xigoi 3y agoWhere in the announcement does it say that?
- ElegantBeef 3y agoThey likely read "overloadable enums" and went "Oh Rust calls their tagged unions enums" so assumed all languages did.
- WhereIsTheTruth 3y agoCould be a fun python alternative Questions: - value/object semantic: i peeked at some code, and i can't tell what is a value, and what is a reference type, is everything heap allocated? - tooling: what's the state of their language server? does it work with all of their language features? - debugging: does gdb/lldb understand nim's types and slices? And finally: is a no-gc mode available? I'll play with it later today, it's always been in my todo list of languages to try, now is the perfect time
- janAkali 3y ago1. Nim uses 'var' modifier to pass by reference, e.g. "proc (n: var int)...", default behaviour is pass by value. And there're also raw pointers and references (safe pointers). >is a no-gc mode available? You can disable gc, but most of standard library depends on it. But in Nim 2.0 there's finally support for ARC and ORC (ARC + cycle collector).
- msk-lywenn 3y agoI've been searching and can't find it: A in ARC is for automatic, what does the O stand for?
- lambertsimnel 3y agoI assumed the O was for "optimised", but apparently it stands for "cycle": https://nim-lang.org/blog/2020/12/08/introducing-orc.html https://nim-lang.org/blog/2020/12/08/introducing-orc.html
- dinHeld 3y agoO is a visual pun because it adds a cycle collector to ARC.
- ElegantBeef 3y ago> default behaviour is pass by value Is not exactly true, smaller than 24 bytes is passed by value, the compiler optimizes larger calls and passes by reference implicitly.
- Bostonian 3y agoIf your Python programs heavily use Pandas and Numpy, could there still be speed benefits to translating them to Nim?
- janAkali 3y agoYour programs could benefit from small dependency-free executables and compile time code generation and execution. Nim code can also be called directly from python or vice versa, check out nimpy[1]. 1. https://github.com/yglukhov/nimpy https://github.com/yglukhov/nimpy
- maleldil 3y agoThat might depend on how many raw Python loops and functions you use. Even if most of your code uses pandas and numpy, things like string processing could still benefit from a compiled language.
- pointystick 3y agoHere's a presentation from last year where a Python data scientist compares a Python and Nim implementation for a problem, with the Python version calling out to Numpy. There are performance comparisons at the end and his Nim version was faster so Nim should be usable for scientific programming: https://archive.fosdem.org/2022/schedule/event/nim_hpcfrompythontonim/ https://archive.fosdem.org/2022/schedule/event/nim_hpcfrompy... The big issue Nim faces isn't performance but rather the relative community sizes, and thus how many libraries are available (and also how much help you might find when you run into problems).
- drbaba 3y agoFollowing up on this: As someone who uses Python with NumPy/SciPy heavily, are there any Nim libraries that would make the transition smooth? Libraries that can help with e.g. sparse matrices, linear algebra, differential equations, etc.
- pointystick 3y agoI've not used them myself but there was an effort to group these kinds of libraries in a common 'SciNim' community: https://github.com/SciNim https://github.com/SciNim https://scinim.github.io/getting-started/ https://scinim.github.io/getting-started/ Generally, projects created by Mamy Ratsimbazafy (mratsim) are a good start since he's very adept at optimisating data science-related libraries. You might want to ask in the #science channel of the Nim Discord server since although it's often quiet, that's where people working on these repositories hang out.
- deleted 3y ago[deleted]
- nicechianti 3y ago[dead]
- aquova 3y agoNim has been my favorite language for a while now, and I'm very excited to see version 2.0 finally released. A lot of these features have been items I've been looking forward to for some time. The only downside is some of the included modules being moved to 3rd party repositories, as mentioned at the very bottom. It's not a big deal, but it was nice having SQLite support built into the library. I suppose once you support some databases, you'll be pressured to support more and more. I am a bit surprised to see MD5 and SHA1 support moved out though.
- otherme123 3y agoLibraries stagnate in the batteries included. Python carries some dead batteries since the 90's, but they are required there. While it's nice to have path or logging support in the batteries, some other things are better as third parties, to allow them to evolve.
- j-james 3y agoYes, an experiment was run a while back, incorporating community-maintained code in a "fusion" repo shipped with the compiler by default. It didn't work very well. Discoverability and maintainability of stdlib-like things is hard.
- lenkite 3y agoIn my experience in the batteries included stdlib approach, even if libraries evolve slowly, they tend to get a lot more attention wrt bug-fixing and performance improvements. Go's stdlib is the example here.
- quazar 3y agohttps://github.com/belamenso/v https://github.com/belamenso/v This cleans up Nim's syntax a little, we use it in production with not much maintenance.
- kitd 3y agoStill more readable than the average JS front end.
- arc619 3y agoLooking forward to trying out this release! After programming professionally for 25 years, IMO Nim really is the best of all worlds. Easy to write like Python, strongly typed but with great inference, and defaults that make it fast and safe. Great for everything from embedded to HPC. The language has an amazing way of making code simpler. Eg UFCS, generics, and concepts give the best of OOP without endless scaffolding to tie you up in brittle data relationships just to organise things. Unlike Python, though, ambiguity is a compile time error. I find the same programs are much smaller and easier to read and understand than most other languages, yet there's not much behind the scenes magic to learn because the defaults just make sense. Then the compile time metaprogramming is just on another level. It's straightforward to use, and a core part of the language's design, without resorting to separate dialects or substitution games. Eg, generating bespoke parsing code from files is easy - removing the toil and copypasta of boilerplate. At the same time, it compiles fast. IMHO it's easier to write well than Python thanks to an excellent type system, but matches C/C++ for performance, and the output is trivial to distribute with small, self contained executables. It's got native ABI to C, C++, ObjC, and JS, a fantasic FFI, and great Python interop to boot. That means you can use established ecosystems directly, without needing to rewrite them. Imagine writing Python style pseudoocode for ESP32 and it being super efficient without trying, and with bare metal control when you want. Then writing a web app with backend and frontend in the same efficient language. Then writing a fast paced bullet hell and not even worrying about GC because everything's stack allocated unless you say otherwise. That's been my Nim experience. Easy, productive, efficient, with high control. For business, there's a huge amount of value in hacking up a prototype like you might in Python, and it's already fast and lean enough for production. It could be a company's secret weapon. So, ahem. If anyone wants to hire a very experienced Nim dev, hit me up!
- talldrinkofwhat 3y agoAhem. Ahem. Contact info?
- moigagoo 3y agoAre you hiring Nim devs?
- fithisux 3y ago"Nim is a programming language that is good for everything, but not for everybody." now you got me really interested. At some point dlang-betterc + zig + nim should have an interoperability article and share libraries.
- j-james 3y agoReally, I'm quite hopeful for crabi: https://github.com/rust-lang/rust/pull/105586 https://github.com/rust-lang/rust/pull/105586 An ABI for languages with a proper type system seems fantastic. Swift, Rust, Nim, D all share very similar type systems (and memory management systems) and it would be very cool to see what kinds of interop easy dynamic linking would allow.
- fithisux 3y agoI didn't know about it. Seems life has bright sides too.
- squarefoot 3y agoIf someone at Manning Publications is reading this, it would be great to have a book on the newer Nim version, but please consider using a different typesetting with more readable fonts. I purchased the great book by Dominik Picheta, but am forced to use the .pdf because the dead tree version uses thin fonts that I find extremely hard to read even with the right pair of glasses. Font components (arms, lines, stems, etc) are just too thin. Not being a youngster anymore, I naturally thought it was my fault and took the original K&R 2nd ed as a comparison, but still can read it perfectly.
- uticus 3y agoNot with Manning, but if you have a login you can submit this sort of request via their contact page: https://www.manning.com/contact https://www.manning.com/contact
- alwaysbeconsing 3y agoaraq/Andreas Rumpf, the project lead, has also published a book: https://nim-lang.org/blog/2022/06/29/mastering-nim.html https://nim-lang.org/blog/2022/06/29/mastering-nim.html
- pzo 3y agounfortunately there is no ebook version and it seems araq is against publishing ebook (probably because of worrying about piracy) - for me who is travelling a lot, hard copy is a no go.
- Tiberium 3y agoAraq has mentioned he'll create a new edition of the book for Nim 2.0, and publish it as an e-book, see https://forum.nim-lang.org/t/10366 https://forum.nim-lang.org/t/10366
- treeform 3y agoI wrote a post on how Reddit uses Nim: https://www.reddit.com/r/RedditEng/comments/yvbt4h/why_i_enjoy_using_the_nim_programming_language_at/ https://www.reddit.com/r/RedditEng/comments/yvbt4h/why_i_enj... More and more large companies and startups are adopting Nim. Super excited for Nim 2.0 and huge thanks to all who contributed!
- fuzztester 3y ago>More and more large companies and startups are adopting Nim. Ineresting. Are there any stats / data on this, or is it anecdotal? Even if anecdotal, can you name some names?
- ThomasTJdev 3y agoFor startups, you can count us in[1]. Our backend, across all services, is using Nim. [1] https://cxplanner.com https://cxplanner.com
- lairv 3y agoWhat's the experience of writing web backend with Nim ? Did you use existing libraries / framework ? How good is the concurrency compared to something like Go ?
- ThomasTJdev 3y agoOne of the reasons for choosing Nim was the ease of getting a production ready web backend. For the core part of managing the backend we are using existing Nim libraries [1], and they are easy to expand and work with. I cannot give you a comparison with Go since I haven't managed that large Go projects - but for Nim we are all into the async and threading. I think the channels within the threading is hardest part in Nim, but work is being done it. [1] https://nimble.directory https://nimble.directory [1a] https://github.com/dom96/jester/ https://github.com/dom96/jester/ [1b] https://github.com/planety/Prologue https://github.com/planety/Prologue [1c] https://github.com/guzba/mummy https://github.com/guzba/mummy
- LexiMax 3y agoThe last time I used the language, it was still using a garbage-collector and there were talks about transitioning towards a new way of doing things - I assume that ARC/ORC ended up being that destination. Now that ARC/ORC is considered "complete," are there any remnants of the old GC still in the language, or has the entire ecosystem hopped over?
- treeform 3y agoFor most of us the move from GC to Orc is pretty transparent. Most libraries just work and don't require any major restructuring.
- 127 3y agoNim is really very nice language to write software in. Ship fast, enjoy the ride, produce very performant software. Unfortunately it still in my experience has some sharp edges: juggling C/C++ compilers and options, very poor error messages, very situational libraries that only work on some settings and systems. Given the small community, tho, I can't really fault them for it. The VS Code integration works very well in my experience, rarely crashing.
- philkrylov 3y agoAt least error reporting has been improved recently: https://nim-lang.org/blog/2023/03/31/version-20-rc2.html https://nim-lang.org/blog/2023/03/31/version-20-rc2.html
- foderking 3y agothe shitty error messages and poor tooling are the biggest problems of nim imo. Its overall a great language otherwise
- Corsome 3y agoproc echoLine(): void = discard Discard looks cool! I'm Rust I had to use the unimpl macro crate [0] to get sane error messages. It would be good if that was build in though. [0]: https://crates.io/crates/unimpl https://crates.io/crates/unimpl
- pzo 3y agoHad a look a Nim few months ago - feature wise is a lot of I wish Python had (easy interop with C/C++, static typed, compiled, can be transcompiled and executed on android/iOS), but ecosystem is small even though the language is not new. There is not many high quality libraries such a numpy, scipy, pandas, opencv in python. They lack some big player adopting it - it's too bad Unreal Engine didn't try to adopt Nim instead of creating their own new scripting language Verse. One thing I'm also lucking is out-of-the-box interop with C/C++ libraries without creating own adapters (so that you can just import header and be done with it). Another thing is I wish it had similar easy interop with Rust - just to increase adoption and also because in Rust easier to find high quality cross-platform crates (including mobile) that work without hassle even on mobile devices. I worry in few years either Python will catch up (because of faster python, non-GIL, nuitka, briefcase for mobile etc) or Mojo will eat Nim lunch.
- treeform 3y agoTo be fair to Nim, only Python has the huge ML ecosystem of numpy, scipy, pandas, opencv, pytorch, tensorflow, keres... Doing ML/AI style work in anything but python is really hard! That said Nim does have the nimpy library that allows for pretty seamless interop with python. Which means you can just import PyTorch, or scipy, or opencv and use them in Nim.
- pzo 3y agofor me (mobile developer) interop with python is not enough because of really poor python story on mobile devices (iOS / android) when using native modules. I think if Nim had a seamless interop with Rust or even Zig it could piggyback on those communities to get some libraries for free.
- Xeamek 3y agoDunno about rust, but since both Nim and Zig compile to C as interim, it should be fairly easy to get them working together, no?
- 3y ago
- captn3m0 3y agoIs Nim 1 going to receive patches going forward? Or is it a hard upgrade?
- elcritch 3y ago1.6 should have a few years of support. Though 2.0 is largely compatible with older Nim code.
- himujjal 3y agoI loved Nim when I used it first. But I left it because of recursive imports. I had to basically put all my types into one file and use them from various others. For a relatively medium sized project (~10LOC), its a but of a hassle. Refactoring is an issue. That being said, the language is fantastic. Can anybody with experience suggest me what HTTP library/framework do they prefer for servers?
- elcritch 3y agoThe lack of recursive imports can be annoying, but I found I don't mind it. It keeps your module tree into a DAG. Chronos is probably the most feature rich and uses async. Mummy is newer and uses a threading model. Both are used in production.
- winrid 3y agoNode and Python also don't really work with circular imports.
- himujjal 3y agoPython doesn't work with circular imports. NodeJS does. After using NodeJS for such a long time, I think it is a feature that is taken for granted. That being said, the Nim team is working on it as per a few issues: [1] https://github.com/nim-lang/rfcs/issues/6 https://github.com/nim-lang/rfcs/issues/6 [2] https://forum.nim-lang.org/t/2114 https://forum.nim-lang.org/t/2114 I love the language, and this is probably the only bottleneck for me.
- winrid 3y agoNode really doesn't work with circular imports. There are runtime gotchas with it, for example destructuring a cyclic import via require() will give undefined for the destructured values as they "don't exist yet". Glad to see progress on the Nim side!
- haolez 3y agoIt seems almost too good to be true. Well done! Could someone share some bad experiences when adopting Nim so I can weight that in? I'm seriously considering it.
- j-james 3y agoI have a shortlist of pain points: - Tooling is not great. The language server has a tendency to silently crash on occasion, and it's no rust-analyzer to begin with. A tooling rewrite has been delayed behind proper incremental compilation, which has been delayed behind ARC/ORC... - Interfaces ("concepts") are experimental and there are two differing implementations. - It lacks proper sum types and structural pattern matching in the core language. There are a number of quite good macro-based libraries that provide for this, however: fusion/matching, andreaferretti/patty, beef331/fungus, alaviss/union... - Optional types are not the standard: the stdlib will throw exceptions. This is more so a personal preference than anything. But that's about it. I do like Nim quite a lot.
- ElegantBeef 3y ago> It lacks proper sum types We've talked about this before! You know it has sum types, just not the variation you want.
- j-james 3y agoI know, I know! I do very much like the "type wrapper" approach more than the "object variant" approach. Perhaps in the future we'll simply have both and have no reason to debate ;-)
- ReleaseCandidat 3y agoAs someone who doesn't know much about Nim: Improved type inference ... let foo: seq[(float, byte, cstring)] = @[(1, 2, "abc")] This looks like a normal type declaration to me, why is there any inference involved?
- elcritch 3y agoIt looks simple but in a typed language it's actually somewhat tricky. The compiler needs to infer that the 1 is a float type, 2 is a byte, and compile it appropriately. Previously Nim didn't do any "reverse" type inference so you'd need to say `@[1'f64, 2'byte, "abc")]`. That was because it's a constraints problem that can become exponentially expensive to solve. Exploding compile times in Rust and Swift are good examples of this. But there's limited subsets which can still be quick and are helpful like this case.
- ReleaseCandidat 3y ago> It looks simple but in a typed language it's actually somewhat tricky. But that example looks about as simple as it can be, so I clearly must miss something. > The compiler needs to infer that the 1 is a float type, 2 is a byte, and compile it appropriately. And I don't understand _why_ it has to infer anything, as the type is explicitly declared. I mean, there are 2 possibilities: * 1 is both a valid integer and a float literal => Nim needs the type declaration on the left to unify the type (from "integer or float" or "numeric" or whatever the type checker inferred) to `float`. * 1 is not a valid float literal (but an integer) => the type is not inferred, but implicitly converted to `float`. In both cases the solution does not involve inference?
- elcritch 3y ago> And I don't understand _why_ it has to infer anything, as the type is explicitly declared. The seq declaration doesn’t need to be inferred. However the right side does need to be inferred from the declaration. > I mean, there are 2 possibilities: * 1 is both a valid integer and a float literal => Nim needs the type declaration on the left to unify the type Yep, `1` is an ambiguous number literal. So the compiler needs to back the info from the type into the assignment expression. Not super hard to do for simple cases, but it can become expensive for complex types.
- sedatk 3y agoSo, Nim doesn’t seem to be under an umbrella of a non-profit. Isn’t this destined to be a problem at some point regarding either acquisition of rights or succession? Edit: Ouch. Just found this thread. Very disappointing, and actually makes a greater case for institutional ownership: https://forum.nim-lang.org/t/10312 https://forum.nim-lang.org/t/10312
- koromak 3y agoI find using main a little obnoxious, but like who cares that much?
- sedatk 3y agoI think "default" (Mercurial) is a way better name than anything else for the default branch, duh. But, I err on the side of the disadvantaged because it's impossible to fully empathize with their individual experience, so I try to use "main" whenever I can. That said, I'm a Slav which is the origin of the word "slave" because in Europe, slaves were predominantly Slavs once. I don't really mind it because it feels irrelevant today. Connotations of "master" doesn't feel that ancient yet though, considering that black people weren't allowed to live in Palo Alto, CA (heart of Silicon Valley today) until 1950's.
- mixmastamyk 3y agoRight, I found such changes silly as well, but this kind of anger is a bad sign. Sounds like someone watches too much corporate TV. If you can't handle a little silliness from humanity, might as well bow out now.
- djur 3y agoDespite the remark about confusing people over 50, a primary branch called "master" isn't exactly an unalterable ancient tradition in version control, either. "Trunk" was common in centralized VCSes. I had to get used to "master" and "main" is at worst a lateral move.
- skitter 3y agoWas about to bring up that thread. Having a dictator for life isn't a good combination with that dictator going on unprompted, unhinged rants.
- winrid 3y agoI dearly wish there was something like LibGDX for Nim. I have big Java projects I'd probably move over... scene2d is great for simple cross platform UIs.
- foresto 3y ago> Now one can define constructors and virtual procs that map to C++ constructors and virtual methods, allowing one to further customize the interoperability. I hope this will help with bindings for C++ libraries that have historically been tricky to wrap. For example, I would like to use Qt from a compiled language that's a pleasure to use, and this project looks promising: https://github.com/jerous86/nimqt https://github.com/jerous86/nimqt
- pshirshov 3y agoI like capability separation with tags, though typeclasses are weird, higher-kinded types are not supported and implicits are weird.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- snthpy 3y agoNice! Probably worth taking another look at Nim again. How is interop with Rust these days?
- JaDogg 3y agoNice, congratulations on v2.0. Shameless plug: I'm working on a programming language called Yaksha that is also inspired by Python like syntax, however, philosophy differs from nim. Please take a look and let me know what you think :) https://yakshalang.github.io/documentation.html https://yakshalang.github.io/documentation.html
- suby 3y agoJust as a general comment, the website is extremely hard to read at the default zoom, mainly due to the font size but also due to the lack of contrast on the background color and text color. The code samples in particular are very hard to read due to this.
- JaDogg 3y agoThank you. Will have a think. Question - does dark theme and light theme both have the contrast issue?
- suby 3y agoThe light theme is a little bit better. I usually don't have a problem with text without much contrast though, so you may want to get opinions other than mine. The main problem for me is the small text size.