News for hackers. Stuff that matters.
Re:Brainfuck compiler in brainfuck by skip on Friday July 10, 2009 @08:05AM (#697512)
Source code contains (slightly NSFW) ASCII art--that's awesome.

http://code.google.com/p/awib/source/browse/builds/awib-1.0r...

Re:Brainfuck compiler in brainfuck by jacquesm on Friday July 10, 2009 @10:43AM (#697715)
Apologies to anybody that got fired over that.

Brainfuck tutorial:

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

Re:Brainfuck compiler in brainfuck by stilist on Friday July 10, 2009 @11:17AM (#697750)
Ah, that illustration is a classic.
Re:Brainfuck compiler in brainfuck by silentbicycle on Friday July 10, 2009 @09:27AM (#697625)
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.

Re:Brainfuck compiler in brainfuck by coliveira on Friday July 10, 2009 @11:45AM (#697817)
This is a really interesting piece of code. The style of C programming looks unreadable for the uninitiated, but is in fact very close to what in do in mathematics. I will try to play with this style myself (not for working code, of course).
Re:Brainfuck compiler in brainfuck by jcw on Friday July 10, 2009 @11:58AM (#697836)
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.

Re:Brainfuck compiler in brainfuck by silentbicycle on Friday July 10, 2009 @12:31PM (#697924)
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.

Re:Brainfuck compiler in brainfuck by arakyd on Saturday July 11, 2009 @12:51AM (#698824)
Considerably less fun to toy around with now that the only way to get a non completely crippled version is to pay megabucks (or work at a company that develops in it). If I'm wrong, please please clue me in...
Re:Brainfuck compiler in brainfuck by DannoHung on Friday July 10, 2009 @11:32AM (#697787)
What you really have to love is the complete lack of comments.
Re:Brainfuck compiler in brainfuck by silentbicycle on Friday July 10, 2009 @12:35PM (#697935)
It's a one-page draft of an interpreter for a subset of a language, by one of the main designers involved with it, written to the initial designer. It's written in C, but idiomatically written as closely to the language as possible. Having comments would be pretty strange, honestly.

There's an unpacked and commented version of it here, FWIW: http://www.kuro5hin.org/comments/2002/8/30/175531/763/1#1

Re:Brainfuck compiler in brainfuck by DannoHung on Friday July 10, 2009 @04:31PM (#698314)
Yeah, except he does the same thing in every language, even in written english.

I'm not criticizing it anyway. His K is very clean... usually.

edit: I do wish he'd be a little less terse in the code for interfacing with other C code. Just as a favor to us normal humans.

Re:Brainfuck compiler in brainfuck by silentbicycle on Friday July 10, 2009 @04:47PM (#698346)
Agreed. I think it's atrocious C style, it just makes sense for people who write J natively to style the C that way in a context where it will be understood.
Re:Brainfuck compiler in brainfuck by blasdel on Friday July 10, 2009 @04:42PM (#698337)
The 'J-styled C' reminds me of how the original Bourne shell was written with ALGOL syntax in C using cpp macros, and implements a language with ALGOL-flavored syntax.
Re:Brainfuck compiler in brainfuck by judofyr on Friday July 10, 2009 @08:35AM (#697558)
Checkout my Brainfuck to Brainfuck compiler in Brainfuck!

  ,[.,]
Re:Brainfuck compiler in brainfuck by UpFromTheGut on Friday July 10, 2009 @02:53PM (#698165)
I wonder if putting brainfuck on my resume would get me in the door, or thrown out the door.
Re:Brainfuck compiler in brainfuck by michael_h on Friday July 10, 2009 @10:30AM (#697702)
How much patience is necessary for something like this? If I could start a slow clap, I would.
Re:Brainfuck compiler in brainfuck by andyn on Friday July 10, 2009 @12:45PM (#697954)
I think you could write some sort of simple language that would get expanded into BF.

e.g.

  +6 -> ++++++
Re:Brainfuck compiler in brainfuck by silentbicycle on Friday July 10, 2009 @01:08PM (#698001)
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.)

Re:Brainfuck compiler in brainfuck by tetha on Friday July 10, 2009 @06:56PM (#698558)
in fact, there is work on a gcc-backend which outputs brainfuck (name's gcc-bf)
Re:Brainfuck compiler in brainfuck by 10ren on Friday July 10, 2009 @10:28AM (#697698)
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.

Re:Brainfuck compiler in brainfuck by req2 on Friday July 10, 2009 @12:11PM (#697862)
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.)

Re:Brainfuck compiler in brainfuck by michael_dorfman on Friday July 10, 2009 @09:52AM (#697659)
Someone ought to port it to Ook! (http://www.dangermouse.net/esoteric/ook.html)

That would be something to read.

Re:Brainfuck compiler in brainfuck by jacquesm on Friday July 10, 2009 @09:58AM (#697663)
that's just a search & replace, they're equivalent.
Re:Brainfuck compiler in brainfuck by michael_dorfman on Friday July 10, 2009 @11:42AM (#697809)
I didn't say it would be a difficult port....

It would sure look different, though.

Re:Brainfuck compiler in brainfuck by geeko on Friday July 10, 2009 @09:03AM (#697594)
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?
Re:Brainfuck compiler in brainfuck by silentbicycle on Friday July 10, 2009 @09:50AM (#697656)
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/)

Re:Brainfuck compiler in brainfuck by arakyd on Saturday July 11, 2009 @01:01AM (#698831)
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

Re:Brainfuck compiler in brainfuck by jacquesm on Friday July 10, 2009 @09:15AM (#697605)
I think it is quite an amazing feat to write in brainfuck at all (to me it means you have both too much time on your hands and that you grok turing machines), to write a self-hosted compiler (ok, a brainfuck to C translator) is a very neat hack.

If that doesn't work for you think of it as art. Not everything has to have a direct purpose.

Re:Brainfuck compiler in brainfuck by dan00 on Friday July 10, 2009 @09:24AM (#697620)
I just love these kind of things.

If it was fun developing or fun doeing something so strange, than this was the purpose.

I really don't like it if purpose is reduced to getting richer, making career or impressing other people.

If people think that's the purpose, than they might loose the purpose of life.

Re:Brainfuck compiler in brainfuck by ajuc on Friday July 10, 2009 @09:36AM (#697640)
Impressing people might have something to this :)

At least I'm impressed.

Re:Brainfuck compiler in brainfuck by Devilboy on Friday July 10, 2009 @09:20AM (#697613)
It's kinda like mountain climbing for hackers I think.
Re:Brainfuck compiler in brainfuck by icey on Friday July 10, 2009 @03:50PM (#698250)
I'd liken it more to a hot dog eating competition for hackers.
Re:Brainfuck compiler in brainfuck by arakyd on Saturday July 11, 2009 @12:48AM (#698821)
Or like extruding peacock feathers for any animal that doesn't have peacock feathers.
Re:Brainfuck compiler in brainfuck by GrandMasterBirt on Friday July 10, 2009 @09:51AM (#697658)
Because they can, you can't, and you will never understand it even given all the source code.

Also nice ascii art.

Its not educational, its b0w b3f0r3 m4h sk1llz!

I must also agree with one of the posts here... It is art. Its geek art but it really is art. Judges who say source code is not art should also admit michalengelo was just some asshole who put grafitti on some holy buildings.

Re:Brainfuck compiler in brainfuck by abefortas on Friday July 10, 2009 @10:16AM (#697679)
I'm sorry, what?

Michelangelo's frescoes were commissioned. I utterly fail to see why anyone should admit they were graffiti.

Re:Brainfuck compiler in brainfuck by Batsu on Friday July 10, 2009 @12:55PM (#697976)
>> Judges who say source code is not art should also admit michalengelo was just some asshole who put grafitti on some holy buildings.

> Michelangelo's frescoes were commissioned. I utterly fail to see why anyone should admit they were graffiti.

The negatives confuse the sentence, but that was his point. Michelangelo's works were not graffiti, and similarly source code should be considered art, even if it is geek art.

Re:Brainfuck compiler in brainfuck by abefortas on Friday July 10, 2009 @01:14PM (#698013)
I don't see the connection. One could maintain that source code is not art and that Michelangelo's works were not graffiti.
Re:Brainfuck compiler in brainfuck by nx on Friday July 10, 2009 @06:45PM (#698550)
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)?

Re:Brainfuck compiler in brainfuck by jcw on Friday July 10, 2009 @12:00PM (#697842)
Someone should write a Forth in brainfuck.
Re:Brainfuck compiler in brainfuck by jacquesm on Friday July 10, 2009 @03:32PM (#698216)
is that a challenge ?