Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: A partial HTTP server written in brainfuck extended with syscalls (github.com/ajyoon)
103 points by ajyoon on Dec 9, 2016 | hide | past | favorite | 59 comments



I think the best approach for the Brainfuck madness is to write a compiler/transpirer from a high level language (e.g. LOLCODE) to generate Brainfuck code. Then you can write your app in the high level language and show off the generated Brainfuck code.


If anyone out there in Internet land is going to do this, please, please select INTERCAL as the high-level language, I implore you.


I put in a vote for Malbolge


Ooh, or the highest-level language, Homespring. http://xeny.net/Homespring


I kind of want to implement that now...


It's really cute how the author added $ to insert a debugging break into the source. Instead of "debugging by printf", which is a bit tedious in brainfuck, this is driving your debugger by editing the source code. Bravo!


You laugh, but Python works the same way.


I recently learned you can do a similar thing with C/C++ too. Programmatically raise a SIGINT when running under gdb, and gdb will intercept that signal, at which point you can step through the code.


Yeah, in Windows you have the `DebugBreak/__debugbreak()` function [0].

For POSIX you have `raise(SIGTRAP)` or gcc you have `__builtin_trap()` which actually has some caveats. [1]

[0] https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...

[1] https://stackoverflow.com/questions/173618/is-there-a-portab...


I was laughing in a good way, it's always cool to see not only the "thing" but how it was debugged.

As for python, I debug it by adding print() statements. No debugger involved. If there's a way to insert debugger breakpoints in the source, I'm unaware of it.


import pdb ; pdb.set_trace()


Pdb has saved my sanity so many times I have lost count.


And I often find this very useful in JavaScript


It's fantastic how the author was able to get this up and running, but not the hello world example.


listen...


This is perhaps the most Hacker News headline ever.


This is madness. Also, has anyone noticed the Brainfuck interpreter is written in assembly?!


>the Brainfuck interpreter is written in assembly?!

Having reached the lowest level of the machine, they started digging...


Lol and assembly is more readable.


Isn't leaving comments or whitespace in brainfuck code considered bad form?


There is a minified version here if you're into that kind of thing https://github.com/ajyoon/systemf/blob/master/examples/http/...


lol


Is this idiomatic Brainfuck?


can we talk about how github has code highlighting supports brainfuck?

I didn't really expect that


I was impressed, but then again it's like a 1h project so anyone with an interest can do it.


Please, I have a family. Don't do this.


Because the brainfuck syntax is very simple, it's not really hard to generate a valid program from random characters.

The language is also Turing complete.

It is possible to use genetic programming (and other approaches) to generate brainfuck programs without an insane amount of effort.

Eventually the resulting program can be processed to be made more efficient.


So we've come to this. At least it's not another javascript framework (ducks).


Baby steps, but we will eventually get to reactive-brainfuck.


I've already filed a patent for BaaS (Brainfuck as a service), so don't even think about it guys. I'm in it for the long run ;)


That's funny because I already had this patent describing:

"Combination of Brainfuck with paper mediums for transmission to location for processing, storage, distribution, and archiving of said combinations."

If you made a Brainfuck patent, you need to write me a check.


I can verify: he mentioned it in the thread on the sigtbd parallel brainfuck CPU paper (and yes, that was real: you can look it up).


...Wait, wrong patent. Nevermind.

Still funny though.


You should've left off the correction. Now I can't supeona you for the trial in East Texas.


...Well than you'd sue me when I testified accurately on the stand, and that would hardely be ideal, now would it?


Ok but first we should rewrite the kernel in brainfuck. No, really.


All someone has to do is write a JS->brainfuck transpiler and we could have this.


I'd really like to see that. I'm eager to build a small program that takes style offenses like nested ternary operators and replaces them with a still functional brainfuck equivalent, to highlight how anoying that style of programming is to read.


Thats hilarious lol Or some of those rediculously dense ruby one liners could fit the bill too.


How about one where style pages via bf->js->sass->css


I mean yeah but this is javascript. Only 3 phases of transpilation is for noobs.

brainfuck->typescript->es6->via babel->es5->postCss plugins->sass->css->transpiled to react components->transpiled to an Angular 2 project->to webcomponents->transpiled to ArnoldC language->transpiled to a Turing complete Shopify liquid template-> commonjs and browserified->rails sprocket pipeline->then piped to /dev/null

It's not easy being a Javascript Ninja/Rockstar.


the pipe to /dev/null made it all worth it


/Slowclap :D


Waiting for serverless brainfuck


And maybe a brainfuck framework to develop cross-platform apps


I don't know whether to be impressed or scornful that it's interpreted rather than compiled.


I was surprised to learn that this has got to be one of the only languages which is easier to compile than interpret. When compiled the language reduces to basically a single-register assembly with a one-to-one character-to-line ratio. Bracket branching can be extremely easily implemented with jump labels and `test` + `jnz` statements without having to worry about things like parsing and jump table construction at all.


It's pretty freaking easy to interpret, as well... I implemented an interpreter in Go (which I had never used before) in an hour or so; most of the time spent was learning the two languages (Go and BF).

I should start asking interview candidates to write a BF interpreter...


So delighted to see this :D I once fail/won with a paper in whitespace. I love the non-traditional programming languages. They're fun, whimsical, and sometimes a nice break.

LOLCode is still my favorite though. I wrote a prime number generator in it for fun :)


I think the author is a masochist


The author wrote parts of sauerbraten, he is a cool guy and not afraid of anything.


Do you play? I spent ages on that game. Any word on why that would mean he isn't afraid of anything?


I played the banabread fork- and tried to mod the engine once to make Turmalin, a sort of team-deathmatch meets 3d-tetris game. https://springrts.com/phpbb/download/file.php?id=6378

The not being afraid of going unconventional ways refers to the levels of sauerbraten being stored in octrees. This is quite tough too edit if you are used to 3dsmax and blender. Actually that was too much effort- thus the project never came to be- but the way its stored and accessed, is blazingly fast and effective. One has to admire this skills.


> Any word on why that would mean he isn't afraid of anything?

http://knowyourmeme.com/memes/pretty-cool-guy


Why call it systemf? That name is already taken: https://en.wikipedia.org/wiki/System_F


Didn't you get the memo? We ran out of names about 10 years ago, so now everything is fair game



Would it be easier to write a HTTP server in C and compile to Brainfuck using ELVM (https://github.com/shinh/elvm)?


Much easier, the equivalent C would be in the area of 15-20 statements




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: