Live data from Hacker News

Nim 1.6

nim-lang.org

21–30 of 179 posts

Re: Nim 1.6

#21

> Why use Nim? > One language to rule them all: from shell scripting to web frontend and backend, scientific computing, deep learning, blockchain client, gamedev, embedded, see also some companies using Nim. Does that work in practice? I can't really imagine a single language that would be a good choice for "everything".

Adjacent comment already has a list of concrete libraries/frameworks for large number of areas, so I just want to mention that nim has a very good metaprogramming capabilities, and if the /language/ itself does not feel up to the task you have a lot more freedom when it comes to implementing things. So it really comes down to the community size and amount of money poured in the development, and not fundamental problems with the language design.

This is mostly an argument about "technically you can write anything with anything", except in nim's case it is also backed by extremely high flexibility.

EDIT: by flexibility I mean

- different backends they covet very huge ecosystems (Js and C, and by extension anything they you can interface with using C (like python))

- already mentioned metaprogramming

- support for low-level convenience features like custom operators

- different memory management options. If you want you can turn off automatic mm completely and write code that deals with pointers and stuff like that directly

- more niche things like support for embedding nim interpreter in your programs https://peterme.net/using-nimscript-as-a-configuration-langu...

Re: Nim 1.6

#22

> Why use Nim? > One language to rule them all: from shell scripting to web frontend and backend, scientific computing, deep learning, blockchain client, gamedev, embedded, see also some companies using Nim. Does that work in practice? I can't really imagine a single language that would be a good choice for "everything".

Yeah, these kind of statements feel very “empty” to me. That’s probably true that you could do everything with Nim, it’s also true that you can do everything with every language. Should you? That is another question.

You say "empty", but each of the listed uses links to a project as evidence, and the claim is followed up with specific evidence about small binaries, fast compile times, native performance, multiplatform targeting, etc.

Given all that, what are you still looking for to make the statement non-empty?

Re: Nim 1.6

#23

> Why use Nim? > One language to rule them all: from shell scripting to web frontend and backend, scientific computing, deep learning, blockchain client, gamedev, embedded, see also some companies using Nim. Does that work in practice? I can't really imagine a single language that would be a good choice for "everything".

Well no language is perfect, but Nim can be used in almost every domain because of it's compilation targets(C, C++, JS) and it's fast compile times(who needs interpretation when compile times are that fast!): * Shell scripting, I still assume most people will just use Bash tho: https://github.com/Vindaar/shell * Frontend: https://github.com/karaxnim/karax or you could bind to an existing JS library. * Backend: For so…

I haven’t used nim outside of some hello world toying a few years back. Is compiling actually that fast? I thought the nim compiler compiled to C and then called gcc (or whatever system compiler), isn’t that slow in practice?

Any large nim projects that anyone can point me to would be helpful too, I’ll give the compiler a shot later today!

Re: Nim 1.6

#24
How to run those benchmarks?

At that Nim release page:

https://nim-lang.org/blog/2021/10/19/version-160-released.ht...

Is link to this benchmark:

https://web-frameworks-benchmark.netlify.app/result

Where nim is 2nd with 200k req/s, but it is using httpbeast:

https://github.com/dom96/httpbeast

That says it would be more useful to use jester:

https://github.com/dom96/jester

Jester has 150k req/s.

But, when looking at these:

https://www.techempower.com/benchmarks/

drogon, actix etc has about 600k req/s .

Also redbean has about 600k req/s, when I tested:

https://redbean.dev/

I tested like this:

git clone https://github.com/wg/wrk.git

cd wrk

make

./wrk -H 'Accept-Encoding: gzip' -t 12 -c 120 http://127.0.0.1:8080/

When I tested https://caddyserver.com v2, it did show about 800k req/s.

It would be very helpful to know how those benchmarks are actually done, so that I could compare what is actually fastest in real world, and not just use some for benchmark tested winning non-realistic code.

Re: Nim 1.6

#25

