The Processor and The Programmer

The answer to the question whether software should be written for the computer or for humans can be found on the relation between the salary of a developer and the price of a processor. First of all, code is to be read. Legible code reduces the cost, both during development and maintenance.

So, can performance be ignored? Definitely not, but a few rules should be followed:

  • Readable first, optimized later. It is easier to optimize a legible program than make legible an optimized one. Only a small part of the code needs to be optimized.
  • Profile the code execution before optimizing it. The reasons behind non-performant code are often counter-intuitive. Between the code written by the developer and its execution by the hardware, compilers and caches play an important role in the optimization of the source code structure and execution to take advantage of the target machine characteristics.
  • Demanding performance requirements are dealt by the software architecture. The software architecture isolates in a small set of modules the code that has to have good performance. This way, it is possible to associate concurrency and assign processors to these modules.
  • Encapsulate the optimized code. If the requirements are identified during requirements engineering, it is inside the software architecture modules, if performance drawbacks are identified during development isolate the code that has to be optimized inside a module, while preserving the architectural design.