Live data from Hacker News

Nim: Scripting Ease in a Compiled Language

junglecoder.com

11–20 of 169 posts

Re: Nim: Scripting Ease in a Compiled Language

#11
post #3

Is there anyone using Nim either in side projects or in production that can comment on how they like it? I keep hearing about Nim and it sounds interesting, but I'm not sure I have the mental capacity right now to do a deep dive into the language and build something with it. I'd like to at some point soon though.

I use Nim in production. I been using it for more than 1 year in production.

I like it. For me, it started out as a faster python that prevents typos. But it has really grown on me. I really like that I can share libs on server (compiling to c) and client side (compiling to plain javascript).

Basically any C library is also a Nim library with a tiny wrapper. That's a huge ecosystem! I also like how Nim can integrate with complex C++ libs that do virtual table call backs. It can also call objective-C functions .. you know the ones with [foo a:1 b:1] crazy syntax? Python was a glue language for me, but Nim can just glue more things.

JS too! In Nim you can just compile to plain JS, that other JS can call as well. Pass plain JS objects around. I basically replaced my JS code file by file - there was no need for a huge rewrite.

I know docker and kubernetes is "the thing" right now, but I just like that I can just scp the binary over. It just feels less complex. I feel like docker solved the distribution problem for python and node... I just don't have a problem to solve any more. It's just gone.

Re: Nim: Scripting Ease in a Compiled Language

#12

Looks cool already but is it easy to cross-compile? I can copy a Python script from my Linux machine and run it on both Mac and Windows PCs. Can Nim build executables for other platforms nearly as easy?

Well, you sorta can. As long as you wrote it:

* to work in both Python 2 and 3 (no telling what other system's Python will be) * don't use any modules outside of stdlib (that requires install too)

Those aren't always requirements, but they are the reason I reach for compiled languages when I can't control the target environment where the program needs to run (or don't want to).

Re: Nim: Scripting Ease in a Compiled Language

#13
post #8
post #4

Earlier quoted context omitted.

I've used Nim a bit for side projects (on and off, even back when it was called Nimrod). I found it really really powerful once I got past the initial bump. It's a fairly small learning curve to be honest, especially if you're familiar with reading Python. What I love about it is the small binaries.

Can the binaries be statically compiled similar to go?

yes

Re: Nim: Scripting Ease in a Compiled Language

#14
Shameless plug - I interviewed Andreas, the creator of Nim, about his philosophy and design choices here: https://sourcesort.com/interview/andreas-rumpf-on-creating-a...

Might be an interesting read for people who are thinking about using Nim and wondering how it compares to the C family, Python, Go, etc.

Re: Nim: Scripting Ease in a Compiled Language

#15
post #3

Is there anyone using Nim either in side projects or in production that can comment on how they like it? I keep hearing about Nim and it sounds interesting, but I'm not sure I have the mental capacity right now to do a deep dive into the language and build something with it. I'd like to at some point soon though.

I ported a smallish script I use at work (~300 lines or so) from Python to nim fairly easily since the syntax is similar. Being able to compile a small binary across several platforms is nice, though the particular library I used wouldn't compile on Windows using nim 1.0, despite supposedly working in earlier versions (the bugs appear to be in Nim's Windows support, not the library).

The biggest downsides right now as compared to Python are the overall lack of libraries, and lack of documentation (the core language is reasonably well documented, 3rd party libraries much less so).

Re: Nim: Scripting Ease in a Compiled Language

#16
post #3

Is there anyone using Nim either in side projects or in production that can comment on how they like it? I keep hearing about Nim and it sounds interesting, but I'm not sure I have the mental capacity right now to do a deep dive into the language and build something with it. I'd like to at some point soon though.

I've used Nim for most of my personal projects for the past ~2 years, and it's generally enjoyable. There are a lot of useful language features. C interop, generics, tagged unions (I always miss these in languages without them), traits (powerful duck typing), channels, generators. Metaprogramming via templates/macros if you want to get crazy. Lots of rope to hang yourself, so to speak. I wouldn't choose to use it in…

Have you checked the latest documentation recently? There has been some really good work in the past few months to improve all these areas.

What doc issues are the biggest pain points for you right now?

(Getting good error messages for macros and meta-programming is notoriously hard, but we are trying!)

Re: Nim: Scripting Ease in a Compiled Language

#17
Is Nim stable? I have vague memories that some parts of its runtime had some deep issues that weren't yet resolved, like maybe around concurrency? I see the language is at 1.0 now, does it have a stable, solid, dependable implementation and runtime?

Re: Nim: Scripting Ease in a Compiled Language

#19

One thing I find annoying about Nim is the case insensitivity [0]. There was no strong reason for this "feature" and literally no mainstream language does it. Moreover it makes code search a pain. [0] https://nim-lang.org/docs/manual.html#lexical-analysis-ident...

You can use nimgrep [0] to find symbols that match each other with case insensitivity, but yeah it is unusual.

[0] https://nim-lang.org/docs/nimgrep.html

Re: Nim: Scripting Ease in a Compiled Language

#20
post #3

Is there anyone using Nim either in side projects or in production that can comment on how they like it? I keep hearing about Nim and it sounds interesting, but I'm not sure I have the mental capacity right now to do a deep dive into the language and build something with it. I'd like to at some point soon though.

I used Nim for my implementation of Make A Lisp[1]. I use Python every day and the jump was pretty straightforward. Almost copy and paste from some things. I don't have to think about static types much, but it was a welcome change. I loved having macros to play with, too. I spent a lot of time with docs which aren't bad.

As for the "mental capacity" I felt the same about finally getting into Rust. Spending some time with Nim actually helped me bridge the gap from Python to Rust.

[1] https://github.com/kanaka/mal

Post reply on HN