3 ms·
... and I get hung up on page 2:- nim c -r --verbosity:0 helloworld.nim c is short for compile, and -r is short for run. Why? Why not:- nim cr --verbosit
by tuatoru 4y ago
... and I get hung up on page 2:-
nim c -r --verbosity:0 helloworld.nim
c is short for compile, and -r is short for run. Why? Why not:-
nim cr --verbosity:0 helloworld.nim
or even just:-
nim helloworld.nim
with "r" and verbosity zero being the defaults, and the compiler figuring out that it neeeds to compile first?
These inconsistencies and bits of unnecessary mental freight annoy me.
- cb321 4y agoIn 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
- xigoi 4y agoCompiling is the main action you do with the file. Running it is just an additional option, hence why it's a flag. It's the same reason why you have, for example, `git push -f` and not `git pushf`.