Hacker News new | past | comments | ask | show | jobs | submit | nimmer's comments login

The author should really look at Nim.


Isn't that more equivalent of "I really want to have a typed and compiled language, but I'd also like to keep the Python like syntax". Nim is an underrated language, it's easy to pick up and plenty fast.


I will someday :) But unless there's Tensorflow and about a gazzillion other packages in Nim, it's not easy to switch.


The language is dandy, but it needs better tooling. If I wanted to support the project, that's where I'd direct my energy.


You know: this always tempts me, but I hold back because nim is not memory-safe (or has a clearly delineated memory-safe subset like Rust), and I would rather pick up an actually memory-safe (even if GCed) language even if some perf-cost (like F#, Ocaml, Swift, Vale ..etc).


There is a fairly clear subset of Nim which is memory safe. There are discussions once in a while to reduce that from a small set to one..two keywords, e.g.:

    https://forum.nim-lang.org/t/9280#61243
which has links to some others. The resolution is usually: Eh - it's already a very small set.

There also may well be libs (that you feel unable to not rely upon) which use these language constructs, and trust sure is tricky (in any PL ecosystem as well as just in life).


Definitely learnt from that link, thanks!

That still hasn't won me over from prioritizing definitely-memory-safe languages over "fairly-memory-safe" nim tho.


> Any good company won't care what programming language you are specifically proficient in

True, but most companies care more about using popular language rather than an innovative one. You might get hired but you won't be using Nim at work.


It's much faster than C++, Rust, Go and many others.


I'm assuming this must be for huge projects?

I just compiled my toy project (detecting anomalous parity in integers) in nim 1.6.6 (4.23s), go 1.17.7 (2.43s to create both aarch64 and x86_64 binaries), zig 0.8.0-dev.1140 (2.04s to create aarch64 and x86_64 binaries) and C via clang 13.1.6 (0.14s).

nim's compilation is 175% of Go, 207% of zig, and 3021% of clang.


how are u compiling (optimization, custom compilation flags etc.?) In my case https://github.com/mratsim/Arraymancer big project compile under your 4.2s so or you have like 10k+ lines of codes with macros or you just pass some debug flags to compiler :D


Compilation command is:

    nim c -d:release --passC:"-flto" --gc:markAndSweep --out:ap ap.nim
I will add that once it's been run a few times, it does go a bit quicker (down to ~0.7s) but the Go also gets quicker (down to 0.28s for two outputs when files are cached.)


No, even small files. You must have issues with your setup. Are you sure your compiler is not built in debug mode?


How would I check that? I installed it through homebrew via https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/... which doesn't seem to mention debug mode anywhere?


Run `nim -v`, if it's not in debug mode you should see "active boot switches: -d:release".


Looks like it isn't in debug mode after all.

    $ nim -v
    Nim Compiler Version 1.6.6 [MacOSX: arm64]
    Compiled at 2022-05-05
    Copyright (c) 2006-2021 by Andreas Rumpf
    
    active boot switches: -d:release -d:nimUseLinenoise


Thanks for the data; that's what I call an elegant rebuttal.


No, it is not - Nim's compiler backend is extremely complex and full of cruft. I've been around Nim for 7+ years now and there's a reason the compiler was hard forked.

Nim's compiler is definitely not speedy, and this is why so much effort has been spent on incremental compilation, which tmk, still isn't working - https://github.com/nim-lang/Nim/issues/19757.


Verbosity overhead? Nim is very close to Python.


There is also Nim in Action, by Dominik Picheta


Nim supports classes and methods.


It has methods, but doesn't really have classes. And class-oriented programming is unidiomatic in Nim.


Nim is a very good choice because it generates tiny binaries while having a very expressive syntax.

It's the closest language to a static typed Python.

Also it uses GCC, which supports most microcontrollers.


While this is a very ambitious goal, Nim implements formal proof for invariants using a theorem prover:

https://nim-lang.org/docs/drnim.html


> If Nim can work with numpy it's a plus

Nim goes further there by removing the need for tools like Pandas and numpy. You don't have to write code in "Pandas-style" because native Nim is equally fast and sometimes faster.


> Nim goes further there by removing the need for tools like Pandas and numpy. You don't have to write code in "Pandas-style" because native Nim is equally fast and sometimes faster.

Can you clarify this? Is there an equivalent data stack in Nim? Or is it that nim is lighter-weight because, for example, it permits transforming tabular data into language structures natively (i.e., without library support)?


Besides @nimmer's fine response, there is also https://github.com/SciNim/Datamancer


The latter. For most uses of Pandas you can simply use native arrays. You can use for loops and so on.

For N-dimensional array computation: https://github.com/mratsim/Arraymancer/


This is the opposite of a footgun. Imagine if DNS was case sensitive and GMAIL.COM belonged to a domain squatter.

Nim prevents that. It's that simple.


This is an interesting take, I do see the value. If I was trying to prevent this type of aliasing, I'd have the compiler throw an error if there were two aliased variables names (xyz and XYZ for example), rather than merging them automatically.


Since Nim is statically typed you can't simply create a new variable with the same name as an existing one without errors. You can shadow variables in a deeper scope, but then only the latest version is available. Defining a function xyz and then trying to define another function xyZ is indeed an error.


That's what --styleCheck:error is for.


No. Nim always throws an error if you try to define multiple variables/procs that are conflicting.

--styleCheck:error strictly enforces camel case.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: