4 ms·
In more recent versions of Nim than covered by that 2015 tutorial you can, in fact, simplify that to `nim r helloworld` (without the .nim extension). Dropping
by cb321 4y ago
In more recent versions of Nim than covered by that 2015 tutorial you can, in fact, simplify that to `nim r helloworld` (without the .nim extension).
Dropping the `r` part entirely would require (at least) not dropping the `.nim` part. Otherwise, a file named, say, "c.nim", "js.nim", "cpp.nim", "doc.nim", etc. would cause ambiguity with backend selection. Nim is (mostly) a compiler not an interpreter.
Choosing defaults is always a bit tricky, but Nim provides various ways to tune them/tweak almost all compiler settings so that you need not re-enter them all the time. E.g. with your "$HOME/.config/nim/nim.cfg", per directory "nim.cfg" or per file "foo.nim.cfg"..or "NimScript" alternatives.."config.nims", "foo.nims" instead. In fact, `nim e myScript.nims` is a way to invoke the compiler as an interpreter of a somewhat more limited language.
Tutorials themselves are also tricky. Different new users (of anything) come to early questions at, erm, different levels of earliness - largely due to different background/expectations. So, keeping a record of what you ask about/learn about when and then writing your own tutorial for others can add real value.
- elcritch 4y agoDon't forget that Nim also supports multiple backend languages, so I don't think `nim cr` works since `nim jsr` just gets confusing. The `nim c` part isn't shorthand for `nim compile` so the syntax seems logical to me with `-r` being a flag after the target language. There's also: nim cpp helloworld.nim nim cpp -r helloworld.nim nim js helloworld.nim nim js -r helloworld.nim