Live data from Hacker News

Nim 1.6

nim-lang.org

91–100 of 179 posts

Re: Nim 1.6

#91
post #62

I learned Nim last year by rewriting some of the core Arduino functionality in C, and then wrapping them in Nim. (I also wanted to better learn C and better understand how Arduino's internals work, thus the convoluted approach) A few observations: * The community was very helpful and responsive. I identified a bug in compiling Nim to bare metal C, and it was fixed in 24 hours. * The C/Nim bindings were a breeze to us…

Oh it definitely can run on those devices! I wrote my own keyboard firmware from scratch in Nim, and the firmware sizes are vanishingly small compared to even simple "hello world" level stuff in Arduino. I did a talk on it for NimConf2021: https://www.youtube.com/watch?v=dcHEhO4J29U

This is great!

I've wondered if Nim could be the foundation for a sort of "next-generation" Arduino. It's easy to learn, compiles to small binaries, and can wrap a ton of existing C code.

My experiments taught me wrapping Arduino from scratch, while possible, might not be ideal. There's some cruft in that code base, and the abstractions could use some updating.

Re: Nim 1.6

#92
post #82
post #52

Earlier quoted context omitted.

JS is also great for scripting, but really isn't popular for ML or data science (no pandas/numpy/scipy equivalents I think, other than tensorflow.js). I'm curious how Nim fares for DS/ML.

Nim has a popular ML library "inspired by Numpy and PyTorch": https://github.com/mratsim/Arraymancer One of the advantages of the language for DS/ML is the native "C like" performance with very low developer friction. Another advantage from a library perspective is being able to automate fast, low level boiler plate code from easy to use DSLs using AST macros. For example a DSL could generate bespoke code for differe…

Nice! That definitely sounds enticing.

Re: Nim 1.6

#93
post #62

Earlier quoted context omitted.

Oh it definitely can run on those devices! I wrote my own keyboard firmware from scratch in Nim, and the firmware sizes are vanishingly small compared to even simple "hello world" level stuff in Arduino. I did a talk on it for NimConf2021: https://www.youtube.com/watch?v=dcHEhO4J29U

This is great! I've wondered if Nim could be the foundation for a sort of "next-generation" Arduino. It's easy to learn, compiles to small binaries, and can wrap a ton of existing C code. My experiments taught me wrapping Arduino from scratch, while possible, might not be ideal. There's some cruft in that code base, and the abstractions could use some updating.

There is definitely room for this, it just needs somebody passionate enough to write a nice Arduino/embedded framework and document/promote it well.

Re: Nim 1.6

#94
post #75
post #58

What's the state on: - web frameworks / servers ? (ie. is there something like Sanic that is actively maintained ?) I imagine it's too early for a consensus. - database drivers ? (postgresql is important here. I can live without an ORM)

There is plenty of web frameworks and servers, each with differing maintenance levels. You can for example check out Jester[1] and HttpBeast[2] (shameless plug, I wrote these :)). 1 - https://github.com/dom96/jester 1 - https://github.com/dom96/httpbeast

Thanks !

I see jesper's Request has its body as a string. How would you manage (very) large request body ?

Re: Nim 1.6

#95

I started looking at Nim a few months ago, but I didn't like the feature where it ignores underscores and capitalization. It seems to me that this would make grepping harder on larger projects. I suppose a linter or style-guidelines-and-not-making-mistakes invalidate this issue. For anyone that has used Nim, has this been a problem in practice?

I've been using Nim for hobby programming for a few years now. I'm maintaining the Norm package, it's an ORM for SQLite and Postgres. Not a huge project but not a hello world either.

Style insensitivity has never caused a single problem for me. Honestly, this is the most unimportant language feature, I don't get why it causes such fuss every time Nim is mentioned.

Re: Nim 1.6

#96

Earlier quoted context omitted.

