Live data from Hacker News

I wrote an LLVM-powered trace-based JIT for Brainfuck

github.com

31–40 of 56 posts

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#31
post #2

I don't know... "neat hack", but it seems there is so much out there that could actually have some kind of practical application that it's a bit of a waste to work on "silly" projects. I love to hack on things that don't have any immediately evident business model or real world application, but I think purposefully working on something that never will is perhaps a bit unfortunate. Yeah, he learned something for sure,…

I can't disagree more. This is a great project for learning how to use LLVM because there is nothing to add complexity. There is no need for a runtime library. There is no need for a complicated parser. With those parts gone, all that matters is building the compiler, JIT core, tracing algorithm, and so on. Now that the author knows how to do all that, he's mentally prepared to be productive when taking on a more com…

> This is a great project for learning how to use LLVM because there is nothing to add complexity.

Speaking as someone who's written a very simple Brainfuck interpreter, this is absolutely spot-on. As someone who'd never written an interpreter before, I didn't want to have to think about the language itself, just focus on getting the absolute fundamentals down.

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#32
Nice work!

Let me make a tiny plug for a short Sunday project as well... Brainf*ck in Prolog:

http://github.com/danieldk/brainfuck-pl/

One nice thing is that unit testing is really simple:

http://github.com/danieldk/brainfuck-pl/blob/master/unittest...

And for some very trivial outputs, it can generate the program to create that output.

  ?- brainfuck:interpret([A,B],[],[0],[0],[1,0]).
  A = 
Ps. Yes, it's easy to improve generation...

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#33
post #8

Earlier quoted context omitted.

I'm assuming you've been downvoted because slightly more than 50% of HNers think of this project as an artistic/fun project. But the fact is, even a purely artistic/fun project will have some creativity or originality in it. I would consider a toy language or Brainf__k written for the first time as artistic. But this project is just a JIT for Brainf__k, there's no creativity in it, and all it did was give the author…

Does HN censor the "fuck" in "Brainfuck", or was it just you? EDIT: Ah, it doesn't.

Generally, as long as it's part of something constructive and adds rather than detracts from the message, the community won't downvote profanity. http://news.ycombinator.com/item?id=1636262

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#34
post #7
post #6

Earlier quoted context omitted.

That's not the point. These are the kind of projects programmers do for fun. Your comments is like saying "if this guy didn't go the zoo, but rather spent his day at work, he at least might have been productive". Now, I can imagine you wouldn't enjoy watching somebody else's pictures of zoo animals, unless you were very interested in zoo animals, like, say, some people are interested in compiler technology and/or eso…

I did a small language for fun: http://www.hecl.org And it has actually turned out to be useful, besides being a lot of fun to work on. I am not saying fun projects need to be useful (I'd be the last one to say that), I'm saying "why ensure they'll never be useful?". Here's another language that is a 'fun project' that, who knows, might be quite useful some day: http://wiki.reia-lang.org/wiki/Reia_Programming_Languag…

I see your point (and kind of agree)... but isn't the fact that it's Brainf*ck part of the fun?

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#35
post #16
post #15

Earlier quoted context omitted.

> I am not saying fun projects need to be useful (I'd be the last one to say that), I'm saying "why ensure they'll never be useful?". Because some things are done for learning exercises and nothing more. Just because that code isn't going to do anything useful when executed, it does not mean that there is no value in the exercise of producing or sharing the code. Not that it needs that much justification, fun is a go…

Ok, you people are seriously failing to comprehend that which I am attempting to communicate to you. * I have no problems with 'fun projects'. I do them myself. * I have no problem with 'useless code'. Many fun projects are never useful. I have done these myself. * I have no problem with learning for learning's sake. I have engaged in lots of that. What I don't agree with is artificially limiting your project's poten…

Writing fast Brainfuck interpreter is one of the best optimization exercises I've ever encountered. Trivial to start, easy to improve and then it gets progressively harder with every iteration.

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#37
post #28

Earlier quoted context omitted.

You're assuming that every thing that people work on actually needs the potential to become "big". What about the people that study klingon? Or Esperanto? Or Elvish? You assume that a person cannot gain something by simply learning something that has no practical purpose. This isn't the case. By working on BF, someone might make some neuron connections that help them with logical thought with other projects, by break…

> You assume that a person cannot gain something by simply learning something that has no practical purpose Actually, what I wrote , if you'd bother to read it, is: "Yeah, he learned something for sure, but that's pretty much all it can be." so don't put words into my mouth. The point boils down to this: * It'll probably never become big. * That doesn't really matter, it's mostly for learning and for fun. * But even…

The effort you've expended to debate this will soon meet & then exceed the effort that went into the tracing JIT in question. When you reach that point, you'll have some soul searching to do.

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#38
post #2

I don't know... "neat hack", but it seems there is so much out there that could actually have some kind of practical application that it's a bit of a waste to work on "silly" projects. I love to hack on things that don't have any immediately evident business model or real world application, but I think purposefully working on something that never will is perhaps a bit unfortunate. Yeah, he learned something for sure,…

Hey, I'm the actual author of this.

I actually work on LLVM-proper during my day job. This was just a fun exercise to demonstrate that it was possible. I also have plans to write a tutorial based on it.

Re: I wrote an LLVM-powered trace-based JIT for Brainfuck

#40

Hey folks, I'm the actual author of this. I actually work on LLVM-proper during my day job. This was just a fun exercise to demonstrate that it was possible. I also have plans to write a tutorial based on it.

Also an example of how to implement a direct-threaded interpreter.

Some performance data from a Brainfuck mandelbrot benchmark.

Interpreter: 37.787s

Tracing JIT: 11.716s

Static Compiler: 2.402s

The tracing JIT loses out to the static compiler largely because there's no dynamic dispatch in Brainfuck for the tracer to optimize out. There's probably some performance to be recovered by tuning the tracer thresholds and minor optimizations, but I would be shocked if it ever beat the static compiler at least for Brainfuck.

Post reply on HN