Д.М. ([info]d_m_) wrote,

Век живи - век учись!

Сегодня совершенно случайно узнал о существовании языка программирования со скромным, но интригующим названием Brainfuck. Навел справки - и узнал массу интересного. А главное - полезного! :)

Вот изложение истории языка и полное его описание:

Brainfuck

An Eight-Instruction Turing-Complete Programming Language

Brainfuck is the ungodly creation of Urban Müller, whose goal was apparently to create a Turing-complete language for which he could write the smallest compiler ever, for the Amiga OS 2.0. His compiler was 240 bytes in size. (Though he improved upon this later -- he informed me at one point that he had managed to bring it under 200 bytes.)

I originally started playing around with Brainfuck because of my own interest in writing very small programs for x86 Linux. I also used it as a vehicle for writing a program that created ELF files. Eventually, however, I too succumbed to the Imp of the Perverse and wrote some actual Brainfuck programs of my own.

The Language

A Brainfuck program has an implicit byte pointer, called "the pointer", which is free to move around within an array of 30000 bytes, initially all set to zero. The pointer itself is initialized to point to the beginning of this array.

The Brainfuck programming language consists of eight commands, each of which is represented as a single character.

Increment the pointer.
Decrement the pointer.
Increment the byte at the pointer.
Decrement the byte at the pointer.
Output the byte at the pointer.
Input a byte and store it in the byte at the pointer.
Jump forward past the matching ] if the byte at the pointer is zero.
Jump backward to the matching [ unless the byte at the pointer is zero.

http://www.muppetlabs.com/~breadbox/bf

Вот интерпретатор BF с примерами программ на BF:

http://esoteric.sange.fi/brainfuck/compiled/win/DBFI.zip

 


Так выглядит HelloWorld:

>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]
<.#>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[
<++++>-]<+.[-]++++++++++.


А вот нахождение всех делителей числа, с авторскими комментариями:
(проверял, оно работает!!)

* factor an arbitrarily large positive integer
*
* Copyright (C) 1999 by Brian Raiter
* under the GNU General Public License

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>-

*
* read in the number
*

<<<<<<<<<+
[-[>>>>>>>>>>][-]<<<<<<<<<<[[->>>>>>>>>>+<<<<<<<<<<]<<<<<<<<<<]
  >>>>>>>>>>,----------]
>>>>>>>>>>[------------------------------------->>>>>>>>>->]
<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]-

*
* display the number and initialize the loop variable to two
*

[>++++++++++++++++++++++++++++++++++++++++++++++++.
  ------------------------------------------------<<<<<<<<<<<]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
--------------------------.[-]
>>>>>>>>>>>>++<<<<+

*
* the main loop
*

