Skip to content

Commit ae8b17e

Browse files
kspalaiologosjonasgeiler
authored andcommitted
Brainfuck part (#54)
* Create README.md * Create advantages.md * Kill all the typos * Create disadvantages.md * Create conclusion.md * Create intro.md * Update intro.md * Create history.md * Remove trailing space * Remove trailing space * Remove leading and trailing whitespace * Get rid of ! * Grammar fixes * Another fixes * Kill all the typos v2 * More grammar fixes * Update intro.md grammar typo fixed * Update advantages.md * Update conclusion.md * Update history.md keep the whole book in an American English, please * Update SUMMARY.md added Brainfuck to Summary file * Update credits.md done this for you...
1 parent a4f0cd1 commit ae8b17e

8 files changed

Lines changed: 105 additions & 1 deletion

File tree

book/SUMMARY.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@
132132
* [Some interesting facts](languages/haskell/misc.md)
133133

134134
* [Conclusion](languages/haskell/conclusion.md)
135+
136+
* [Brainfuck](languages/haskell/README.md)
137+
138+
* [Introduction](languages/brainfuck/intro.md)
139+
140+
* [History](languages/brainfuck/history.md)
141+
142+
* [Advantages](languages/brainfuck/advantages.md)
143+
144+
* [Disadvantages](languages/brainfuck/disadvantages.md)
145+
146+
* [Conclusion](languages/brainfuck/conclusion.md)
135147

136148
## End
137149

book/credits.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ We have to thank these great people on helping to write this book. Everyone here
4646
- Lucas Parzianello
4747

4848
- [devRant](https://devrant.com/users/lucaspar)
49-
- [GitHub](https://github.com/lucaspar)
49+
- [GitHub](https://github.com/lucaspar)
50+
51+
- Krzysztof Szewczyk
52+
53+
- [devRant](https://devrant.com/users/KrzysztofSzewczyk)
54+
- [GitHub](https://github.com/KrzysztofSzewczyk)

book/languages/brainfuck/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Welcome
2+
3+
> This chapter has been authored by Krzysztof Szewczyk "Παλαιολόγος".
4+
5+
Welcome to the Brainfuck chapter! I'd like to let you know a bit more about
6+
this awesome language.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Advantages
2+
3+
Generally speaking, currently, Brainfuck is seen as joke language or proof-of-concept language. Therefore, it's not very efficient, nor easy to write.
4+
5+
First of all, it's a really good exercise for your brain! Brainfuck, as the name suggests, is very hard to write and read, but not understand! You don't have to waste a lot of time just to understand this fascinating language, you can view it as Sudoku of programming.
6+
7+
Also, Brainfuck is a great learning tool. You can create code generators, optimizing interpreters, learn JIT & AOT compilation basics, compiler construction (by, for example, creating a compiler from Brainfuck to C or some kind of assembly language to Brainfuck).
8+
9+
Brainfuck is really simple too! It consists of eight instructions so it's really easy to learn.
10+
11+
Let's imagine Brainfuck computer - it would consume a really small amount of power (x86 has wide instruction set, ARM has it tighter, while Brainfuck destroys other real architectures having only eight!) and excel in simple tasks.
12+
13+
Finally, Brainfuck can help to **understand** the basics - how do you multiply two numbers? How do you create a conditional statement? In other languages, it might seem simple, but Brainfuck challenges the programmer creating this unique spirit.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Conclusion
2+
3+
Brainfuck was meant to be a joke language, and it would be reasonable to leave it's as is.
4+
5+
Thinking about Brainfuck in real terms is a bit risky, it's always quicker and easier to program other languages. On the other hand, Brainfuck brings back joy to
6+
programming allowing you to play around with the smallest units of a computer program while leaving language fully theoretical,
7+
not binding it to any definite machine (unlike Assembly, allowing you to feel not only joy while programming, but frustration too).
8+
To program Brainfuck, you'd need just a pencil and a reasonable amount of paper. Of course, you could do the same with other languages,
9+
but it's way less practical.
10+
11+
To play around with Brainfuck you need basically no experience - basic knowledge of maths and decent imagination are going to be
12+
sufficient.
13+
14+
Summing around disadvantages and advantages - Brainfuck is impractical and it shouldn't be considered real language. But there's
15+
nothing bad in playing with it!
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Disadvantages
2+
3+
Let's face it. Brainfuck is esoteric language. It was created as a joke, and conforming to author's will is recommended.
4+
There are many so-called Brainfuck hackers around, but being honest, You can't earn a living programming in Brainfuck.
5+
6+
Brainfuck is too impractical to be using language in real-world cases. Developers would cost way too much and work really
7+
inefficiently. Albeit low abstraction level, Brainfuck is memory and CPU time inefficient (a bit like JavaScript on web),
8+
so it's not very viable to write anything in bare Brainfuck and you'd be better off by using some kind of Brainfuck assembler,
9+
or HLL to brainfuck compiler, but none of the listed can beat pure C implementation instead of Brainfuck one.
10+
11+
Finally, the language is a bit limited - I/O is limited to console input and output, greatly reducing use cases.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# History
2+
3+
Brainfuck was first implemented and described by Urban Müller in 1993, attempting to design a language for which he could write
4+
the smallest possible compiler. The language was inspired by False. Müller decided to name his language brainfuck
5+
(with the initial letter in lower case, although it is now often capitalized). He uploaded the first Brainfuck compiler to Aminet
6+
in 1993. The program came with a readme file, which briefly described the language, and challenged the reader
7+
> Who can program anything useful with it? :)
8+
9+
Müller also included an interpreter and some quite elaborate examples
10+
11+
It is not known was Müller aware of or influenced by Böhm's language P'' (1964), of which brainfuck can be considered a minor
12+
variation.

book/languages/brainfuck/intro.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# Introduction
3+
4+
Brainfuck is the most famous esoteric programming language ever made. It's an esoteric language, so it was not meant to be used
5+
in solving real-world problems (but, no one forbids You too!). The language can't be classified clearly. Partly it's a very high-level language - Brainfuck doesn't bind itself to any architecture making it very portable language. On the other hand, it's very
6+
low-level language - it supports only addition and subtraction, basic control structure (`while`-like loop), basic I/O (terminal
7+
only, shrinking capabilities to the absolute minimum), and indefinitely long tape where any byte can be stored arbitrarily. Brainfuck
8+
is Turing complete, meaning that it is in the same computational class as universal Turing machines. This, plus its amount of
9+
instructions, makes it a most popular example of a Turing tarpit. This can be proven in many ways, with various restrictions on
10+
the brainfuck program or interpreter.
11+
12+
Daniel Cristofani wrote universal Turing machine emulator in Brainfuck which is so small we can quote it here:
13+
14+
```bf
15+
+++>++>>>+[>>,[>+++++<[[->]<<]<[>]>]>-[<<+++++>>-[<<---->>-[->]<]]<[<-<[<]+<+[>]<<+>->>>]<]<[<
16+
]>[-[>++++++<-]>[<+>-]+<<<+++>+>[-[<<+>->-[<<[-]>>-[<<++>+>-[<<-->->>+++<-[<<+>+>>--<-[<<->->-
17+
[<<++++>+>>+<-[>-<-[<<->->-[<<->>-[<<+++>>>-<-[<<---->>>++<-[<<++>>>+<-[>[-]<-[<<->>>+++<-[<<-
18+
>>>--<-[<<++++>+>>+<-[<<[-]>->>++<-[<<+++++>+>>--<-[<->>++<[<<->>-]]]]]]]]]]]]]]]]]]]]]]<[->>[
19+
<<+>>-]<<<[>>>+<<<-]<[>>>+<<<-]]>>]>[-[---[-<]]>]>[+++[<+++++>--]>]+<++[[>+++++<-]<]>>[-.>]
20+
```
21+
22+
Simulation is one way to prove Turing completeness:
23+
24+
> If an interpreter for A can be implemented in B, then B can solve at least as many problems as A can.
25+
26+
There are some difficulties with this way of proving Turing completeness (ℒ), but for Brainfuck, it's entirely sufficient. By theory,
27+
it's ℒ-complete too, so the proof is fully valid.
28+
29+
Brainfuck is an amazing language. One must still understand where it would be suitable, and where it doesn't particularly excel
30+
at.

0 commit comments

Comments
 (0)