Self-hosting compiler: Difference between revisions

Added FreeBASIC
(Moved Wren entry into correct alphabetical order.)
(Added FreeBASIC)
 
(7 intermediate revisions by 7 users not shown)
Line 1:
{{difficulty}}
{{draft task}}
 
Implement a self-hosting compiler for your language i.e. create a compiler that is implemented in the language it is supposed to compile. Extra credit for any solution that can compile in an online compiler such as Ideone. If this is not feasible due to language complexity, link to external projects that achieve this task.
 
Implement a self-hosting compiler for your language, i.e.:   create a compiler that is implemented in the language it is's supposed to compile. Extra credit for any solution that can compile in an online compiler such as Ideone. If this is not feasible due to language complexity, link to external projects that achieve this task.
 
Extra credit for any solution that can compile in an online compiler such as Ideone.
 
If this isn't feasible due to language complexity, link to external projects that achieve this task.
<br><br>
 
=={{header|ALGOL 68}}==
 
The Algol 68 to C compiler available here: [httphttps://wwwgithub.poenikatu.co.ukcom/srcsdolim/] or here:algol68toc [https://github.com/NevilleDNZsdolim/algol68toc] is written in ALGOL 68 and compiles itself. It is derived from the ALGOL 68RS compiler.
 
=={{header|ATS}}==
ATS2 is ''not'' self-hosting, but ATS1 (in which ATS2 is written) is. The source repository is here: [https://github.com/githwxi/ATS-Anairiats https://github.com/githwxi/ATS-Anairiats]
 
=={{header|BaCon}}==
Line 14 ⟶ 24:
 
The older Mono C# compiler, currently backed by the .NET Foundation, can be found at [https://github.com/mono/mono]. There is also a (much newer) Mono VB compiler.
 
=={{header|FreeBASIC}}==
Essentially, FreeBASIC consists of two parts:
 
1. The FreeBASIC compiler, written in FreeBASIC (self-hosting). Compiling this requires a working FreeBASIC installation.
2. The FreeBASIC runtime libraries, written in C. Compiling this requires a C compiler such as gcc, the GNU C compiler (Native gcc on Linux, MinGW on Windows, DJGPP for DOS).
 
FreeBASIC is a self-hosting compiler, being roughly 120,000 lines of code (compiler core only, not including libraries).
 
Source code can be downloaded from [https://freebasic.net/wiki/DevBuild https://freebasic.net/wiki/DevBuild].
 
=={{header|Go}}==
Line 24 ⟶ 44:
=={{header|J}}==
 
<langsyntaxhighlight Jlang="j">do =: ".
STDIN =: 1
do read STDIN
Line 31 ⟶ 51:
".1!:1[1
((,~}:)~|.)'Go hang a salami '
Go hang a salami imalas a gnah oG</langsyntaxhighlight>
 
{{omit from|Julia}}
Line 42 ⟶ 62:
=={{header|Lingo}}==
Propably not how the task was meant by the OP, but if "compiling code at runtime" counts, here Lingo's capabilities to do this:
<langsyntaxhighlight lang="lingo">m = new(#script)
 
-- automatically triggers compilation to byte code
Line 59 ⟶ 79:
-- for direct execution of simple code there is also the do() function
do("put _system.milliseconds")
-- 22476580</langsyntaxhighlight>
 
=={{header|Nim}}==
Nim compiler is written in Nim and can be found here: https://github.com/nim-lang/Nim.
 
=={{header|Phix}}==
Phix is self hosted. Run "p -c p" and it rebuilds itself in about 15 seconds. One of my favourite parlour tricks is to then run "p p p p p p p p -cp" which stacks seven interpreted copies of itself on top of each other with the last recompiling itself, and apart from a slightly longer startup time, no slower than the shorter command.
 
=={{header|Plain English}}==
Plain English is self-hosted. The Osmosian Order of Plain English Programmers claim that Plain English can recompile itself in 3 seconds. Instructions for recompiling Plain English can be found in the instructions.pdf.
 
=={{header|Python}}==
Line 88 ⟶ 114:
(formerly Perl 6)
 
<syntaxhighlight lang="raku" perl6line>use MONKEY-SEE-NO-EVAL;
EVAL slurp</langsyntaxhighlight>
 
=={{header|Rust}}==
Line 110 ⟶ 136:
 
The VM (which includes the bytecode compiler) and the command line interpreter (which enables Wren scripts to be run independently) are written in C. Most of the core library is also written in C though parts of it are written in Wren itself. Frankly, in the interests of speed and because Wren is primarily intended as an embedded scripting language, self-hosting is never going to happen.
 
Note, however, that Wren can compile Wren source code ''at runtime'' using the Meta.compile method.
 
=={{header|ZED}}==
Source ->
Compiled -> http://ideone.com/UHMQco
<langsyntaxhighlight lang="zed">(*) number1 number2
comment:
#true
Line 1,384 ⟶ 1,412:
comment:
#true
(zed->scheme!) "value" nil</langsyntaxhighlight>
 
=={{header|zkl}}==
2,130

edits