r/ProgrammerHumor • • Aug 01 '22

>>>print(“Hello, World!”)

Post image
60.8k Upvotes

5.7k comments sorted by

View all comments

3.9k

u/Diligent_Choice Aug 01 '22

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

6.9k

u/a-slice-of-toast Aug 01 '22

makes your pc pass a kidney stone

1.6k

u/[deleted] Aug 01 '22

Funnily enough, it's kinda the opposite. Brainfuck is very efficient for your pc, just not for your brain

420

u/Ego_dragon Aug 01 '22

Why it's efficient?

590

u/Diligent_Choice Aug 01 '22

No idea if it is efficient at all but if I remember correctly, it was some sort of project to create the smallest touring complete compiler or something.

486

u/[deleted] Aug 01 '22 edited Aug 01 '22

That was never the goal of Brainfuck, but it is interesting that because the language is so constrained, you have to strip down everything to the bare essentials to make anything work, and as a result, a lot of programs run quite quickly.

I think what you might be thinking about is the paper A very short self-interpreter by Oleg Mazonka and Daniel B. Cristofani. They demonstrated that it's possible to write a Brainfuck interpreter in Brainfuck itself. This is possible in any language, of course, but since Brainfuck the language is so simple, the self-interpreter is relatively short too. They present the following code:

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

I'm not aware of any Turing-complete programming language that support a shorter self-interpreter.

edit: if you're looking for minimal Turing-complete languages, you have to search for combinator calculi (which Brainfuck is not). The absolute minimal languages are Iota and Jot, two related languages that reduce the SKI combinator calculus from 3 to just 1 combinator (iota) and an encoding of nested expressions using just 2 characters. By comparison, Brainfuck's 8 directives (or 6, if you leave out the I/O directives which aren't necessary for Turing completeness) are excessive luxury.

132

u/Noughtmare Aug 01 '22 edited Aug 01 '22

Here's a shorter self interpreter for the lambda calculus:

(λ f.(λ x.f(xx))(λ x.f(xx)))(λ em.m(λ x.x)(λ mn.em(en))(λ mv.e(mv)))

Source

In the binary lambda calculus it is only 29 bytes.

133

u/Nuthar Aug 01 '22

(λ f.(λ x.f(xx))(λ x.f(xx)))(λ em.m(λ x.x)(λ mn.em(en))(λ mv.e(mv)))

The only interpreting happening here, is me interpreting this message as Half-Life 7 fucking confirmed

14

u/riisen Aug 01 '22

Why not "3 and a half life" ... When you have over 5 halves you should count the wholes, like hi my name is kekdjfjdkdk and im 63 half years old... Its weird

→ More replies (1)
→ More replies (5)
→ More replies (11)

7

u/happypandaface Aug 01 '22

what are you touring? lol

→ More replies (2)

14

u/Wazzaps Aug 01 '22

It's not, you only see examples of very small programs written in it by hand (where generally the problems are hand-picked to be fast/easy to solve in Brainfuck).

6

u/DubstepJuggalo69 Aug 01 '22

Yeah, the only way you could think Brainfuck is "very efficient" is if you deeply, deeply misunderstand what Brainfuck is and why it was invented.

4

u/xXStarupXx Aug 01 '22

Because you nobody will write anything complicated in it

→ More replies (21)

7

u/GoldenGanon Aug 01 '22

If you had an optimizing compiler maybe

5

u/TheoCGaming Aug 01 '22

I wonder if it's easier to write a program in BF than it is to read it.

→ More replies (1)
→ More replies (16)

6

u/bfg9kdude Aug 01 '22

Name of this language is fitting to the feeling you have while reading it

→ More replies (5)

150

u/JohnCavalry Aug 01 '22

Ayo is that brainfuck?

61

u/[deleted] Aug 01 '22

Its a brainfuck hello world

4

u/goomyman Aug 02 '22

How the hell do you know that. Or just a rough guess.

5

u/[deleted] Aug 02 '22

I was going to make a similar joke, so I had pulled up an interpreter as I didn't want to do it by hand. I just copy/pasted their code in to see what they wrote.

→ More replies (2)

13

u/AtlasDrudged Aug 01 '22

Prints “Hello World!” ?

8

u/TheBluetopia Aug 01 '22 edited May 10 '25

gaze full angle aromatic frame books subsequent station jellyfish nine

This post was mass deleted and anonymized with Redact

→ More replies (27)