How to reduce the chance for human error in programming

Programming is a difficult task. Few people are good at it. One of the main secrets of expert programmers is that they avoid things that cause problems, and steer towards constructions that are robust.

The first secret is to use constants instead of variables whenever possible. In most good languages there is a concept of a constant that cannot be changed in the program. In the C language they used a #define statement, In a better designed language like Pascal or Modula-2 there was a const statement that you could use to define a quantity. The compiler would prevent you from trying to change the variable; you can't do it even by accident because the compiler prevents you from making that mistake. This is a fantastic feature, and unfortunately Javascript didn't have this feature until recently. A constant has almost no chance to be wrong. The more constants you have in your code, the better it is. 

IF statements are also a big problem. The fewer IF statements you have in your code, the better it is. In fact, if you eliminate loops and IF statements, your code then becomes a linear sequence of instructions, and even the worst programmer can debug a big program if it has no IF statements, and a completely sequential control flow.

Object oriented programming was a fad that is now finally ending, and it was disaster for the industry, because in Java, the poster-child language for object-oriented programming, you were encouraged to created little packages of variables called "objects". These objects would multiply by the thousands. The net result was a system that you couldn't possibly understand, and there are few things more cryptic than a very large Java program. Java encouraged variable creation. The reason functional programming is so attractive to people is that in functional programming you use a lot fewer variables. Every language has the concept of a function or subroutine, so functional programming is really a misnamed thing, because what is different in functional programming is not functions, but how variables are treated.

But all of the latest languages and programming style fads are missing something very important. And that is the evolution of data structures. If we don't create new data structures, programs are not going to change much, nor will productivity improve. Prof. Wirth in his Oberon language, tried to create the concept of a data structure that could be larger than a previous one, and the larger augmented structure could be passed to a function that needed only the original. As long as you sent a superset of fields it would work. Java also has this concept, called superclassing. This means that subroutine libraries can still work with evolved data structures. The subtlety of Prof. Wirth's system was completely lost on people, and Oberon was totally ignored. Prof. Wirth wrote an important book called "Algorithms + data structures = programs", and since algorithms are pretty set now, the main area that needs innovation is in data structures. Not syntax, or fancy operations like map, reduce, apply, or fancy pipe operators. 

The weakness of their data structures dooms all the existing languages. Each language breakthrough has added some data structures, but lately the new languages have not added any new data structures, so in an important aspect they are not new languages really, but new skins on old concepts.