
Show HN: A partial HTTP server written in brainfuck extended with syscalls - ajyoon
https://github.com/ajyoon/systemf
======
ww520
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.

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

~~~
hood_syntax
I put in a vote for Malbolge

~~~
nfd
Ooh, or the highest-level language, Homespring.
[http://xeny.net/Homespring](http://xeny.net/Homespring)

~~~
hood_syntax
I kind of want to implement that now...

------
greglindahl
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!

~~~
umanwizard
You laugh, but Python works the same way.

~~~
deepanjanroy
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.

~~~
therein
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...](https://msdn.microsoft.com/en-
us/library/windows/desktop/ms679297\(v=vs.85\).aspx)

[1] [https://stackoverflow.com/questions/173618/is-there-a-
portab...](https://stackoverflow.com/questions/173618/is-there-a-portable-
equivalent-to-debugbreak-debugbreak)

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

~~~
ajyoon
listen...

------
tlrobinson
This is perhaps the most Hacker News headline ever.

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

~~~
Rhinobird
>the Brainfuck interpreter is written in assembly?!

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

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

~~~
ajyoon
There is a minified version here if you're into that kind of thing
[https://github.com/ajyoon/systemf/blob/master/examples/http/...](https://github.com/ajyoon/systemf/blob/master/examples/http/minified_server.bf)

------
jksmith
Is this idiomatic Brainfuck?

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

I didn't really expect that

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

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

------
partycoder
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.

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

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

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

~~~
hobofan
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.

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

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

~~~
ajyoon
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.

~~~
QuercusMax
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...

------
this-dang-guy
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 :)

------
raw23
I think the author is a masochist

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

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

~~~
Pica_soO
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](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.

------
bweitzman
Why call it systemf? That name is already taken:
[https://en.wikipedia.org/wiki/System_F](https://en.wikipedia.org/wiki/System_F)

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

~~~
macintux
[http://dilbert.com/strip/1993-06-23](http://dilbert.com/strip/1993-06-23)

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

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

