Hello everyone!
I've been learning Nim (reading the tutorial and docs mostly) for the past few days now, and I am very impressed. A bit about me - I began my programming career with Turbo Pascal, then moved to C and C++, then spent many years using Perl and JavaScript professionally. I've been keeping an eye on the few new languages that have been generating buzz lately. I find Go incredibly boring and uninteresting. Rust is much more interesting, but a bit enigmatic.
Then comes Nim, which I really like, except for a couple of semantic issues. I apologize if these have been discussed previously. Also, I realize that it may be too late to change semantics, so I am going to state my issues in the form of questions:
def pow2(num: int): int =
num * 2
versus
proc pow2(num: int): int =
num * 2
2. Why except in the try-except-finally block? The word except meaning "exception" in this context, is more confusing than helpful, because it has a different meaning in the English language. It means "aside from", or "apart from". This kind of makes reading code sound like: "Try to do this, except for this and except for that". I feel it would have made more sense to use the word catch, instead of except, in which case the block would read more like: "Try to do this, catch this exception, catch that exception, finally do that."
Those are the only couple of questions I have. All things considered, I really like Nim, and I am looking forward to learning more and using it in the future.
Thanks, Stefan G.
About def vs. proc - proc comes from Pascal IIRC. Also, func is already a keyword in nim and will be used to define pure functions (no side effects) at a later stage. Also, people usually indent two spaces.
About catch vs. except - neither is better than the other in a vacuum, it's just that more languages use catch. I have no idea where that one comes from.
I agree with the question about catch vs except, at first i thought it was a way to filter exception that you didnt want to catch, then i learnt it was because of except(ion)
About def vs proc, i wouldn't mind def, but you really get used to proc very quickly. In this way, it is faster to spot, at first sight, if the code was written in nim vs python.
Why was the word proc chosen to define functions? It's a bit counter-intuitive because a procedure traditionally does not return a value (Pascal, Modula-2).
Actually Modula-2 and Oberon only use procedure too, Pascal's distinction makes little sense. It makes much more sense to distinguish between proc and func based on their effects rather than the existance of a return value.
Wouldn't it be better if the keyword func was used, or even better, the short and very familiar def?
But this doesn't even make sense in Python: class for "define class" and def for "def'ine function/method"? It would be worse in Nim: template, macro, type (etc.) and then def?
Why except in the try-except-finally block?
except is more useful as keyword. :P (import foo except bar) It's also the same in Python and Delphi.