Hacker News new | ask | show | jobs
A Brainfuck interpreter written in PostScript (github.com)
117 points by romac 924 days ago
14 comments

This has got to be peak <something>. I don't know what exactly, but it's something. Self-inflicted torment and/or eccentric fountain of joy. Probably both.

I cannot, for the life of me, see myself investing the time needed into something so futile. But I love that there are people out there who do this kind of thing out of pure joy.

I'm the author of bfps. I don't have too much time either. But I do enjoy this kind of brainb^Hteaser while commuting in the train :)
I love this idea. Instead of doomscrolling news or giving your time to the attention economy in other ways, this is like solving interesting puzzles.
Brainfuck, while difficult to actually use, is very easy to implement. There is one array data structure of ints, and iirc 8 operators that work on the array. They either manipulate the current pointer to the array cell by either moving up or down, or increment or decrement the value there. And then there is a simple conditional and a print command. That's it. You can write that in an afternoon if not in an interview session. Now actually doing something productive with the language is a whole different situation. It's clearly Turing-complete as the infinite paper is just the array and the operations are exact copies. A fun little exercise.
These are the people which will be fighting for us in 20 years, from within some hidden cyberbunkers in the city sewerages.
At one point I was considering writing, in Postscript, a Brainfuck compiler whose compilation target is a Magic the Gathering based Turing machine.

I did not accomplish this.

I gotta say, the idea is amazing!
Definitely, Brainfuck squared.
Close.

Peak <something> would be a PostScript interpreter written in Brainf***.

oh no
To be peak brainfuckery, the GUI must only accept Morse code.
Amen!

I read the title and recoiled in horror, and yet I am fascinated by the project.

The most awesome random submission I ever received was a BrainFuck compiler written in BrainFuck, by hand. Short story: I wrote a bf compiler in Emacs Lisp many many years ago. As a small testcase, I included a BrainFuck compiler in BrainFuck, which was written by a guy who wrote a C-alike to BrainFuck compiler so that he could implement his BF compiler in BF. That was a strange piece of code, about 6 pages of plain BF. A few years later, suddenly, I have this mail in my INBOX: A norwegian guy sent me a BF compiler in BF, written by hand. He was unsatisfied by the existing BF compiler, as it was generated. His implementation was about 6 lines of BF code. And it was a magnitude faster. Hats off to that guy!
How do you implement a compiler in 6 lines of code, let alone 6 lines of BF code?
Whitespace is ignored in Brainfuck, so just write the compiler in brainfuck and then strip all but 6 newlines.
I think lines should be hard wrapped at around 100 or 120. Linus prefers 100 for example.
This is such a Brainfuck answer
Just a helpful resume tip. If you work on something in Brainfuck, put it on your resume as BF. And don't mention the name of your multi-threaded BF environment.
Wonder what to use for MongoDb. "Mongo" is a nasty slur for a person with Downs syndrome in Norwegian
I was told mongoloid was the politically correct term to use instead of retarded lol

Personally I always thought it sounded more demeaning, kinda sounds like some less developed homosapian ancestor, almost like calling someone a neanderthal

I don't think that term has been appropriate for a long time... Wikipedia seems to indicate similarly.

https://en.m.wikipedia.org/wiki/Mongolian_idiocy

I saw someone on Rocket League use that term as an insult. When I said it was a slur, they said it just meant "stupid", heh. No, buddy... there's a lot more to it than that.

There was a lot more to it than that. Insults tend to gradually lose their meaning until they just become synonyms for "stupid". E.g. "idiot", "dumb", "gay".
I’m hoping the official term of art is either a clusterfuck or a fuckfest?
I'm not going to write the term I saw on a resume, but it starts with a b and may be a Japanese word.
https://bitbucket.org/wjmelements/bukkake/ I take it?

I’m surprised it didn’t make more of a splash.

This is what I've seen others qualify as "quite cursed".
PostScript is actually a pretty nice programming language, once you get used to it.

