Programming |
|||
|
Contents Home Page Climbing Programming Biking Running Web |
This is the main page for the programming section of the site. The silicon processors at the heart of modern computers are one of the few devices so far invented that may be used for almost any control or other process that is repetitive and that may be automated. With seemingly everything these days controlled by these devices there needs to be some means of controlling the behaviour of such devices. That means goes by the generic term of programming. Programming is often thought of as simply writing instructions (code) for the computer to follow. However there is somewhat more to it than that. Thought must be given to what is being controlled and the means of controlling it, that is the algorithm to be used. Thought must also be given as to how all the pieces of code fit together, this generally goes under the name of system design with the latest musings on this subject being presented as patterns. A short, incomplete, history of programming. Originally, on the earliest devices, programming was done by means of writing the controlling code in the basic commands of the particular piece of silicon. This has two disadvantages: firstly it takes a large number of such commands to achieve even simple functionality; secondly each processor or processor family has a different set of commands. True some may be very similar in appearance but even subtle differences are enough to ensure that a silicon version of the Tower of Babel ensues. The next stage in program writing was to produce mnemonics for the basic commands. These made the coding process much easier as the programmer no longer had to remeber an obtuse set of numbers but could write their code in what appears as a stilted shorthand version of English. These mnemonics were then assembled into the underlying machine code. Since this translation was an obviously automatable process a program was soon written to perform this task, this program became known as an assembler and by extension the mnemonic codes gained the generic name "assembler". The problem still remained however that there was one assembly language for each processor type, all that had happened was that the "languages" had a passing resemblence to English. Code could not be written for one processor type and run on another, it had to be translated beforehand. Obviously a time-consuming and error-prone process. Slowly the so-called third generation languages began to appear. These have the appearance of very formal version of English, albeit a version that has a very small set of words. The early versions of these languages often required specific layout of the code which was a throwback to the layout of assembler. As time progressed these requirements relaxed so that the later languages in this group became known as "freeform" meaning that whitespace (blanks, tabs and newlines) could be used to make the code easier to read to the human eye. These changes also meant changes to the programs used to convert human readable code into machine readable code. Now, rather than a straight translation between a mnemonic and the underlying machine code, one so called high-level instruction could result in tens or even hundreds of individual instructions. Such programs are known as either compilers or interpreters. In the former case the translation to machine code is made directly and is normally done just once, in the latter the human readable code is converted on a line by line basis as the code is run. If a line is repeated then it is repeatedly converted before being run. Obviously this is less efficient than the whole program being converted once but it does have the advantage that it is simpler and may be sufficient for human-computer interaction such as in text shells such as DOS or the UNIX command line. Today there is a bewildering array of different languages available to the programmer. Why? Well, just as in the real world, you wouldn't use the language of a carpenter when discussing law or vice-versa, so it is with computer languages, each serves a particular niche in the overall market. Some are really just hobby languages that have "escaped" others are very widely used. Some have a miriad of variations (BASIC), others are standardised by international bodies (C, C++) so that the dream of write once use anywhere is possible. Still others are standardised by the fact that they are "owned" by commercial companies who decide what is and is not part of that language (Java). My language of preference is C. It is one of the older languages in common use today and also probably the closest there is to a lingua franca. It has been said that there is a C compiler available for every processor type. Unlike its natural counterpart "Esperanto", C is genuinely useful and much of its syntax is used in languages such as C++, Java, Perl and others. The code examples in this section are, at the moment, all in C though some Perl may creep in at a later date.
|
||