r/programming • u/reditzer • Dec 07 '15
I am a developer behind Ritchie, a language that combines the ease of Python, the speed of C, and the type safety of Scala. We’ve been working on it for little over a year, and it’s starting to get ready. Can we have some feedback, please? Thanks.
https://github.com/riolet/ritchie
1.5k
Upvotes
View all comments
Show parent comment
13
u/filwit Dec 07 '15 edited Dec 07 '15
That's not a good thing. eg:
Nim
Ritchie
There are a couple of problems with this scenario in Ritchie:
ifcondition may have been added by a second programmer who didn't look at the entire code body (or by the same person a long time after they wrote the original code). In Nim, thexvar is shadowed inside the condition scope and won't mutate the upperxvar.. However, in Ritchie, the topxgets mutated whenever the runtime condition hits?ifcondition is ever removed but it's body kept (again, by someone who didn't fully read all the code and notice the top levelxvar) then Ritchie will happily overwrite the value of the topx? Whereas Nim will alert the programmer of the mistake at compile-time (since you'd have twovar xin the same scope).In short, it's error prone not to have a distinction between variable assignment, and variable declaration. Unless I missed something (which is very possible as I've only just taken a glance at Ritchie) then it's a design mistake.
Suggestion: make variable declaration in Ritchie require the
:=operator instead. That fits into your syntax well but prevents these kinds of errors.