10 ms·
Even though I haven't taken it out for a spin just yet, I've gotten a good impression of nim. Anybody out there who has tested that can say if my hunch is right
by rijoja 8y ago
Even though I haven't taken it out for a spin just yet, I've gotten a good impression of nim. Anybody out there who has tested that can say if my hunch is right or not?
- qaq 8y agoplayed with it a bit the lang is really nice but lib support for things I needed was lacking. e.g. async PostgreSQL driver. Has good c interop though.
- tokai 8y agohttps://github.com/cheatfate/asyncpg https://github.com/cheatfate/asyncpg
- qaq 8y agoyou seriously proposing to use a db driver in prod that has 1 contributor and was abandoned more than a year ago?
- tokai 8y agoI wasn't proposing anything. I dropped a link with relevant content to your post. It was as much aimed at readers of your comment as it was aimed at you. Please turn down your scorn.
- jamespo 8y agoMaybe you could contribute to it
- qaq 8y agoPretty far from my area of expertise. BTW. I have 0 expectation that someone has to solve my problem but when looking at a lang to me the minimum req. are good PG support and decent http lib which is obviously not the requirements people actively working on Nim have.
- mratsim 8y agoNim forum is written in pure Nim[1] and is using httpbeast[2] as a backend. [1]: https://github.com/nim-lang/nimforum https://github.com/nim-lang/nimforum [2]: https://github.com/dom96/httpbeast https://github.com/dom96/httpbeast In terms of features it's powerful enough to build a Discourse-like forum enough. In terms of performance it's very well performing in the TechEmpower benchmarks[3] it is competing in. It even grabbed first place on JSON serialization on Cloud hardware. [3]: https://www.techempower.com/benchmarks/#section=data-r17&hw=cl&test=json https://www.techempower.com/benchmarks/#section=data-r17&hw=... and https://forum.nim-lang.org/t/1152#27100 https://forum.nim-lang.org/t/1152#27100
- qaq 8y agoOK english is not my native lang so maybe I am not formulating things clearly I did not try to suggest that nim does not have good http lib. I was just saying my 2 core requirements good http lib and high quality mature PostgreSQL driver. Nim has good Http lib Nim does not have async PG driver that I would feel confident using in prod.
- vram22 8y agoThe D forum is also written in D (it's called DFeed, IIRC), and it's fast (anecdotally).
- mratsim 8y agoPlease note that cheatfate is one of the most prolific Nim contributors and is also working in Nim as a full-time job at Status[1]. He is also the main author of an asyncdispatch hardfork[2]. I.e. any issue you might have with the lib can be raised and addressed fast. Disclaimer: he is also my colleague. [1]: https://github.com/status-im?utf8=&q=&type=&language=nim https://github.com/status-im?utf8=&q=&type=&language=nim [2]: https://github.com/status-im/nim-asyncdispatch2 https://github.com/status-im/nim-asyncdispatch2
- qaq 8y agoGood to know this prob a workable option for non-critical path tools then.
- Boxxed 8y agoI found the same thing. There are oddities in the non-async library too -- for example, rows are returned as a tuple without any column metadata, so you can't do a "select *" because you don't know the column order. I think all types get stringified too, which is weird. The core language is interesting, but like the standard library has an odd edge here and there.
- qaq 8y agoI am sure it will be addressed as ecosystem matures. In general lang is very elegant and I would love to use it when it matures.
- thatsaguy 8y agoNim is actually great. The syntax is streamlined and you can pick it up in a few hours if you have some basic experience with python. Because it's effectively a transpiler and it's way less opinionated than (say) Rust, I managed to use nim in embedded controllers without any special support from the compiler. Nim suffers because it doesn't have the big push of a corporation such as Mozilla behind.
- rijoja 8y agoCool! I'm working on a project that uses javascript and a C backend so it actually might be a good fit for me.
- mratsim 8y agoHere is an example of such for neural network training[1]: - Nim JS for browser display - Nim C as a backend [1]: https://github.com/Vindaar/NeuralNetworkLiveDemo https://github.com/Vindaar/NeuralNetworkLiveDemo
- alehander42 8y agoIt might be indeed: e.g. I've implemented validation for game moves before for a web game, and reusing everything on the backend and frontend was nice
- jibal 8y ago" A source-to-source compiler translates between programming languages that operate at approximately the same level of abstraction, while a traditional compiler translates from a higher level programming language to a lower level programming language." In other words, Nim is not a transpiler, it's a compiler that outputs C or Javascript. But the difference is just in terms of the readability and modifiability of the output. For the purpose of using it in embedded controllers, the difference doesn't matter, it's the fact that it generates C code that is of value. And yes, Nim is vastly less "opinionated" than Rust, thank goodness.
- dom96 8y ago
- narimiran 8y ago> I've gotten a good impression of nim. Anybody out there who has tested that can say if my hunch is right or not? I've started using Nim couple of months before last year's Advent of Code, after I've been reading about Nim both here and on Reddit. As a Python user, I was immediately drawn to Nim's elegant syntax, which looked to me like "ok, just copy-paste my Python code, and declare some variables, and voila: 10-100x faster Python!", which is 80% true. The remaining 20% were "this works in Python, why doesn't work in Nim?" questions, which were promptly answered by the great Nim IRC community. I soon realized that those differences are what makes Nim great, and I began to really like the language. I decided to solve AoC 2017 in both Python and Nim [0] so I could directly compare my solutions. This was a great experience for me, and I've learnt a lot. In the past year I started using/liking Nim more and more (I have used Nim even at my work (numerical calculations, before done in Numpy)). This year I'm gonna solve AoC solely in Nim. From my experience, your hunch is right. If you have any Nim questions, let me know. [0] https://github.com/narimiran/AdventOfCode2017 https://github.com/narimiran/AdventOfCode2017
- baldfat 8y agoThank you. That is the best answer to comparing languages I have seen by looking at your two codes. I never really thought of Nim as being that close to Python in syntax but seeing the two codes together I saw how you were able to achieve that and it was really insightful.
- alexeiz 8y agoFor me, Nim feels closer to Pascal than Python. They even say so on the "features" page: "Pascal-inspired type sections for leaner definitions."
- gameswithgo 8y agoI enjoyed it quite a bit while playing with it about a year ago. The compiler had some bugs and the language spec had some rough edges that turned me off a bit, but I've also noticed in the year since that most (all?) of the issues I ran into got fixed. So that is promising! They have gotten a bunch of funding since then too so progress may accelerate.
- aepiepaey 8y agoLast time I was going to try it, I got sidetracked reading up on rules for identifier equality, prompted by noticing that the nim package bundled its own grep (nimgrep). Basically, Nim ignores case (except for the first character) and underscores in identifier names, so the following is a valid Nim program and all those names refer to the same variable: var myVar = 1 my_var = 2 mYVAR = 3 echo(myVAR) Most people wouldn't actually write code like that, but I personally found it to be a turn-off. More on this: https://nim-lang.org/docs/manual.html#lexical-analysis-identifier-equality https://nim-lang.org/docs/manual.html#lexical-analysis-ident...
- BoppreH 8y agoI personally think it's a great idea. Much better than having a code base with mixed camelCase and snake_case because a library didn't follow the language convention. I've seen people write wrappers just to fix casing.
- joelthelion 8y agoA much better solution is to have a language-wide style guide, with a tool such as "go fmt" to enforce it.
- alehander42 8y agoInterop with C/JS: you can't control all identifiers, because you can reuse a rich ecosystem of other language libs: you can't force their names to change EDIT: you can still change them in importc pragmas, but this still seems less nice to me. Still, you can reuse Nim libs even if they don't follow nep1: one can still use nimpretty/gofmt for his own codebase.
- pelario 8y agoCan somebody explain why would anyone consider this a good idea? I'm honestly puzzled.
- 8y ago
- rohansingh 8y agoI tried to use Nim in an embedded context (ESP32). Since one of the bullet points is that it "compiles to C", I thought it'd be a good option. In practice, even once I was able to compile basic Nim, there were a lot of glibc and other POSIX dependencies for any of Nim's standard libraries, some of which weren't available in ESP-IDF. That's totally fair, but many of those dependencies aren't available when compiling to JS either, though, so I was surprised. In the end, delving into the code I found that a lot of stuff was gated behind the equivalent of "platform=JS" switches throughout the stdlib. It seemed like adding support for another platform would be a major pain. This was all preliminary investigation and I didn't reach out to the Nim community, so perhaps I missed something. Maybe this kind of portability isn't even a goal for Nim. It would definitely be nice to have, though.
- mratsim 8y agoYou need to pass --gc:none when compiling so that the compiler warns you when you try to use a garbage collected type and instead of the stdlib, use the SDK facilities. Here are some libraries for embedded you can get inspiration from[1]: - msp430f5510 - Run Nim on MSP430f5510 micro-controller (6KB of RAM).[2] - stm32f3 - Run Nim on STM32F3 micro-controller (16KB of RAM).[3] - ardunimo - Nim wrapper for Arduino + LinkIt ONE SDK by Mediatek.[4] - ardunimesp - Nim wrapper for Arduino ESP8266 framework + A tool for flash, compile and make the nim project into an Arduino project.[5] [1] https://github.com/VPashkov/awesome-nim#embedded https://github.com/VPashkov/awesome-nim#embedded [2] https://gitlab.com/jalexander8717/msp430f5510-nim https://gitlab.com/jalexander8717/msp430f5510-nim [3] https://github.com/mwbrown/nim_stm32f3 https://github.com/mwbrown/nim_stm32f3 [4] https://github.com/gokr/ardunimo https://github.com/gokr/ardunimo [5] https://gitlab.com/NetaLabTek/Arduimesp https://gitlab.com/NetaLabTek/Arduimesp Also, yes abstracting a platform is a lot of pain but Nim accepts PR even for niche platforms like Haiku, Genode and Nintendo Switch. Also with the upcoming destructors, the standard library will be GC-free so much more will be usable on embedded.
- rohansingh 8y agoYeah, I tried --gc:none. After some playing around, I ended up with: --gc:stack --header:"nim.h" --os:standalone --noMain --genDeps In the end I got Nim code to run and was able to do a "hello world". As a hack I also used -d:android to trigger some conditionals that reduced the reliance on various dependencies. But it wasn't enough to be usable, and it was a bit unfortunate to have to do that. Looking at those projects you linked though, clearly I didn't try hard enough! Great to see that people have had success.
- curioussavage 8y agoI really enjoy nim. Using it in two projects now. I write Python and typescript at work so nim gives me the syntax I like from python with the type safety I miss from typescript plus cool stuff like macros.