by dagw · 10y ago · 0 comments
Nicely put. :) Thanks for the link.
Needlessly increased variable scopes - and thus increased risk of harder to follow cross-dependencies - is probably the biggest downside risk. But I've found code that executes linearly easier to read and understand when it's written linearly. When everything is factored into functions - particularly impure functions - you need to click all over the place to understand the whole.
If there are higher-level primitives that can be used - filters, maps, folds, etc. - then they can reduce the verbosity overall. Some monadic styles can flatten nested code by computing a pipeline / computation rather than having lots of nested loops. But depending on the language and the problem domain, performance may suffer.
This is a great piece of advice and one that has worked for me in the past when refactoring code like the one referenced.
I was quite surprised at how often copy-paste-modify
operations resulted in subtle bugs that weren't
immediately obvious.
I now strongly encourage explicit loops for everything,
and hope the compiler unrolls it properly.
I found this particularly interestingAnother good example of this is the Phong shading model. IIRC it was invented in the mid-70s, and some software rasterizers implemented it, but it didn't really make its way into graphics cards with fixed pipeline rendering until the mid-90s.
Graphics tech in the 90s and even early 2000s involved a lot of hardware and software catching up to theory from the 70s and 80s because we were finally getting enough compute power to make it worthwhile to use "approximate" rasterization-based algorithms in order to get real-time rendering.
The man is a legend. I remember using his little set of DOS utilities (things like stuffit.com [2]) back in the early 1990s, which I got from a friend whose dad was a colleague of his at Hydro. They were all written in assembly language, and were superb little extensions to DOS.
[1] https://www.linkedin.com/in/terje-mathisen-b740181
[2] http://files.mpoli.fi/unpacked/software/dos/utils/keyboard/s...