If you took Python but made it perform blazingly fast, and made it suitable for the most demanding of embedded and systems programming applications, in addition to game dev, you'd get Nim.
If on the other hand you're satisfied with Python, then keep using it. It was trivial for me to port a Python elliptic curve implementation to Nim. I'd certainly recommend it over Cython, because Nim is simply designed as one complete system built for writing high performance applications with a sane syntax.
Statistics (on an x86_64 Intel Core2Quad Q9300):
Lang Time [ms] Memory [KB] Compile Time [ms] Compressed Code [B]
Nim 1400 1460 893 486
C++ 1478 2717 774 728
D 1518 2388 1614 669
Rust 1623 2632 6735 934
Java 1874 24428 812 778
OCaml 2384 4496 125 782
Go 3116 1664 596 618
Haskell 3329 5268 3002 1091
LuaJit 3857 2368 - 519
Lisp 8219 15876 1043 1007
Racket 8503 130284 24793 741
https://github.com/def-/LPATHBench/blob/master/nim.nimAre there any other up-to-date benchmarks of Nim? In larger programs, performance is often dominated by allocating and garbage collecting memory. It would be interesting to know if Nim performs as well in that discipline as in raw number crunching.
When I say "powerful macros" I really do mean it. I wrote what is essentially the equivalent of C# async await using only Nim's powerful metaprogramming.
const lookupTable = veryComplicatedFunctionCall()
or letting you declare types differently depending on compile time specifications. And then there's the macro system which I haven't really used but seems pretty nice.So maybe "C with a macro system that's safe and does everything you always wanted it to do"?
As someone who does a lot of work on microcontrollers where there's no filesystem to read in configurations from and where small binary sizes count this is all very exciting for me.
In case anyone is wondering: The actual platform was Chumby [1], and Python ran great on it. We had a little twisted [2] application that displayed images and played sound. To display the images we just wrote an image file (after using PIL to manipulate it) to /dev/fb. It was really fun! I just double checked the hardware the chumby: A 350 MHZ ARM9 processor with 64 megabytes of SDRAM. It sounds a little crazy to me now to think of transforming images using PIL in 64 megabytes of ram, but it actually worked quite well.
[0] http://www.scratchbox.org/
I tried pulling the files out of nimcache/*.c, but it is wanting to include nimbase.h.
Is there a way to compile an entire Nim program to a single self-contained .c file (ie. an amalgamation, aka SQLite?)
SQLite pioneered this approach, called an Amalgamation. It offers some noticeable advantages:
https://www.sqlite.org/amalgamation.html
It is gaining some followers:
https://github.com/vinniefalco/Amalgamate
http://stackoverflow.com/questions/2719311/tool-to-create-an...
http://lua-users.org/lists/lua-l/2008-08/msg00594.html
> Usually people redistributing source code don't mind having several files bound together by some make|build script.
A single .c file is easier to integrate into various build systems. For example a Visual Studio project, or another Makefile without needing a separate script. It's just cleaner.
> Most people willing to get something redistributable prefer a binary static|dynamic library or final executable.
These aren't portable like a C source file is.
Go is garbage collected and has an opinionated ABI and runtime. Completely different beasts.
Someone has revived the LLVM C Backend. Hopefully this could be a path to Rust->C compilation: https://github.com/draperlaboratory/llvm-cbe
Compiling to C is so important to me that I may check out Nim as an alternative to Rust, despite liking Rust very much.
That would be Kawa (http://www.gnu.org/software/kawa/).
Put that up, and allow integrate CPython 2.7 into Nim's output binaries for use of interfacing with Python2 libraries through Nim code... and you have yourself a serious contender for picking off many Python refugees and some serious traction within industry too.
That's a good point. One could try "faster, safer Python" here, but I agree that it should be discussed and made official, so that anyone seeing Nim's homepage would immediately know what it's about.
-very slow
-GIL
-not enough type checking
Nim fixes those while keeping things which attract people to Python in the first place. It should be enough of a selling point.
I write most of my code in C + Python (and sometimes in Python + C). For me Nim ticks all the boxes, even the minor ones (how syntax looks etc.). I can't wait to give it a try once I am done with my current project.
It looks like Python, with a little more types.
Fwiw, I'm also a language geek and my favorite language is Factor. If I wanted to evangelize it, I could show how idiomatic Python or Haskell code translated to Factor takes up less than half or a third in size. So that's its USP (Unique Selling Point) -- really short code. What is Nim's USP?
Julia: "fresh approach to mathematical computing", Rust: "safe resource disposal without GC", Go: "C successor backed up by Google", Swift: "Replacement for Objective-C", Clojure: "Scheme on the JVM", Nim: "no idea what to write here"
Is it the Why should I be excited? paragraph: "Nim is the only language that leverages automated proof technology to perform a disjoint check for your parallel code. Working on disjoint data means no locking is required and yet data races are impossible" If I understood what the hell that means, maybe I would be excited. :)