I have decided that meaningful whitespace is an anachronism. 20 years ago, I liked it a lot . Today, after the invention and normalization of opinionated autoformatters, it means that the autoformatter can't figure out for me how my code should be indented. Which means that, assuming I am using an autoformatter, it creates one more thing that I have to do manually, because the editor can't accurately do it for me. An…

Some counterpoints: Your auto formatter can’t figure out where you missed braces either. Missing brackets in languages where they are optional for single statements (C) has been a source of serious bugs. Also, in Vim, indenting/dedenting a block is just highlighting the lines and using > or <.

> Missing brackets in languages where they are optional for single statements (C) has been a source of serious bugs.

This is why, in languages where they are optional, a good autoformatter will automatically insert them. If you've got it set to run every time you save the file or run tests, it's likely to do so long before you have a chance to produce the next Heartbleed.

It's not perfect, of course, but it's as good a protection against this sort of thing as I've ever seen.

> Also, in Vim, indenting/dedenting a block is just highlighting the lines and using > or But, excluding plugins (which aren't available/consistent across all the editors where I use a vim editing mode), I don't know of a quick vim command that lets me quickly select, delete, replace, yank, or change the full contents of a scope in a whitespace-sensitive language. Or quickly jump to the beginning or end of the current scope. Stuff like that. Versus, with curly brace languages, vanilla vim gives me an experience that approaches the ease of paredit.

Re: Nim 1.6

#97
post #71

Earlier quoted context omitted.

I can't remember exact place where I've seen this discussion (I think it was on the nim IRC), but if I recall correctly, the original line of thought with nim was to take C (because fast/compiled/available-everywhere) and LISP (because flexible/extensible/good-ideas) and add more syntax sugar, so that user would not have to reimplement most of the syntax from scratch (using reader macros/special functions and so on).…

Indeed, in fact the original line of thought was[1]: > [combining] Lisp's power with Python's readability and C's performance. I'd say Nim still satisfies this very well. 1 - https://web.archive.org/web/20110704041631/http://force7.de/...

Interesting, I think Julia was close to that too:

> We want a language that's open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that's homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.

https://julialang.org/blog/2012/02/why-we-created-julia/

Re: Nim 1.6

#98
post #38

Earlier quoted context omitted.

> who needs interpretation when compile times are that fast! Well, interpretation is pretty useful for a REPL. And a REPL is not just useful to avoid compilation, but also as a way to explore a new API. And, most importantly, to preserve the results of long computations when you do not know yet what to do with it. If computing a value takes half an hour, you certainly don't want to recompute it each time you change s…

> don't want to recompute it each time you change something True... May I introduce you to the filesystem?

Wow, what a great invention I have been missing! You made my day! :-)

Re: Nim 1.6

#99
Maybe a year and a half ago I put myself towards learning Nim. My learning project was a basic REST API backend written using the standard library.

I found the lack of IDE support very painful. On top of that, I ran into places where the documentation was out of date or just incorrect. After a few weeks of painful, slow going, I turned my attention to GO instead and haven't looked back.

Re: Nim 1.6

#100

Earlier quoted context omitted.

Some counterpoints: Your auto formatter can’t figure out where you missed braces either. Missing brackets in languages where they are optional for single statements (C) has been a source of serious bugs. Also, in Vim, indenting/dedenting a block is just highlighting the lines and using > or <.

> Missing brackets in languages where they are optional for single statements (C) has been a source of serious bugs. This is why, in languages where they are optional, a good autoformatter will automatically insert them. If you've got it set to run every time you save the file or run tests, it's likely to do so long before you have a chance to produce the next Heartbleed. It's not perfect, of course, but it's as good…

> I don't know of a quick vim command that lets me quickly select, delete, replace, yank, or change the full contents of a scope in a whitespace-sensitive language.

I'm sure there are better ways, but you could v9G$ to select from the current line to the end of line nine. Or v9j select the next nine lines, v9k previous nine, etc.

Post reply on HN