8 ms·
Nim 1.2
- sergiotapia 6y agoIf you would like to see some simple to parse Nim code and get a feel for what a "1 month of experience during weekends" Nim looks like, check out my project: https://github.com/sergiotapia/torrentinim https://github.com/sergiotapia/torrentinim Nim is a very interesting language, with a lot of upsides. It just needs that killer framework to get the ball rolling and allow devs to solve business needs quickly. Once that's done I think Nim will grow a lot! Tiny binaries, static binaries, fast, low memory usage, macros, compiles to C.
- icedchai 6y agoI'm going to check it out this weekend... I'm very intrigued by what I see.
- MaxBarraclough 6y agoIt uses a rather primitive garbage-collector though, right?
- dom96 6y agoPrimitive in what sense? Nim has a soft real-time garbage collector which doesn't sound primitive to me. Actually Nim supports more than one GC including boehm so you really have a lot of choice here.
- sp33der89 6y agoIt really doesn't! It's GC story is pretty great, because you can choose out of several GC's, one of them being good for real-time systems: https://nim-lang.org/docs/gc.html https://nim-lang.org/docs/gc.html Recent versions also use this fancy thing: http://www.gii.upv.es/tlsf/ http://www.gii.upv.es/tlsf/
- MaxBarraclough 6y ago'TLSF' sounds very interesting, I'll have to keep an eye on that project. What are the reference-counting options for though, given the absence of weak references? Under what circumstances is it acceptable to permit memory-leaks in case of cycles? Short-lived processes (i.e. arena-based memory management)? When I say 'primitive GC', I mean Boehm, which is obviously decades behind the state of the art, but easy to get off the ground. GNU Guile uses it, for instance. Serious garbage collectors are tremendously complex, and are something less popular languages unfortunately tend to lack. I believe even D is miles behind Java. Can't say I know much about Go's GC. Edit Oops I misread, TLSF isn't a GC, it's an allocator. It sounds then like Nim doesn't have a proper real-time solution, does it? useRealtimeGC is actually a leaky reference-counting system?
- rayman22201 6y agoDid you see the parent comments about the new -gc:arc? It's suitable for hard real time. https://www.youtube.com/watch?v=yA32Wxl59wo https://www.youtube.com/watch?v=yA32Wxl59wo
- MaxBarraclough 6y ago> Reference cycles cause memory leaks, beware. It isn't acceptable to just permit memory-leaks in case of cycles. There's no way we'd ever see something like that in a serious JVM. Unless there's some serious machinery to provide assurances against reference cycles, of course. Which sounds like an interesting research project, come to think of it.
- beagle3 6y ago> It isn't acceptable to just permit memory-leaks in case of cycles. That's only in the new --gc:arc which is still somewhat experimental. The old gc, --gc:markandsweep IIRC, does detect cycles, and has a deadline schedule (i.e. you can tell it "I now have 5ms, collect as much as you can"); But it has per-thread heaps, which means passing data between threads often entails a copy. You also have --gc:boehm (no cycles, shared heap), and --gc:none (no gc, you should take care of freeing memory yourself).
- rayman22201 6y agoAs others have said, Nim has plugabble garbage collectors, some are quite advanced. In addition there is active work on a swift like reference counting, lifetime based memory management option. This will be suitable for hard real-time use cases.
- jjtheblunt 6y agoIsn't it announced here in this release : --gc:arc and linked explanatory video https://www.youtube.com/watch?v=yA32Wxl59wo https://www.youtube.com/watch?v=yA32Wxl59wo ?
- rayman22201 6y agoyup! That is the one :-)
- treeform 6y agoNeat project!
- totalperspectiv 6y agoVery excited to see gc:arc make it into stable.
- sergiotapia 6y agoFor the layman Nim dev, would you say "always use gc:arc" is a safe bet?
- dom96 6y agoDefinitely not. --gc:arc is still experimental.
- treeform 6y agoI would still try out --gc:arc on your programs. For mine it just runs without issue. But keep in mind if you do have issues you might have to create a bug report and wait for a fix. You would not reply on --gc:arc working. But it's fun to play around with. It's real now.
- deleted 6y ago[deleted]
- rayman22201 6y agoI would say gc:arc beta quality. Very usable for many programs, but needs more battle hardening. Please try it and send bug reports if you find them! That's how we improve!
- narimiran 6y ago> would you say "always use gc:arc" is a safe bet? This is the first release to offer `--gc:arc` so there are still some rough edges, but I would follow @treeform's and @rayman22201's advice from sibling comments: give it a try, it might work for you without any problems, and if not - report it. The long-term plan is to make it the default.
- nepeckman 6y agoThe collect macro is awesome, and way more idiomatic Nim than list comprehensions. Nim continues to hit the sweet spot between performance and developer ergonomics.
- predators372 6y agoOooo, wow collect looks so much cleaner. I can't wait to get home and play with it!
- adwww 6y ago> I can't wait to get home and play with it A. Where are you that you are not already at home?? And B. I wonder how many people are using nim at work, and what sort of workplaces that might be?
- ilaksh 6y agoB. https://github.com/nim-lang/Nim/wiki/Companies-using-Nim https://github.com/nim-lang/Nim/wiki/Companies-using-Nim
- alberth 6y agoI really with more people used NIM for web development. It really seems like the best of all worlds (e.g. perf, developer ergonomics, productivity, etc).
- nathancahill 6y agoI've been building and deploying Nim web apps for clients over the past couple years. The language is just getting better and better and the library environment is filling out nicely too (not to subtract from the stdlib, it's very complete too). It's been a really great experience. Also: available to hire if anyone is looking to work with Nim.
- alberth 6y agoAre you using Jester or another framework?
- nathancahill 6y agoLargely building microservices with the stdlib. Generating html frontends with htmlgen. Using karax for more dynamic frontends.
- nepeckman 6y agoI'm planning on trying out the new Prologue framework. Seems promising from the readme! https://github.com/planety/prologue https://github.com/planety/prologue
- dom96 6y agoBy far my favourite feature of this release, dark mode in docs: https://nim-lang.org/docs/lib.html https://nim-lang.org/docs/lib.html
- treeform 6y agoI feel like dark mode is a sign that people care. I think it's a user feature that is easy to do, but not done often. Mostly done by people who care. It brings so much polish to the experience.
- leadingthenet 6y agoIt can be done poorly as well, like in Facebook / Google apps on Apple devices. They feel very unintegrated into the rest of the OS.
- rattray 6y agoIt's not necessarily _that_ easy to do, especially depending on how your CSS was implemented (eg; do you use variables for all your colors, and do they have a sane, consistent, reversible brightness scale?) However, I certainly agree with your "you do this because you _care_" sentiment. Source: implemented dark mode for an application where the "sane css colors using variables" property was true.
- qqssccfftt 6y agoWhat if I care specficially not to add a dark mode?
- yjftsjthsd-h 6y agoWhy exactly would caring about users lead you to omit something that makes things nicer for them?
- SaxonRobber 6y agoMaybe the same reason why others choose to omit light modes, despite that being my preference.
- intrepidhero 6y agoI've been doing the nim track on exercism.io (no affiliation, just a user) for the last two weeks. The mentors on the track have been fantastic. If you're looking for a "solve a problem and get some external feedback" approach to learning the language it's pretty good.
- jjtheblunt 6y ago"exercism.io" is such a great name!
- mikebelanger 6y agoAh neat - thanks for sharing. I'm gonna try that out.
- zelphirkalt 6y agoPersonally I stopped using exercism, when it started to require me to work for Google for free and would not let me log in, if I did not. It's not an ethical platform, unfortunately.
- duxup 6y ago>it started to require me to work for Google for free How did that work?
- zelphirkalt 6y agoRecaptcha and tracking.
- ampdepolymerase 6y agoWould you pay monthly if they removed it?
- zelphirkalt 6y agoPerhaps I would. I've supported many projects in the past, so I think, if it was really good and did not violate my privacy, there is a fair chance I would.
- iimblack 6y agoDup is very interesting to me. Does that mean that in Nim all functions will be impure by default, and that it's considered idiomatic to modify the input? I guess it's nice that they're trying to make behavior consistent. It just seems like the opposite of the recent directions I've seen other languages take.
- jrhurst 6y agoI haven't played with nim for a few months, but only parameters with var will get mutated. I suspect you want to use someone else's cursed function and don't want to poison your blessed code
- iimblack 6y agoI see. I know nothing about Nim but I do see in their example they used var when declaring the function. This way seems like it's hidden to the consumer of the function but hopefully editor tooling helps with this.
- juki 6y agoYou have to declare the variable as `var` as well, eg. var arr1 = [4, 2, 3, 6] sort arr1 # Doesn't work let arr2 = [4, 2, 3, 6] sort arr2 You'll get a warning about the latter from the compiler (and nimsuggest for editors).
- treeform 6y agoMutating in place is often times faster and is more straightforward. I do feel Nim embraces mutation more than other recent languages.
- eindiran 6y agoYeah, the 'discard' keyword is a pretty cool way to note that you're using a procedure only for its side effects.
- 6y ago
- jakear 6y ago> If you were relying on some edge case and/or buggy behaviour which is now fixed, try if --useVersion:1.0 gives you back the results you expect to see. If that doesn’t work and you need the old behaviour, please open an issue in our bug tracker and we will try to make it work in future bugfix releases So useVersion doesn't simply checkout the old codebase, but they still promise to maintain all prior version's bugs? Seems like a losing battle to me... why not just tell people relying on version 1.0 behaviour to use version 1.0 and create tooling to make sure switching between versions is easy (a. la. nvm)?
- _0ffh 6y agoMy impression was that using "choosenim" switching between versions is easy already, but I might be missing something.
- rayman22201 6y agochoosenim is still supported :-) The idea is more like the gcc -std flag (gcc -std=gnu++11 for example). to emulate certain versions to ease upgrading.
- jakear 6y agoDo you think the gcc -std flag would exist if every distribution of gcc included a command to easily download alternate versions and swap them out depending on project configuration? -std seems more like a bandaid around a difficult install/config than a feature, in my opinion. Obviously nim is free to make implement whatever options they want, but it seems to me like every second spent triaging/fixing/etc bugs about not properly maintaining broken things (not to mention the end user time spent experiencing them and debugging them!) is time that could be better spent improving the language.
- rayman22201 6y agoDepends on your organization more than tooling. Even if you have the tool, your orgs security policy may not allow using it. You may not have an environment that allows switching compiler versions for other reasons. Even Rust has a similar concept that allows gating of features like this. They call it "editions".
- iffycan 6y agoAmong other great additions, I like the addition of compilesettings [1], which will give programs more visibility into how they were compiled. [1] https://nim-lang.org/docs/compilesettings.html https://nim-lang.org/docs/compilesettings.html
- wmock 6y agoAs someone who's heard of Nim, can someone who's used it tell me a little bit more about its benefits and how it compares to other common languages like JavaScript, Python, etc?
- rayman22201 6y agoThe major features are: Python like syntax, Lisp like macro system, potential for C like performance (YMMV of course). This is my person opinion here: Nim is part of the "new generation of system programming languages" from the last decade or so. Some other examples in this category include Zig, D lang, Go lang, Swift, Rust, etc... The whole idea is to provide "modern high level" language features and ergonomics while still producing efficient low level code. For Pythonistas, The familiar syntax is attractive to Python programmers looking for a more performant language (data science is a prime example.) Nim is also attractive to lispers looking to move to a more traditional Algol or C like language while still keeping much of power and flexibility that they are used to from macros.
- hartator 6y agoVery bullish on Nim. It's Python with C-level performance.
- war1025 6y agoIrrelevant, but I spent the entire day reading this headline as NVim, i.e. Neovim. These comments make a lot more sense now.
- rattray 6y agoDoes Nim have an ORM or querybuilder as good as SQLAlchemy yet?
- pietroppeter 6y agoThere is [Norm](https://github.com/moigagoo/norm https://github.com/moigagoo/norm) that goes in that direction. [ormin](https://github.com/araq/ormin https://github.com/araq/ormin) takes a different twist
- dzonga 6y agohope they nim developers, port a lot of python data science tools e.g pandas, numpy etc so they can increase adoption in the language. Julia is supposed to fill that space, but feel strongly nim is better positioned
- rayman22201 6y agoThis is definitely being worked on (slowly but steadily) and the initial results are very impressive. See: https://mratsim.github.io/Arraymancer/ https://mratsim.github.io/Arraymancer/
- eigenspace 6y agoOut of curiosity, what do you feel makes Nim better positioned in this space?
- juststeve 6y agoarrays start at 0?
- eigenspace 6y agoI know I shouldn't feed these sorts of trollish remarks, but if it really bothers you, you can always just use https://github.com/JuliaArrays/OffsetArrays.jl https://github.com/JuliaArrays/OffsetArrays.jl
- rayman22201 6y agoAs I said in another comment, the familiar python like syntax, while having the potential for much better performance. Many data scientists are familiar with Python. They can write similar code and will run much faster by default (or with very little tweaking). Then, if that's not fast enough, The language is positioned such that you can optimize the code to a much higher degree than you can with Python. I'm not saying that Python code can't be optimized, but there is a limit to the speed of python code even with optimization. At some point you have to drop down to a C extension (what Numpy, Pandas, etc... does) and then you are just writing glue code in Python to drive the C. You could also use one of the Python optimized compilers, but that has limits and edge cases as well. There is "developer friction" there. In Nim you can just have the whole program in one language. The program can be optimized to the same level as optimized C code with no special tools. This is much less friction. What's missing is the libraries. But that will come with time.
- flywind 6y agoNice!
- rishav_sharan 6y agoI am currently working on a tiny game in nim using Raylib. I had some initial friction with Nim, but i like using the language now. You'll do well to stop trying to use Nim as an oops language and just use it as a better C. The language syntax is clean, and the std lib has all that I need. One bit which I still hate is simply how imports work in Nim. My project pretty much has a header like file containing function and variable signatures which can be called from other files. For someone used to modern languages, it just feels so archaic. But overall it is still a fantastic language and I am excited to try the ARC gc
- dom96 6y ago> One bit which I still hate is simply how imports work in Nim. My project pretty much has a header like file containing function and variable signatures which can be called from other files. You mean how `import` works or are you using `include`? If the latter then I would strongly discourage you from using it. As for the former, you can use `from module import nil` everywhere if you really want.
- DeathArrow 6y agoNim might be great. But how can a great language get traction if nobody big is behind it? Java and Python are being pushed by Silicon Valley and universities, Go is being pushed by Google, Kotlin is being pushed by Google, C# is backed by Microsoft and some big companies. Who can help Nim, or Crystal, or Rust or other new language? I look at many of them from time to time, see interesting developments, see exciting things but I refuse to learn the languages, their ecosystem and frameworks from the fear I have I will lose lots of valuable time since I might not be able to earn my living using them.
- moonduster 6y agoSurprisingly, a lot of large companies use Rust in-house. I work at Nando's, one of our biggest systems is in Rust, and we're a chicken restaurant business, so it's not just limited to bleeding-edge SV companies. Hoping we can open-source some of this stuff in the near future too to kind of show the world that Rust is ready.
- steveklabnik 6y agoThis is very intriguing! I hope you can too. Let me know if I can help in any way!
- matdehaast 6y agoThats awesome to hear! Would love to learn more. I assume you are part of the South Africa Nando's group...
- chris_j 6y agoPlease tell us more - I'd be really interested to hear what system it is and to learn about your experiences.
- klohto 6y agoRust is being adopted by Apple so I wouldn’t worry about it.
- 6y ago