Computer LanguagesComputers can 'speak' many languages nowadays. But how do they do this? To commmunicate with a computer's 'brain' you need to communicate via a computer language. Put very simply, the computer needs input from you in the form of a series of 'on' 'off' electrical signals - a binary input. It will then process that information in accordance with a 'program' - a set of instructions that tell it how to respond to particular input - and give an output to the user - you!. The 'brain' of the computer is the CPU - the central processing unit. Simple processors execute instructions one after the other, superscalar processors are capable of executing several instructions at once. A program is set out in 'lines of coding'. The computer works through the lines of the program sequentially - one after the other. Content of the lines of code can influence the program flow. It may be influenced by special 'jump' instructions that tell it to go to a numbered line. Conditional jumps can be used. These get the computer to compare parameters and depending on the result of that comparisson the program flow continues at the next line or a jump is made to another line in the program. Language LevelHow easy it is to write a program depends on the 'level' of it. The higher the level of the program the more it is related to human language and thought processes. The lower the level the nearer it is to machine speak - binary! The construction of these programs depends on the type of language used by the programmer. There are three categories of program language: Low-Level Languages (LLL) High-Level Languages (HLL) Very High Level Languages (VHLL) As well as full languages there are script languages (for example JavaScript) and little langauges. These are dealt with in separate sections. Compilation and InterpretationWhen you have written your program the computer then has to translate it into machine code (binary) so that it can understand it.
In principle any language could be implemented via a compiler or an interpreter - and a combination of both solutions is becoming increasingly common. A compiler can translate the source code into some intermediate form (often called bytecode), which is then passed to an interpreter which executes it. A program translated by a compiler tends to be much faster than an interpreter executing the same program: even a 10:1 ratio of speed is not uncommon. The mixed solution's efficiency is typically somewhere in between. The disadvantage of the "compiler" solution are the longer edit-run cycles and the inherent complexity of a good implementation. A pure compiler implementation is the typical solution for low-level languages, because it comes out as more "natural", and because of efficiency concerns; however with effort it is always possible to write compilers even for traditionally interpreted languages. Theoretically, any language may be compiled or interpreted, so this designation is applied purely because of common implementation practice and not some essential property of a language, and for some programming languages, there is little performance difference between an interpretive or compiled based approach to their implementation. Many languages have been implemented using both compilers and interpreters, including BASIC, C, Lisp, Pascal, and Python. While Java is translated to a form that is intended to be interpreted, just-in-time compilation is often used to generate machine code. |
|