Update
This commit is contained in:
parent
d52544f211
commit
2c60dc3a2e
22 changed files with 1722 additions and 1663 deletions
12
brainfuck.md
12
brainfuck.md
|
@ -1,12 +1,12 @@
|
|||
# Brainfuck
|
||||
|
||||
Brainfuck is an extremely simple, untyped [esoteric programming language](esoland.md); simple by its specification (consisting only of 8 commands) but intentionally very hard to program in. It works similarly to a pure [Turing machine](turing_machine.md). In a way it is kind of [beautiful](beauty.md) by its [simplicity](minimalism.md). It is very easy to write your own brainfuck [interpreter](interpreter.md).
|
||||
Brainfuck is an extremely simple, [minimalist](minimalism.md) untyped [esoteric programming language](esoland.md); simple by its specification (consisting only of 8 commands) but very hard to program in (it is so called [Turing tarpit](turing_tarpit.md)). It works similarly to a pure [Turing machine](turing_machine.md). In a way it is kind of [beautiful](beauty.md) by its [simplicity](minimalism.md), it is very easy to write your own brainfuck [interpreter](interpreter.md) (or [compiler](compiler.md)) -- in fact the Brainfuck author's goal was to make a language for which the smallest compiler could be made.
|
||||
|
||||
There exist [self-hosted](self_hosting.md) brainfuck interpreters and compilers (i.e. themselves written in brainfuck) which is pretty fucked up. The smallest one is probably the one called [dbfi](dbfi.md) which has only slightly above 400 characters, that's incredible!!! (Esolang wiki states that it's one of the smallest self interpreters among imperative languages).
|
||||
There exist **[self-hosted](self_hosting.md) Brainfuck interpreters and compilers** (i.e. themselves written in Brainfuck) which is pretty fucked up. The smallest one is probably the one called [dbfi](dbfi.md) which has only slightly above 400 characters, that's incredible!!! (Esolang wiki states that it's one of the smallest self interpreters among imperative languages). Of course, **Brainfuck [quines](quine.md)** (programs printing their own source code) also exist, but it's not easy to make them -- one example found on the web was a little over 2100 characters long.
|
||||
|
||||
The language is based on a 1964 language P´´ which was published in a mathematical paper; it is very similar to brainfuck except for having no [I/O](io.md).
|
||||
The language is based on a 1964 language P´´ which was published in a mathematical paper; it is very similar to Brainfuck except for having no [I/O](io.md). Brainfuck itself was made in 1993 by Urban Muller, he wrote a compiler for it for Amiga, which he eventually managed to get under 200 bytes.
|
||||
|
||||
Brainfuck has seen tremendous success in the [esolang](esolang.md) community as the **lowest common denominator language**: just as mathematicians use [Turing machines](turing_machine.md) in proofs, esolang programmers use brainfuck in similar ways -- many esolangs just compile to brainfuck or use brainfuck in proofs of [Turing completeness](turing_complete.md) etc. This is thanks to brainfuck being an actual, implemented and working language reflecting real computers, not just a highly abstract mathematical model with many different variants. For example if one wants to encode a program as an integer number, we can simply take the binary representation of the program's brainfuck implementation.
|
||||
Since then Brainfuck has seen tremendous success in the [esolang](esolang.md) community as the **lowest common denominator language**: just as mathematicians use [Turing machines](turing_machine.md) in proofs, esolang programmers use brainfuck in similar ways -- many esolangs just compile to brainfuck or use brainfuck in proofs of [Turing completeness](turing_complete.md) etc. This is thanks to Brainfuck being an actual, implemented and working language with I/O and working on real computers, not just some abstract mathematical model. For example if one wants to encode a program as an integer number, we can simply take the [binary](binary.md) representation of the program's Brainfuck implementation. Brainfuck also has many derivatives and modifications (esolang wiki currently lists over 600 such languages), e.g. [Brainfork](brainfork.md) (Brainfuck with [multithreading](multithreading.md)), Boolfuck (has only binary cells), Brainfuck++ (adds more features like [networking](network.md)), Pi (encodes Brainfuck program in error agains [pi](pi.md) digits), Unary (encodes Brainfuck with a single symbol) etcetc.
|
||||
|
||||
In [LRS](lrs.md) programs brainfuck may be seriously used as a super simple [scripting language](script.md).
|
||||
|
||||
|
@ -29,6 +29,10 @@ A program consists of these possible commands:
|
|||
- `.`: output value under data pointer as an ASCII character
|
||||
- `,`: read value and store it to the cell under data pointer
|
||||
|
||||
Characters in the source code that don't correspond to any command are normally ignored, so they can conveniently be used for comments.
|
||||
|
||||
Brainfuck source code files usually have *.bf* or *.b* extension.
|
||||
|
||||
## Implementation
|
||||
|
||||
This is a very simple [C](c.md) implementation of brainfuck:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue