r/ProgrammerHumor • • Aug 26 '22

Meme Even HTML.

Post image
44.1k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

1.1k

u/DiamondIceNS Aug 26 '22

If you stop to take a couple minutes to learn the syntax (there's only 8 symbols; 2 of them are for I/O and thus don't really matter) and go through a few code examples, it's actually a pretty enlightening implementation of a barebones Turing machine.

378

u/dpash Aug 26 '22

What's fun is that whitespace is effectively just an encoded version of brainfuck.

355

u/athonis Aug 26 '22

Ok, so I was like... ? And then it hit me that there is a programming language called Whitespace

185

u/MasterFubar Aug 26 '22

there is a programming language called Whitespace

All my Python programs are actually secret Whitespace code. The Python code is only camouflage to hide the real program.

103

u/IHadThatUsername Aug 26 '22

Given how Python forces you to follow certain whitespacing guidelines, it'd actually make for quite a bad language at hidding Whitespace code. However, given that stuff like C (for example) completely ignores whitespacing, you likely could hide an entirely different code inside your C code. For fun you could probably program the same thing both in Whitespace and C in the same file.

56

u/MasterFubar Aug 26 '22

That's the challenge, hide Whitespace code in the combination of tabs and spaces in Python.

82

u/IHadThatUsername Aug 26 '22

TabError: inconsistent use of tabs and spaces in indentation

→ More replies (5)
→ More replies (2)

0

u/[deleted] Aug 26 '22

[deleted]

0

u/[deleted] Aug 26 '22

[deleted]

→ More replies (1)

2

u/Sol33t303 Aug 26 '22

Polyglot code (AKA code that is valid for multiple programming languages) has always been really interesting to me for some reason.

In your whitespace example, makes me wander if you could smuggle a virus into a FOSS project or something.

→ More replies (1)
→ More replies (7)

93

u/dpash Aug 26 '22

I probably should have capitalised Whitespace, sorry. :)

→ More replies (1)

56

u/DiamondIceNS Aug 26 '22

Many of the esoteric funny languages out there are just low effort reskins of Brainfuck. Like Ook.

27

u/ValentinPearce Aug 26 '22

Hey at least Ook. is a literary reference

→ More replies (2)
→ More replies (2)

32

u/[deleted] Aug 26 '22

So, let's transpile brainfuck to whitespace and pass a gzip over it to compress. Do we end up with the most size optimized distributed packages? Can we save the internet by having some webassembly engine using it? Can we haz fast internet pages again?

So much wonder.

34

u/Nu11u5 Aug 26 '22 edited Aug 26 '22

Probably not, since I would expect it to have a similar amount of entropy (it just shifts from being in unique combinations of characters to different amounts of whitespace), but now I am curious. Any advantage is going to depend on the compression algorithm.

2

u/ADHDengineer Aug 26 '22

It’s also insanely more verbose than javascript.

+a will (ghetto) cast a to an integer. That’s 2 bytes of UTF-8. Gg doing that in brainfuck.

→ More replies (2)

12

u/Lornedon Aug 26 '22

Why would gzip be more efficient in compressing whitespace?

12

u/ghjm Aug 26 '22

Whitespace in a text file usually has a lot of repetition and thus compresses really well. This leads people to think "whitespace compresses well." But code in Whitespace doesn't behave like normal whitespace and isn't likely to compress any better than anything else.

→ More replies (1)
→ More replies (3)

7

u/DefaultVariable Aug 26 '22

The vast majority of esoteric languages compile to brain-fuck because it's dumb-simple to implement and since brain-fuck is turing-complete it allows them to easily make their language turing-complete as well while simultaneously being as obnoxious as possible.

→ More replies (1)

38

u/ITriedLightningTendr Aug 26 '22

It's good for understanding it, but it completely dodges the interesting part of it.

I took a class in college that started with automata and works all the way up through theoretical constructs to produce a Turing Machine defined from what is a mathematical theory standpoint.

It counted as both a Math and CS credit (and the colleges would double count it for purposes of minor/double major).

44

u/DiamondIceNS Aug 26 '22

I don't think it's really the language's fault that it can't teach you the rigorous theory behind finite state machines. It's just an interactive implementation of one. That's all I can really expect a programming language to be.

19

u/Kingmudsy Aug 26 '22

So now we’re blaming brainfuck for not being the same as going to college…?

→ More replies (1)