TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Brainfuck Optimization Strategies

103 点作者 nirvanis超过 10 年前

15 条评论

Gurkenmaster超过 10 年前
There&#x27;s of course also a optimized brainfuck compiler written in sed: <a href="https://github.com/stedolan/bf.sed" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;stedolan&#x2F;bf.sed</a>
评论 #8852237 未加载
评论 #8852919 未加载
评论 #8851283 未加载
bquinlan超过 10 年前
I while ago I wrote a simple Brainfuck interpreter, JIT and compiler (<a href="https://github.com/brianquinlan/brainfuck-jit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brianquinlan&#x2F;brainfuck-jit</a>).<p>The compiler implements the &quot;Operation offsets&quot; optimization as described in the article. It is actually pretty straightforward. This function converts a map of offset =&gt; delta to x86-64 instructions: <a href="https://github.com/brianquinlan/brainfuck-jit/blob/master/bf_compile_and_go.cpp#L175" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;brianquinlan&#x2F;brainfuck-jit&#x2F;blob&#x2F;master&#x2F;bf...</a><p>and the function following it generates that table.
评论 #8851679 未加载
lifthrasiir超过 10 年前
I have a (at the initial release, and possibly still) &quot;state-of-the-art&quot; Brainfuck compiler to C [1], which can compile a &quot;Hello, world&quot; program into a single `puts` call.<p>Some ProTip(tm): JITing Brainfuck doesn&#x27;t fare a lot; for example, resetting the cell is an O(n) operation in BF, so JIT alone doesn&#x27;t reduce this into O(1). Some kind of scalar evolution has to be implemented to reduce this O(n) factor. More sophiscated liveness and range analysis might be required to go further (esotope-bfc didn&#x27;t get there, anyway).<p>[1] <a href="https://bitbucket.org/lifthrasiir/esotope-bfc" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;lifthrasiir&#x2F;esotope-bfc</a>
JetSpiegel超过 10 年前
<a href="http://calmerthanyouare.org/2014/09/30/brainfuck-java.html" rel="nofollow">http:&#x2F;&#x2F;calmerthanyouare.org&#x2F;2014&#x2F;09&#x2F;30&#x2F;brainfuck-java.html</a> some of the issues encountered when writing a brainfuck-to-java compiler in brainfuck<p>Yo dawg, etc
评论 #8851535 未加载
sp332超过 10 年前
As a comparison, what does it look like if you enable GCC optimization?
评论 #8851383 未加载
debacle超过 10 年前
Brainfuck is a really beautiful language. It was the first language I wrote a parser for, and it&#x27;s incredibly beautiful in its simplicity.
评论 #8851651 未加载
评论 #8852557 未加载
评论 #8851700 未加载
primaryobjects超过 10 年前
Is there an implementation of this that converts any BF code into C&#x2F;C# code? Might make a handy web-based tool.<p>It would be interesting to apply this to AI generated programs (<a href="http://www.primaryobjects.com/CMS/Article163" rel="nofollow">http:&#x2F;&#x2F;www.primaryobjects.com&#x2F;CMS&#x2F;Article163</a>)
评论 #8851788 未加载
评论 #8854636 未加载
评论 #8855462 未加载
abandonliberty超过 10 年前
Though rather juvenile I appreciated this interpreter that maps instructions to offensive four letter words.<p>NSFW text. ff&#x2F;feckfeck&#x2F;f* ckf* ck.<p><a href="http://web.archive.org/web/20050318095341/http://www.chilliwilli.co.uk/ff/" rel="nofollow">http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20050318095341&#x2F;http:&#x2F;&#x2F;www.chilliw...</a><p><a href="http://web.archive.org/web/20050311055852/http://www.chilliwilli.co.uk/ff/hwcommented.ff" rel="nofollow">http:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20050311055852&#x2F;http:&#x2F;&#x2F;www.chilliw...</a>
ninjakeyboard超过 10 年前
I&#x27;m working on implementing the JVM in Brainfuck
huhtenberg超过 10 年前
Now peg it against <a href="http://mazonka.com/brainf/" rel="nofollow">http:&#x2F;&#x2F;mazonka.com&#x2F;brainf&#x2F;</a>, the bff4lnr version :)
评论 #8851703 未加载
Yadi超过 10 年前
This sounds cool, but I was not sure till halfway through the post if it&#x27;s like an Onion article or not.
Fede_V超过 10 年前
How long until someone makes a homoiconic version of brainfuck?
chucksmart超过 10 年前
Who is hiring brainfuck developers these days?
评论 #8855465 未加载
blt超过 10 年前
Beautiful insanity.
nemo超过 10 年前
Kudos, I guess...