Re:Porting a NES Emulator from Go to Nim
by guelo on Friday May 01, 2015 @04:29PM
(#9474307)
It's closer to Go than Rust since it is garbage collected. It's statically typed, has OO features and first-class functions. It compiles to C making it pretty portable.
[ Parent
| on HN ]
Has generics, meta-programming and GC can be disabled (or tuned to run up to some max # of milliseconds).
So it is Go++ if you wish.
But I am not sure about its concurrency. Go does have channels which are nice abstractions for doing concurrency right.
Nim has channels too (although I think they need replacing). There is also spawn which is similar to Goroutines in some ways: http://nim-lang.org/0.11.0/manual.html#parallel-spawn-spawn-...
You can have manual control over memory if you want, though. This worked the last time I looked at the language, at least:
foo = cast[ptr Foo](alloc(sizeof(Foo)))
# do stuff with foo
dealloc(foo)
EDIT: Here's the documentation on the site itself. Most things are 'traced' by the GC, but by using alloc and dealloc you can work with 'untraced' (i.e. manually allocated) memory: http://nim-lang.org/0.11.0/manual.html#types-reference-and-p...