News for hackers. Stuff that matters.
Re:Parse, Don’t Validate by DonaldFisk on Thursday November 07, 2019 @08:17PM (#21479202)
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.

Re:Parse, Don’t Validate by ttty on Thursday November 07, 2019 @08:28PM (#21479257)
No need to scroll. If you use a modern ide you can just hold Ctrl and hover the variable with your mouse.
Re:Parse, Don’t Validate by DonaldFisk on Thursday November 07, 2019 @09:57PM (#21479635)
That still wouldn't work for dynamically typed languages.
Re:Parse, Don’t Validate by squeaky-clean on Thursday November 07, 2019 @10:38PM (#21479784)
Maybe not something like Lisp but languages such as JS, Python, and Ruby have advanced enough tooling available that would easily identify this.
Re:Parse, Don’t Validate by marcosdumay on Friday November 08, 2019 @07:42AM (#21481701)
That's why the claim that it's an advantage of statically typed languages.