Why Do We Try To Make Programming Like Something Else? |
Written by Mike James | |||
Thursday, 31 January 2019 | |||
Page 1 of 2 There has been a long tendency in the development of programming to try to turn it into something else - mathematics, logic, engineering - anything as long as we can get away from programming. Why, when what makes software different from all of the above is clearly its strength and not its weakness? Software - we all like to complain about it. You know the bugs, the overruns, the cost, the failures the.. Software is a problem for business, commerce, project management and science. Software projects fail, software fails and it is difficult to get it right in the first place and next to impossible to correct when the failures become apparent. But wait there is something we are ignoring. Consider a typical software project with thousands of lines of code up front and tens of thousands in the supporting role. OK, so you didn't have to write the compiler and the frameworks you are using, but even "hello world" is in reality tens of thousands of lines of code all flying in formation. Constructing software is by far the most complex of tasks humans undertake. Consider for a moment an example from embedded development - the humble elevator. Embedded design is a good place to examine code because it often directly replaces hardware doing the same job. In the case of a mechanical elevator the call button is just a slightly more sophisticated version of two bits of metal held apart by a spring. The control logic is a few relays wired together to make the motor turn in the right direction and the safety interlocks - more switches and more relays. Complex for a machine yes but compared to the control software that replaces it not even off the launch pad.
So you have a touch screen which shows floor icons, and thousands of lines of code that work out which area of the screen has been touched for long enough to be equivalent to pressing the switch. All of the code that creates the graphics for the buttons, animates the buttons, shows the buttons in different states all comes before we get to the logic of controlling the lift. When we do get to this central task you can be sure that instead of a "goto first button" algorithm of the mechanical system we have a scheduling algorithm that attempts to minimize the wait time for the users. And if you push things a little further the elevator can wish the user a good day and add that it was a pleasure to serve as their elevator today. However, my point is that you really don't have to go as far as the speech synthesis the fairly basic workings of an elevator as implementing in software are already much more complex than the hardware equivalent.
More cartoon fun at xkcd a webcomic of romance,sarcasm, math, and language
Software is complex - big surprise but even simple software is more complex than the systems it replaces. So this is the problem? Yes it is and this is the reason that software has a bad reputation. Even one line of high level code generally has more failure modes than a complex mechanism. OK, I exaggerate a little but the general point is correct. So what do we do about this complexity problem that we have? We go and look at disciplines that have a reputation for precision and robustness. We try to make software look like engineering but fail to notice that software is far more complex than anything engineering has ever had to tackle. Yes there are amazing engineering projects that make you mind boggle at how it all works out and comes together in the construction - but almost any even small piece of software is more complex. Just think of "hello world" again for a moment - to make it work you need a compiler or an interpreter, a complete framework that the language can use, the operating system and all the drivers the deliver the bits as pixels to the screen. This is staggeringly complex and yet we want to liken it to building a bridge. I'm not saying that there aren't things that we can learn from engineering but it isn't enough. So if engineering isn't going to hack it what about mathematics. Something in mathematics can be proved correct and this provides certainly. For mathematics to work for us however we have to abandon most of the things that makes programming different from math. What are these things that presumably are the cause of programming begin so useless and math being so perfect? The biggest difference is the mutability of assignment. When you set A=B you store what is in B in A. This is not the statement of equality that works so well in mathematics. So we throw out mutable assignment and work with immutable data structures that we have to keep on giving birth to new immutable objects as a way of mocking up mutability! Trying to reduce programming to math causes as many problems as it solves. Again I'm not saying that formal proofs and functional programming haven't got something to contribute - but it isn't enough. |
|||
Last Updated ( Thursday, 31 January 2019 ) |