Paul Galvin talks about Overcoming Functional Programming’s Cognitive Dissonance Issues (for sticklers like me).
I don’t know how much you’re like me, but if you are, you can get bogged down in the specific meaning of words, concepts, definitions and how these apply to the real world. I can personally have a difficult time bridging the gap between notional definitions and real world practice
…
I don’t know how much you’re like me, but if you are, you can get bogged down in the specific meaning of words, concepts, definitions and how these apply to the real world. I can personally have a difficult time bridging the gap between notional definitions and real world practice
…
So if you’re like me — a bit of a stickler for literal definitions — and you’re interested in functional programming, try and let your guard down a bit. I have been chipping away at my preconceptions for a while now and I’ve been enjoying some success. You may too.
This is what has hit me in exploring Python. Up until now, with Fortran, Basic, C, Java, and other classics, programming has been atomic. an equal sign indicates an assignment of one thing to another thing. Classes, structures, methods, and functions were just straightforward representations of collections or algorithms that boiled down to individual values of a defined type. Program structure was still just assign, compare, and branch. No more.
Functional programming uses a word that had a specific meaning in the classic context and takes it to new galaxies. The term “functional” no longer means just a chunk of code stuck out in a pile because of convenience and resource conservation. It is now a style of problem solving with nuance and depth. Getting from what was to what is now isn’t a simple journey and that is why Galvin’s Cognitive Dissonance strikes a chord.
Micropython is especially revealing in this light. Set up a WiFi station and then scan for networks and you get a list of tuples back. In the really old days, that’d been a two dimensional array. Not all that long ago, it’d be an array of structures or classes. Now, the tuple that describes the SSID and other properties of networks heard by the WiFi radio is an ordered collection of constants. A loop can iterate through the list of networks and a single assignment can break out the tuple into individual variables so you can parse the values for authorization mode and other properties to print out a pretty report of what was heard.
Underneath this is one of the issues that caused the break between Python2 and Python3. That is Unicode (wikipedia). The idea of an English only character set that could be conveniently set up with only 256 or fewer items gave way to world wide computing that needed to accommodate many languages and alphabets and symbols. That really messed things up for programmers as the simple structures they used to manage character strings became much larger and more complex. With lots of memory and computing power, that wasn’t too big a deal but with the Micropython target size and complexity presented problems.
Another way of looking at this is that the mathematicians are creeping into programming. It used to be that being able to program was a matter of understanding algebra. That created a lot of ‘cognitive dissonance’ in schools as many educators had set ‘computer literacy’ up on a pedestal as an alien god and that led to a lot of bad schooling. For mathematicians, computer literacy was just a flavor of their usual studies and computers were really rather simple as they weren’t electronic engineers trying to design logic gates that actually worked. Mathematicians often start with something simple and build things. The things they build are means to communicate ideas and concepts in a very rigorous way. Newton and Leibniz ‘invented’ calculus as an example. Even algebra was invented to describe and help solve a class of problem.
Now, with computer programming, mathematicians have a new world to play in. One outcome of that is new paradigms in thinking about the representation of algorithmic solutions for classes of problems. That thinking shows up in the plethora of modern programming languages. Galvin’s advice to “let your guard down a bit” is classic for learning and something all teachers know at one level or another.
It’s not a change that everyone sees but it is one that impacts them all. Never in human history has such a period existed with so much change so fast in how we think about the problems we face. We live in interesting times.