Few imagine the immense variety of programming languages ​​that are available. Certainly a great variety like RPG, Forth, Fortran, Lisp, PL / I, Logo, C, Pascal, Perl, Python, TCL, Ada , Java, etc. But today we do not come to talk about these, today the prominence is taken by Brainfuck but before. The first thing one learns when learning a new programming language is to write “Hello world.” It is one of the most widespread topics in the world and it has already become a tradition that makes more than one feel uncomfortable if they do not learn that way. For example, in C ++, one of the languages ​​that we use in the Online Course on Video Game Programming with C ++, hello world would be written like this: cout << “Hello world << endl;.

But why the name? How difficult is this language? Well, it’s actually not as difficult as we think. There are only 8 possible instructions and they only have one character:> and <that increase and decrease the pointer, + and – that increase and decrease the pointed byte,. which writes the byte,, which reads a byte, and [] which forward or backward instructions. If you look at it, on the hello world line you have 11 points: one for each letter and the space. What’s more, if you look at it, there are two points together: the two l’s for hello. In fact, it goes something like this:

++++++++++

[Loop to start memories (repeats 10 times)

> +++++++>++++++++++>+++++++++++> +++>+ <<<<< –

70 100 110 30 10

]

> ++. prints ‘H’ (72) 1

>> +. print ‘o’ (111) 3

—. ‘l’ (108) 3

<—. ‘a’ (97) 2

>> ++. space (32) 4

<+. ‘m’ (109) 3

++++++++. ‘u’ (117) 3

——-. ‘n’ (110) 3

<+++. ‘d’ (100) 2

> +. ‘or’ (111) 3

> +. ‘!’ (33) 4

>. ‘\ n’ (10) 5

Well, there is some difference with C ++. More code samples on brainfuck? A random number generator: >>> ++ [<++++++++ [<[<++> -] >> [>>] + >> + [- [- >> + <<< [<[<<] <+>]> [> [>>]]] <[>> [-]]> [> [- <<]> [<+ <]] + <<] <[> + <-] >> – ] <. [-] >>] Or the famous bubble algorithm, which our students from the Unreal or Ogre course know well: >>, [>>,] << [[<<] >>>> [<< [> + << +> -] >> [> + <<<< [->]> [<] >> -] <<< [[-] >> [> + <-] >> [<<< + >>> -]] >> [[<+> -] >>] <] << [>> + << -] <<] >>>> [. >>. Undoubtedly a rather curious language and somewhat complicated for those who are not knowledgeable but, that depends on each one and it is like everything, if you practice it sooner or later you will master it.

Related reads:
LolCode – An esoteric programming language
Erlang is a peculiar programming language


2 comentarios en «Brainfuck – A big language challenge»

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *