There is no formal distinction between a low level and a high level languages, but a number of differences can be noted.
A high-level language is an advanced computer programming that abstracts details of the underlying hardware , may be designed for a specific job, and is easier to understand. A line of code in a higher level language expands into multiple machine code instruction. Low level languages were developed first, and high level languages came along later. Today, there are dozens of high-level languages; some examples include BASIC, FORTRAN, Java, C++ and Pascal.
Low-level languages have the advantage that the programmer is able to tune the code to be smaller or more efficient, and that more system-dependent features are sometimes available. Their use is often a necessity when writing DeviceDrivers?
. They have the disadvantage that they are often unportable, and usually harder to program in, both in the sense that the programmer has to pay more attention to fine details, and in the sense that it takes more LinesOfCode
to achieve the same result.
As a concrete example, data types in a low level language might represent 8, 16 or 32 bit wide integers, whereas a high level language might feature human-friendly Currency and Date types. Low level languages are always static, and never have garbage collection.
The classic and uncontroversial example of a low level language is AssemblyLanguage
. Assembly is a mnemonic-based low-level language replacing binary machine-code instructions, which are very hard to remember, write down, or correct, with short codes (mnemonics) chosen to remind the programmer of the instructions they represent. For example, the binary-code instruction that means ‘store the contents of the accumulator’ may be represented with the mnemonic STA (st/ore a/ccumulator)
A low level language may be defined by the presence of hardware orientated features as well as the absence of high level constructs. Assembler is considered low level, although it usually include a macro facility, that allows single lines of code to expand into multiple machine code instructions.
Although C (CeeLanguage
) has a many of the high level constructs typical of a 1970s language (cf PascalLanguage
), it is sometimes considered low level (or low-level-high-level, or medium level...) because it allows bit-orientated operations, direct memory access, and raw pointers, (unlike, for instance HaskellLanguage
, where there is no concept of storing data). An argument against C being low level is that, standard ANSI C has lower level counterparts, such as CeeMinusMinus
., and lower level forerunner such as BeeLanguage
and BCPL. C++ (CeePlusPlus
) adds further high level features to C, without losing the low level features; however, systems programmers often prefer C for its explicit, WYSIWYG qualities.
It might seem odd that C, considered as a low level language, is highly portable. Part of the answer is that since the 1970s, hardware has often been designed with eventual programming in C in mind - for instance with a flat MemoryModel?
, and word lengths in multiples of 8 bits. Conversely, C itself has been extended to exploit hardware innovations such as widespread parallelism (eg. UnifiedParallelCee?
Assembler can be inlined in a number of otherwise high level languages, at the expense of less portability. Achieving portability is a motivation for removing low level features from a languages, notably in the case of Java, which runs on a VirtualMachine
. In fact virtualisation means that the level of a language depends on how it is used in situ, and not just on the language itself: C or assembler running in a virtual box will not have genuine access to hardware. Conversely, a language becomes lower level if running on tailored hardware, as in the LispMachine
. The ForthLanguage
is sometimes considered low level, because of its syntaxless approach, and resemblance to a virtual machine code, although, like Lisp, it is highly extensible.
Portable languages like Java may use ByteCode
or something else as an IntermediateLanguage
. Intermediate languages usually aren't meant to be hand written, but there is a certain overlap between low level languages and intermediate ones. See CeeAsAnIntermediateLanguage
Any language that is low level enough to allow full control of the underlying hardware is general purpose (in theory: it might well be a poor choice for some projects) Some high level languages are general purpose, while others are intended to solve particular problems: for example, BASIC was designed to be easily learnt by first-time programmers; COBOL is used to write programs solving business problems; and FORTRAN is used for programs solving scientific and mathematical problems.
See also: HighLevelLanguage