[ [-]>>

  *
  * make copies of the number and the loop variable
  *

  [>>>>[-]>[-]>[-]>[-]
    >[-]>[-]
    <<<<<<<[->>>+>+<<<<]>>>>>>>>]
  <<<<<<<<<<[>>>>>>[-<<<<+>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>>
  [>[->>>+>>+<<<<<]>>>>>>>>>]
  <<<<<<<<<<[>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>>

  *
  * divide the number by the loop variable
  *

  [>>>[-]>>>[-]>[-]>>>]                                  initialize
  <<<<<<<<<<[<<<<<<<<<<]
  >>>>>>>>>[-]>>>>>>>+<<<<<<<<[+]+
  [ ->>                               double divisor until above dividend
    [>>>>>>[->++<]>>>>]<<<<<<<<<<
    [>>>>>>>>[-]>[-]
       <<<<[->>>++<<<]<<<<<<<<<<<<<<<]>>>>>>>>>>
    [>>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<
            [->--------->>>>>>>>>+<<<<<<<<<<[->+<]]]]]]]]]]]>>]
    <<<<<<<<<<[>>>>>>>>>[-<+<<<+>>>>]<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>
    [>>>>>>>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>
            [-<--------->>>>>>>>>>>+<<<<<<<<<<[-<+>]]]]]]]]]]]>>>]
    <<<<<<<<<<
    [>>>>[->>>+>>+<<<<<]<<<<<<<<<<<<<<]
    >>>>>>>>>>[>>>>>>>[-<<<+>>>]>>>]<<<<<<<<<<
    [>>>>>>>>[->-<]>
      [<<<<<<<<<[<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<]
        >>>>>>>>>>>>>>>>>>>]
      <<<<<<<<<<<<<<<<<<<]
    >>>>>>>>>[+[+[+[+[+[+[+[+[+[+[[-]<+>]]]]]]]]]]]<
  ]
  >>>>>>>>
  [                                   subtract divisor from dividend
    <<<<<<
    [>>>>>>>>[-]>[-]<<<<<[->>>+>+<<<<]>>>>>>]<<<<<<<<<<
    [>>>>>>>>[-<<<<+>>>>]<<<[->>>+>+<<<<]<<<<<<<<<<<<<<<]>>>>>>>>>>
    [>>>>>>>>>[-<<<<+>>>>]>]<<<<<<<<<<
    [>>>>>>>>[-<->]<<<<<<<<<<<<<<<<<<]>>>>>>>>>>
    [>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<
            [++++++++++[+>-<]>>>>>>>>>>-<<<<<<<<<<]]]]]]]]]]]>>>]
    >>>>>>>+
    [                                 if difference is nonnegative then
      [-]<<<<<<<<<<<<<<<<<            replace dividend and increment quotient
      [>>>>[-]>>>>[-<<<<+>>>>]<<[->>+<<]<<<<<<<<<<<<<<<<]>>>>>>>>>>
      [>>>>>>>>[->+<<<+>>]>>]<<<<<<<<<<
      [>>>[->>>>>>+<<<<<<]<<<<<<<<<<<<<]>>>>>>>>>>
      [>>>>>>>>>[-<<<<<<+>>>>>>[-<<<<<<+>>>>>>
                [-<<<<<<+>>>>>>[-<<<<<<+>>>>>>
                [-<<<<<<+>>>>>>[-<<<<<<+>>>>>>
                [-<<<<<<+>>>>>>[-<<<<<<+>>>>>>
                [-<<<<<<+>>>>>>[-<<<<<<--------->>>>>>>>>>>>>>>>+<<<<<<<<<<
                [-<<<<<<+>>>>>>]]]]]]]]]]]>]
      >>>>>>>
    ]                                 halve divisor and loop until zero
    <<<<<<<<<<<<<<<<<[<<<<<<<<<<]>>>>>>>>>>
    [>>>>>>>>[-]<<[->+<]<[->>>+<<<]>>>>>]<<<<<<<<<<
    [+>>>>>>>[-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+>
             [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+>
             [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+>
             [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+>
             [-<<<<<<<+>>>>>>>]]]]]]]]]<<<<<<<
             [->>>>>>>+<<<<<<<]-<<<<<<<<<<]
    >>>>>>>
    [-<<<<<<<<<<<+>>>>>>>>>>>]
      >>>[>>>>>>>[-<<<<<<<<<<<+++++>>>>>>>>>>>]>>>]<<<<<<<<<<
    [+>>>>>>>>[-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>>
              [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>>
              [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>>
              [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>>
              [-<<<<<<<<+>>>>>>>>]]]]]]]]]<<<<<<<<
              [->>>>>>>>+<<<<<<<<]-<<<<<<<<<<]
    >>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>]>>
    [>>>>>>>>[-<<<<<<<<<<<<<+++++>>>>>>>>>>>>>]>>]<<<<<<<<<<
    [<<<<<<<<<<]>>>>>>>>>>
    >>>>>>
  ]
  <<<<<<

  *
  * make copies of the loop variable and the quotient
  *

  [>>>[->>>>+>+<<<<<]>>>>>>>]
  <<<<<<<<<<
  [>>>>>>>[-<<<<+>>>>]<<<<<[->>>>>+>>+<<<<<<<]<<<<<<<<<<<<]
  >>>>>>>>>>[>>>>>>>[-<<<<<+>>>>>]>>>]<<<<<<<<<<

  *
  * break out of the loop if the quotient is larger than the loop variable
  *

  [>>>>>>>>>[-<->]<
    [<<<<<<<<
      [<<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<]
    >>>>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<]
  >>>>>>>>[>-<[+[+[+[+[+[+[+[+[+[[-]>+<]]]]]]]]]]]>+

  [ [-]

    *
    * partially increment the loop variable
    *

    <[-]+>>>>+>>>>>>>>[>>>>>>>>>>]<<<<<<<<<<

    *
    * examine the remainder for nonzero digits
    *

    [<<<<<<[<<<<[<<<<<<<<<<]>>>>+<<<<<<<<<<]<<<<]
    >>>>>>>>>>>>>>>>>>>>[>>>>>>>>>>]<<<<<<<<<<[<<<<<<<<<<]
    >>>>-

    [ [+]

      *
      * decrement the loop variable and replace the number with the quotient
      *

      >>>>>>>>-<<[>[-]>>[-<<+>>]>>>>>>>]<<<<<<<<<<

      *
      * display the loop variable
      *

      [+>>[>>>>>>>>+>>]<<-<<<<<<<<<<]-
      [>>++++++++++++++++++++++++++++++++++++++++++++++++.
         ------------------------------------------------<<<<<<<<<<<<]
      ++++++++++++++++++++++++++++++++.[-]>>>>

    ]

    *
    * normalize the loop variable
    *

    >>>>>>
    [>>[->>>>>+<<<<<[->>>>>+<<<<<
       [->>>>>+<<<<<[->>>>>+<<<<<
       [->>>>>+<<<<<[->>>>>+<<<<<
       [->>>>>+<<<<<[->>>>>+<<<<<
       [->>>>>+<<<<<[->>>>>--------->>>>>+<<<<<<<<<<
       [->>>>>+<<<<<]]]]]]]]]]]>>>>>>>>]
    <<<<<<<<<<[>>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<<]
    >>>>>>>>>

  ]<

]>>

