Aktuelle Änderungen Printable View Änderungen Bearbeiten
Scope > ScrapingAdSense > ScreenCasting > ScreenCast > SeSAm > SegWay > SegelShop > SelfHostingProgrammingLanguagesClear TrailThe term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger systems. Other programs that are typically self-hosting include kernels, assemblers, shells and revision control software.
Several programming languages are self-hosting, in the sense that a compiler for the language, written in the same language, is available. The first compiler for a new programming language can be written in another language (in rare cases, machine language) or produced using bootstrapping. Self-hosting languages include Lisp, Forth, Pascal, C, Modula-2, Oberon, Smalltalk, OCaml, FASM, Python, Scala, Haskell, Java and BASIC.
The first self-hosting compiler (excluding assemblers) was written for Lisp by Hart and Levin at MIT in 1962. Because Lisp interpreters existed previously, but no Lisp compilers, they used an original method to compile their compiler. The compiler, like any other Lisp program, could be run in a Lisp interpreter. So they simply ran the compiler in the interpreter, giving it its own source code to compile.[
This technique is only possible when an interpreter already exists for the very same language that is to be compiled. It borrows directly from the notion of running a program on itself as input, which is also used in various proofs in theoretical computer science, such as the proof that the halting problem is undecidable.
A self-interpreter, or metainterpreter, is a programming language interpreter written in the language it interprets. An example would be a BASIC interpreter written in BASIC. Conceptually, self-interpreters are closely related to self-hosting compilers.
A definition of a computer language is usually made in relation to an abstract machine (so-called operational semantics) or as a mathematical function (denotational semantics). A language can also be defined by an interpreter, whereby the semantics of the language in which the interpreter is defined is usually considered as given. The definition of a language by a self-interpreter is not well-founded (i.e., cannot be used to define a language), but a self-interpreter tells a reader a lot about the expressiveness and elegance of a language. It also enables the interpreter to interpret its own source code, the first step towards a reflective interpreter.
There are some languages that have a particularly nice and elegant self-interpreter, such as Lisp or Prolog. Much research on self-interpreters, in particular reflective interpreters, has been conducted in the context of the Scheme programming language, a dialect of Lisp. In general, however, any Turing-complete language allows the writing of its own interpreter.