Comment by DonaldFisk
6 years ago
This helps the compiler, but only works for languages with type declarations, and is less helpful to the programmer, as to find a variable's kind (e.g. valid data vs. raw data) you need to look at its declaration, which may involve scrolling. The original idea, described in Joel Spolsky's original article on Apps vs. Systems Hungarian (https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...) is that the programmer can see, in the expression that the variable is used or the function is called, that the code is wrong.
I apply a variant of Apps Hungarian in my own code, e.g.
(setf input
(inputOfEdge
(first (edgesOfSocket
(outputOfGate
(nth (position visibleInput (inputsOfVertex node))
(ingatesOfEnclosure enclosure)))))))
(In the system this is lifted from, node was confirmed to be a Vertex a few lines earlier, and Output is a subclass of Socket.)
The general idea is language independent: you could write similar code in Java or C.
No need to scroll. If you use a modern ide you can just hold Ctrl and hover the variable with your mouse.
That still wouldn't work for dynamically typed languages.
Maybe not something like Lisp but languages such as JS, Python, and Ruby have advanced enough tooling available that would easily identify this.
That's why the claim that it's an advantage of statically typed languages.