Fred evaluated several programming languages for a new project based on requirements of safety, portability, performance, expressiveness and elegance. The top candidates were Rust, Go and Nim. Nim is a multi-paradigm language created in 2005 with a focus on portability across operating systems and CPUs. It uses a garbage collector for memory management and supports features like generics, metaprogramming and concurrency.
9. ● nim c cc:gcc myproject.nim
● nim c --cpu:i386 --os:linux --compileOnly --genScript
myproject.nim
● nim c --cpu:arm --os:linux myproject.nim
● nim c -d:mingw myproject.nim
● nim c --os:nintendoswitch myproject.nim
--passC="-I$DEVKITPRO/libnx/include"
--passL="-specs=$DEVKITPRO/libnx/switch.specs
-L$DEVKITPRO/libnx/lib -lnx"
Compilation
10. ● FFI
● Wrapping code or libraries (see next slide)
● c2nim = Parse a C file and generate equivalent
Nim code
Interoperability with C-family
languages
11. ● Non-tracing GC
● Can be customised
○ GC_setMaxPause(MaxPauseInUs: int)
○ GC_step(us: int, strongAdvice = false, stackSize = -1)
● Can be turned off
○ GC_disable()
Garbage Collection