Main differences between Haxe and Nim?

Noticed this recent Nim thread on HN, and it appears that Nim and Haxe have quite a bit in common:

  • high-level
  • statically-typed, with type inferencing
  • GC’d
  • Nim can compile to C, C++, JS

Aside from the obvious syntax differences (personally I prefer Haxe’s), and the fact that Haxe supports more target platforms and additionally has its own VM, can anyone comment on the main differences between the two languages?

One feature I noticed from the Nim wikipedia page is that Nim supports UFCS (Uniform Function Call Syntax). I remember seeing that in D. The feature seems confusing to me, as it’s not obvious whether you’re calling a method of the object, or some function via UFCS.

haxe can compile to PHP, python and lua

Nim and Haxe share many things. To your list I would add:

  • a powerful macro system
  • generics

where they differ is :

  • Nim generic is template based, which gives you more power
  • Nim has no real working OOP yet, but you can create OOP easily with the macro system
  • Nim generics support static[T] which is nice
  • Nim has build in yield in the iterator
  • Haxe is much mature and reaches version 4. Nim is struggling to reach version 1
  • Haxe has pattern matching build in. Nim does this with macro and libraries
  • Haxe has Enum as ADT, Nim has object variants. I like Haxe approach much more.
  • Nim allows more low-level programming. you can switch off GC, have manual memory management and have different GCs available (ref counted, mark and sweep, boehm, real time).
  • Haxe has a static analyzer and very good inliner. Nim relies on the backend compiler to do the job until now. When targeting C or C++ Nim code is in general a bit faster than Haxe (less overhead, better memory handling, no Dynamic). On JS I would claim that Haxe is better
  • Haxe has a much more options for the backend

So its a matter what you are doing. For system level programming I would choose Nim. For UI, client side, cross platform or games I would choose Haxe. Both are nice and I use both.


Right, yes, lots of targets!

Thank you for the detailed list, Adrian!