Edit: I used it for a few years within NeWS & HyperNeWS.

I think that's what they call Stockholm syndrome
I think that's a bit harsh - this was a complex system written in Common Lisp that had a front end in NeWS with some C plumbing linking the two together.

PostScript and Lisp are actually pretty similar when the former is used in an interactive graphical environment (i.e. not on a printer!).

I said it in jest, sorry. I wrote a bit of PostScript because I absolutely had to and it was painful, even though I was thrilled to eventually push through.

But I'm very particular about syntax, so the reverse polish notation was enough to upset me. Needless to say, I appreciate Lisp for its power and conceptual simplicity but would never choose to use it.

Out of interest, which programming language do you prefer?
PostScript is a pretty good programming language for what it's meant to do, which is put vector graphics in a box. It was the first language I wrote a lot of code in just for fun and not for school or work, specifically to draw a bunch of fractals. It's particularly well suited for that type of graphics whose structure is mathematically determined by a simple algorithm.
I mean, it’s a perfectly serviceable postfix Lisp. Postfix Lisps are nice! Other things in the page layout language are less nice (e.g. the nonexistent i18n), but the programming parts are quite pleasant, I think.
Postscript is actually surprisingly approachable. It's quite easy to implement logo-like "turtle graphics" and draw fractals in it.
37 years ago: "Why wouldn't you want some random file to be able to execute random code on any and every machine that its on?"
The description is glorious:

---

A Brainfuck interpreter written in PostScript

This program aims at being accurate, readable and minimal.

----[---->+<]>++.+[--->++<]>-.+.------------.--[->++++<]>-.[->+++<]>.+++++++..[++>---<]>--.+[->+++<]>+.+++++++++++.-.---------.--[--->+<]>.-..---[->+++<]>.+++[->++++<]>+.+++++++++++.------------.--[--->+<]>--.[->+++<]>+.-[->+++<]>.+[->+++<]>+.+.---.[--->+<]>-.++[->+++<]>++.-[--->+<]>--.+[->+++<]>++.+++++++++.++++++++.[------>+<]>.+++++++++.---.-.-.--------.+++++++++.++++++.[---->+<]>+++.[->+++<]>+.+++++++++++++.----------.-[--->+<]>-.---[->++++<]>+.-------.-----.+++++++++++.[---->+<]>+++.---[->++++<]>.+++[->+++<]>.[--->+<]>----.+.[---->+<]>+++.-[--->++<]>--.-------.--[--->+<]>---.----.---------.[--->+<]>----..+[++>---<]>.++[--->++<]>..>-[--->+<]>--.[--->+<]>-.----.-------.+++++++++.----------.+++++.-----.[->+++<]>.------------.-[--->++<]>-.+++++.----------.+..-.-[--->+<]>..
The inventor of brain fuck also gave us the Sauerbraten engine with its octree geometry storage as maps.
Out of curiosity I landed at http://sauerbraten.org and was not disappointed by the trailer.
I had no idea, that's awesome; used to love Red Eclipse 2, and my father once roped my siblings and I into playing Urban Terror, both of which we owe to Cube
Now, do the inverse and implement postscript in BF
Some people just love pain it seems
Sadomasochism is alive an well.
Surely it's hurting?
Code looks good! Postscript is a pretty sweet alternative to forth.
Back in the olden days, it was not uncommon to print bitmap graphics files from compressed graphics source (e.g., gif, jpg, tif¹) by sending code to decompress the compressed graphics data alongside a base64-encoding of the data.

1. These were the only compressed graphics format options available back then.

I hate it in the best way possible.
Would it work on a printer?
Looks like it. I wrote one years ago that does [1] (a BF compiler actually) and this looks similar.

(Some other fun PS ditties at that link.)

[1] https://chris.pacejo.net/stuff/postscript/index

… are you telling me there’s 2 BF PS compilers?
Only one to my knowledge; the OP is an interpreter.
What is wrong with you people
"Some men just want to watch the world burn."