0

Just finished full installation of Nim language to my Debian GNU/linux and feel a bit confused, not finding any development kits or at least console commands to try some scripting... Isn't it supposed to be included into instalation packages?

So I'll be thankfull to any advice how to choose between all aviable IDE or interfaces for coding with Nim on Linux.

Deno
  • 57
  • 5
  • Take a look at this article to explore further: https://matthiashager.com/gui-options-for-nim – sreedta Oct 28 '20 at 17:23
  • This is going to be closed quickly. You can choose between vim, emacs, visual studio... I'm happily using neovim + nim.nvim + syntastic + asyncomplete pluggins. – xbello Oct 28 '20 at 17:25
  • 1
    PyCharm has an optional free Nim plugin. – Asclepius Dec 05 '20 at 04:38

2 Answers2

4

Nim isn't included in any development kits as far as I'm concerned. There are a lot of editors with Nim addons though. That includes most popular editors like VSCode, emacs or vim.

If you wanted to you could just use a terminal as an interface with a simple editor.

leventea
  • 41
  • 2
4

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.

Grzegorz Adam Hankiewicz
  • 7,349
  • 1
  • 36
  • 78
  • if you change the script file to ``hi.nims`` you don't need the ``c -r`` and it wont create a binary either. I had to pass ``-S`` to ``env`` ``#!/usr/bin/env -S nim --hints:off`` ``echo "Hi nim scripting"`` – shirleyquirk Oct 29 '20 at 13:11
  • @shirleyquirk my nim compiler (1.2.6) does not have that option, and it's not documented at https://nim-lang.org/docs/nimc.html either. Is `-S` an experimental feature in the development branch? I do find it at https://nim-lang.org/docs/nims.html though… – Grzegorz Adam Hankiewicz Oct 29 '20 at 22:55
  • 1
    -S is a parameter sent to ``env`` to "pass multiple arguments on shebang lines" https://man7.org/linux/man-pages/man1/env.1.html – shirleyquirk Oct 30 '20 at 13:46