Earlier quoted context omitted.

This way you can write json literals in the code, and it will look just like regular json. For serialization and deserialization stdlib uses `to/load/store` proc names. import std/json echo %*{ "key1": "value", "key2": 12, }

Could have just used a "JSON" keyword instead. Symbolic names are needlessly obscure and unfriendly. Hard to infer meaning, hard to pronounce, hard to search online, etc.

As if "json" is any more searchable. Operators have a meaning that you learn quickly when learning the language. You wouldn't do math with "multiply" instead of "*", so why would you want that in a programming language?

Re: Nim 1.6

#26

> Why use Nim? > One language to rule them all: from shell scripting to web frontend and backend, scientific computing, deep learning, blockchain client, gamedev, embedded, see also some companies using Nim. Does that work in practice? I can't really imagine a single language that would be a good choice for "everything".

Adjacent comment already has a list of concrete libraries/frameworks for large number of areas, so I just want to mention that nim has a very good metaprogramming capabilities, and if the /language/ itself does not feel up to the task you have a lot more freedom when it comes to implementing things. So it really comes down to the community size and amount of money poured in the development, and not fundamental proble…

Yes, this is something I should have mentioned as well, Nim does a lot of things just right and adds all the right things so it stays out of your way, is not too verbose but still has enough safety guards where you can just do what you want to do.

Re: Nim 1.6

#27
> Fast compile times: a full compiler rebuild takes ~12s (Rust: 15min, gcc: 30min+, clang: 1hr+, Go: 90s) [2].

Whoa, this really surprised me!

Re: Nim 1.6

#28
post #23

Earlier quoted context omitted.

Well no language is perfect, but Nim can be used in almost every domain because of it's compilation targets(C, C++, JS) and it's fast compile times(who needs interpretation when compile times are that fast!): * Shell scripting, I still assume most people will just use Bash tho: https://github.com/Vindaar/shell * Frontend: https://github.com/karaxnim/karax or you could bind to an existing JS library. * Backend: For so…

I haven’t used nim outside of some hello world toying a few years back. Is compiling actually that fast? I thought the nim compiler compiled to C and then called gcc (or whatever system compiler), isn’t that slow in practice? Any large nim projects that anyone can point me to would be helpful too, I’ll give the compiler a shot later today!

The proof is in the link!

> Fast compile times: a full compiler rebuild takes ~12s (Rust: 15min, gcc: 30min+, clang: 1hr+, Go: 90s) [2].

The compiler is really big and self-hosted too.

For large nim projects check out: https://github.com/mratsim/Arraymancer or https://github.com/treeform/pixie (personal faves).

Re: Nim 1.6

#29

> Why use Nim? > One language to rule them all: from shell scripting to web frontend and backend, scientific computing, deep learning, blockchain client, gamedev, embedded, see also some companies using Nim. Does that work in practice? I can't really imagine a single language that would be a good choice for "everything".

Yeah, these kind of statements feel very “empty” to me. That’s probably true that you could do everything with Nim, it’s also true that you can do everything with every language. Should you? That is another question.

Unfortunately, it's not possible to do everything with every programming language. If thinking of rewrite of some software, it depends does all dependencies, database drivers, authentication, etc exist for some other programming language.

Re: Nim 1.6

#30
post #23

Earlier quoted context omitted.

I haven’t used nim outside of some hello world toying a few years back. Is compiling actually that fast? I thought the nim compiler compiled to C and then called gcc (or whatever system compiler), isn’t that slow in practice? Any large nim projects that anyone can point me to would be helpful too, I’ll give the compiler a shot later today!

The proof is in the link! > Fast compile times: a full compiler rebuild takes ~12s (Rust: 15min, gcc: 30min+, clang: 1hr+, Go: 90s) [2]. The compiler is really big and self-hosted too. For large nim projects check out: https://github.com/mratsim/Arraymancer or https://github.com/treeform/pixie (personal faves).

Thanks for the links, I’ll check those out.
Post reply on HN