what’s the easiest way to program with nim linux?

Nim’s main entry point is the nim command. As long as you have that, you can compile and run nim programs all right:

$ cat > test.nim
echo "Hello nim!"
$ nim c -r test.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: test.nim
Hint:  [Link]
Hint: 14205 LOC; 1.218 sec; 20.496MiB peakmem; Debug build; proj: /private/tmp/t/test.nim; out: /private/tmp/t/test [SuccessX]
Hint: /private/tmp/t/test  [Exec]
Hello nim!

You can also embed that as a shebang into an executable hi.nim file and run it:

#!/usr/bin/env nim c --hints:off -r

echo "Hi nim scripting!"

But you will get a compiled binary without the .nim extension along the original file, so it’s kind of awkward for scripting.

UPDATE: As suggested by @shirleyquirk you can also save .nims files with a special shebang that will run them as NimScript, which has some limitations compared to normal Nim code but should be fine for most if not all typical scripts.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top