

Brainfuck compiler in brainfuck - jacquesm
http://code.google.com/p/awib/

======
skip
Source code contains (slightly NSFW) ASCII art--that's awesome.

[http://code.google.com/p/awib/source/browse/builds/awib-1.0r...](http://code.google.com/p/awib/source/browse/builds/awib-1.0rc6-BETA.b)

~~~
jacquesm
Apologies to anybody that got fired over that.

Brainfuck tutorial:

<http://www.nieko.net/bf.php>

------
silentbicycle
For those of you who like this stuff, the "J Incunabulum" will probably be
really interesting. It's an early draft of a J interpreter, written in
J-styled C.

<http://www.jsoftware.com/jwiki/Essays/Incunabulum>

Also, unlike Brainfuck, unlambda, lolcode, malborge, etc., J and related
languages are used for real work. They're just really dense, like regular
expressions for vector/matrix math.

~~~
jcw
That's some interesting code, but would be more interesting if it worked.
Segfaulted.

K is also fun, but considerably less fun to toy around with now that GUI
functionality was taken out of the standard lib.

~~~
silentbicycle
It's very old, pre-K&R C. It segfaults for me, too, in ga.

It got me interested in the language, but rather than trying to rewrite it, I
decided to go through "J For C Programmers"
(<http://www.jsoftware.com/help/jforc/contents.htm>) on my lunch breaks. The
APL language family has several interesting ideas, the fanatically terse
syntax is just the first one everybody notices.

------
judofyr
Checkout my Brainfuck to Brainfuck compiler in Brainfuck!

    
    
      ,[.,]

------
UpFromTheGut
I wonder if putting brainfuck on my resume would get me in the door, or thrown
out the door.

------
michael_h
How much patience is necessary for something like this? If I could start a
slow clap, I would.

~~~
andyn
I think you could write some sort of simple language that would get expanded
into BF.

e.g.

    
    
      +6 -> ++++++

~~~
silentbicycle
You could _compile_ to brainfuck, treating it as a very simple virtual
machine. It's just simplified to the point of being incredibly inefficient,
like factoring Church-encoded numbers with Prolog's unification, rather than
using its built-in mathematical primitives.

(Whether the bf compiler was actually written or just generated by compiling
to bf is neither here nor there.)

~~~
tetha
in fact, there is work on a gcc-backend which outputs brainfuck (name's gcc-
bf)

------
10ren
It goes from awib v1.0-rc1, rc2, up to awib-1.0rc6-BETA.b... and then the
final release is awib-0.1 (not awib-1.0).

Am I missing something/is this part of the joke/is it just a typo? It's...
ah... messing with my mind a little.

~~~
req2
Well, with an increasing version system, you can never tell when you're
finished. Is version 3 FINAL the final version, or is some new maintainer
going to come make version 4 anyways? If you iterate toward 0, your final
product can be awib-0, and you'd be hard pressed to find a new version number
without further confusing the three people who got what you were going for.

(I'm guessing it's just a typo.)

------
michael_dorfman
Someone ought to port it to Ook!
(<http://www.dangermouse.net/esoteric/ook.html>)

 _That_ would be something to read.

~~~
jacquesm
that's just a search & replace, they're equivalent.

~~~
michael_dorfman
I didn't say it would be a difficult port....

It would sure look different, though.

------
nx
_Awib is an optimizing compiler:

o) Sequences of '-','<','>' and '+' are contracted into single instructions.
E.g. "----" is replaced with a single ADD(4)._

SUB(4)?

------
geeko
I don't want to sound offensive, but do wonder what is the purpose of this
exercise? Is there any problem this project is solving? Or is it 'just' for
educational purpose?

~~~
silentbicycle
Writing a brainfuck interpreter in a language is a good way to size it up.
Unlike "hello world", it actually gives you a meaningful impression of how
string handling, data structures, etc. work. It's not _hard_ , but it's just
enough to work up a sweat -- like a web-programmer writing a blogging engine
or a wiki to try out a web framework. (If it _is_ hard in the language, that
should also tell you something.)

See also:

* Project Euler (<http://projecteuler.net/>), for math problems

* Programming Praxis (<http://programmingpraxis.com/>)

~~~
arakyd
Yeah but that doesn't explain why one would write a brainfuck interpreter _in
brainfuck_.

Day 163: Project complete. Strength nearly gone. Must.. complete...
evaluation.... Data structures, godawful... string handling, non-existent...
writing a brainfuck interpreter, gigantic pain in the ass.... Conclusion: this
better get me laid. Oh sh.. _signal lost_

------
jcw
Someone should write a Forth in brainfuck.

~~~
jacquesm
is that a challenge ?

