C−−

from Wikipedia, the free encyclopedia
C−−
Paradigms : imperative
Publishing year: 1997
Designer: Simon Peyton Jones
Developer: Simon Peyton Jones; Norman Ramsey
Current  version 2.0   (February 23, 2005)
Typing : static, weak
Influenced by: C.
www.cs.tufts.edu/~nr/c--

C−− ( C minus minus ) is a very C -like programming language or intermediate language for generation by compilers . The inventors of C−−, Simon Peyton Jones and Norman Ramsey, both researchers in the field of functional programming , invented C−− more to be used as an intermediate language to the machine code for high-level language compilers than as a normally programmed language. Unlike other intermediate languages, C−− consists of ASCII text, not bytecode (e.g. the intermediate code of Java ) or other binary formats.

Design and history

C−− is used as a portable assembly language designed to simplify the implementation of a compiler that is supposed to produce very good machine code, by the compiler simply producing C −− code and low-level optimization and implementation left to a C −− compiler.

Work on C−− began in the late 1990s. Since writing a code generator itself is difficult, and the compiler backends, which were openly available to researchers at the time, were complex and poorly documented, many projects wrote compilers that generated C code (the original Modula 3 compiler worked like this , also early versions of the GHC ). However, C is a poor language choice as an intermediate language for functional languages; for example, C does not support terminal recursion , has no garbage collection, or efficient exception handling . C−− is a simpler, more tightly standardized language than C, which has all these features. The greatest specialty of C−− is a runtime interface, which enables writing of portable garbage collectors, exception handling systems and other runtime extensions that run with every C −− compiler.

The syntax of C−− is very similar to that of C. However, some C properties have been removed or changed in the syntax, such as variadic functions , pointer syntax, and aspects of the type system of C, since these interfere with certain basic properties of C−−, as well as the easy generation by compilers and code- Make generators difficult.

The name C−− is basically an inside joke ( ++ and −− are used to increment and decrement in C-like languages ): C ++ is a C-based language with extended functions compared to C, so C−− the C language with reduced functionality.

C−− is a target language of the Glasgow Haskell Compiler , an adaptation of the language could become the main target language. Some C −− developers, including Simon P. Jones, João Dias and Norman Ramsey, have already worked on the Glasgow Haskell compiler.

Type system

As in many assembly languages is any higher type discrimination, for example, between signed, unsigned, float, etc. introduced pointers only by the operators and other language constructs.

The type system of C−− is intentionally designed to reflect the limitations of the hardware rather than the type systems of higher languages. In C−−, a value that is stored in a register or a memory cell can only have one type, namely that of a bit vector . A bit vector is a polymorphic type and can come in different word widths, e.g. B. bits8, bits32or bits64. In addition to the bit vector, C−− also has the Boolean type bool, which can be used as a solution in expressions and used to control the program flow, but cannot be stored in a register or in memory.

Sphinx C−−

The name C−− was used for an earlier programming language that was designed by Peter Cellik for x86 computers in the 1990s . Sphinx C−− integrates x86 assembler elements into C.

credentials

  1. www.cs.tufts.edu . (PDF)