*
* display the number and end
*

[>>>>>>>>>>]<<<<<<<<<<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]-
[>++++++++++++++++++++++++++++++++++++++++++++++++.<<<<<<<<<<<]
++++++++++.



Вот тоже неслабый примерчик:
   
   The BF interpreter in BF (when filtered through a comment remover)
   looks like:

>>>,[->+>+<<]>>[-<<+>>]>++++[<++++++++>-]<+<[->>+>>+<<<<]>>>>[-<<<<+>>
>>]<<<[->>+>+<<<]>>>[-<<<+>>>]<<[>[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+<<<<<]>[->>>>>+<<<<<]>>>+>-]>[[-]<+[<[->>>>>+<<<<
<]>[->>>>>+<<<<<]>>>>+>>>[->>+<<<+>]<[->+<]>>>[-[-[-[-[-[-[-<<<+>>>[<<
<->>>[-]]]]]]]]]<<<[<+>[-]]>[->>+<<<+>]<[->+<]>>>[-[-[-[-[-[-[-[-<<<+>
>>[<<<->>>[-]]]]]]]]]]<<<[<->[-]]<]>[-]]<<[->>>>>+<<<<<]>>>>>+>[-]]>>[
-<+<+>>]<<[->>+<<]>[-[-[-[-[-[-[-[-<+>[<->[-]]]]]]]]]]<[[-][-]<[->+>+<
<]>>[-<<+>>]<<[[-<<<<<+>>>>>]>[-<<<<<+>>>>>]<<<<<<-]<<<<<<<<[-]>>>>>>>
>>[-<<<<<<<<<+>>>>>>>>>]<<<<<<<<<<[->>>>>>>>>>+<+<<<<<<<<<]>>>>>>>>>[-
<<<<<<<<<+>>>>>>>>>]>[<[->>>>>+<<<<<]>[->>>>>+<<<<<]>>>>+>-]>>>[-<<<+>
+>>]<<[->>+<<]<<[[-<<<<<+>>>>>]>[-<<<<<+>>>>>]<<<<<<-]>[-<<<<<<+>>>>>>
]<<<<<<[->>>>>>>+<<<<<<<]<<<[->>>>>>>>>+<<<<<<+<<<]>>>[-<<<+>>>]>>>>>>
[<[->>>>>+<<<<<]>[->>>>>+<<<<<]>[->>>>>+<<<<<]>>>+>-]>[[-]<+[<[-<<<<<+
>>>>>]>[-<<<<<+>>>>>]<<<<<<->>>[->>+<<<+>]<[->+<]>>>[-[-[-[-[-[-[-<<<+
>>>[<<<->>>[-]]]]]]]]]<<<[<->[-]]>[->>+<<<+>]<[->+<]>>>[-[-[-[-[-[-[-[
-<<<+>>>[<<<->>>[-]]]]]]]]]]<<<[<+>[-]]<]>[-]]<<[->>>>>+<<<<<]>>>>>+>[
-]]>>]


  • Post a new comment

    Error

  • 16 comments

[info]doppeltes

March 1 2005, 03:11:38 UTC 7 years ago

Машина Тьюринга, блин :)

Вообще этот язык довольно просто интерпретировать. А если написать для него ещё конвертатор туда-сюда в ассемблер (или даже C с ограничениями), то вполне можно такой изврат всавлять куда-нибудь :)

[info]d_m_

March 1 2005, 03:33:15 UTC 7 years ago

Простота интерпретации сомнений не вызывает :) Особенно если учесть тот факт, что автор втиснул транслятор в 200 байтов :)) А насчёт вставлять... да... это идея... например, если заказчик потребует исходники, самые важные фукции срочно конвертнуть в BF! %)

[info]fester_ua

March 1 2005, 04:22:59 UTC 7 years ago

Простите, 240 байт. НА той машинке 40 байт асмового кода -- это эгегей!

[info]d_m_

March 1 2005, 05:05:16 UTC 7 years ago

А в скобочках: Though he improved upon this later -- he informed me at one point that he had managed to bring it under 200 bytes

[info]fester_ua

March 1 2005, 05:19:02 UTC 7 years ago

Простите :)

[info]infanticida

March 14 2005, 14:37:07 UTC 7 years ago

Скорее Маркова. =)

Anonymous

March 19 2005, 05:55:37 UTC 7 years ago

вообще это яркий пример супер-упрощенного форт-процессора. Просто, но нужно хоть константы цифр добавить, ато уж больно неэффективно инкрементами/декрементами начальные условия устанавливать.
да и двоичная логика (add/and/or/xor) не помешает, если уж говорить о реальном применении, а иначе очень медленно будет, не смотря на простоту.

дальше - команды [ ] не есть командами risc, поскольку требуют дополнительную память хранения (стек, как вариант) и предвыборку - нужно добавить команды "пропуск следущего опкода если 0" и "переход по адресу..".

Вобщем если этот язык преобразовать под _быструю_ интерпретацию, получим форт-процессор :)

С Уважением, zyxman.

[info]d_m_

March 19 2005, 07:00:10 UTC 7 years ago

zyxman, а ну быстро сюда!

[info]megavolt_ss

March 2 2005, 19:23:26 UTC 7 years ago

Мощ

[info]2xf

March 18 2005, 20:49:30 UTC 7 years ago

rulez! LOL переводим все промышленное программирование на этого мозгоеба! ;)

Anonymous

March 18 2005, 20:58:06 UTC 7 years ago

да, еще надо как-то перфокарты задействовать. Тогда ващще будет тема!

[info]gone_one

April 18 2005, 23:10:18 UTC 7 years ago

Супер :)

[info]muchandr

April 26 2005, 15:15:41 UTC 7 years ago

Существует еще более минималистический язык, Unlambda.

[info]muchandr

April 26 2005, 15:25:32 UTC 7 years ago

Тоже уже переплюнули, оказывается. Вот вроде текущий рекордсмен:

http://homepages.cwi.nl/~tromp/cl/lazy-k.html

Anonymous

October 20 2006, 06:50:06 UTC 5 years ago

Самый рульный язык это Ook! Все его команды это Ook. Ook! Ook? Изощряйтесь макаки!

Anonymous

August 5 2007, 06:06:56 UTC 4 years ago

Мой компилятор

Я знаю о Brainfuck всего два дня. Но мне очень понравилось на нём писать. Вот моя версия компилятора.
http://ifolder.ru/2898078
Он очень простой. Может комуто понадобится.
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…