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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

30 years of Brainfuck

100 点作者 Decabytes超过 2 年前

10 条评论

pdpi超过 2 年前
Brainfuck is one of my favourite languages. Not that I _write_ any code in it, mind you, but there&#x27;s a bunch of code out there written for it (thank you, you crazy people), and it&#x27;s so tiny and so simple that you can write an interpreter for it in an hour or two.<p>Because the syntax is so minimal, there&#x27;s little point for a naive interpreter to include a parser and you can write it directly as a bytecode interpreter (and my experience has been that most beginners will do exactly that on their first attempt).<p>However, if you _do_ decide to write a (really basic) parser for it, you can easily end up with a tree walking interpreter instead, and, from there, it&#x27;s only a tiny jump to start manipulating the AST. E.g. the simplest change you can make is to do away with the separate Increment and Decrement instructions, and replace them with a generic Add instruction, so + and - get parsed as Add 1 and Add -1 respectively. Then you can replace runs of mixed - and + characters as one single Add instruction (--+-+++ becomes Add 1, for example). If you add a Set instruction, the [-] sequence can be translated to Set 0. Likewise, [.&gt;] can become printf(ptr) instead of a loop of putchar(*ptr).<p>Put all of this together, and it turns out that BF is perfect to introduce people to interpreters, and to demistify the whole &quot;writing a language&quot; thing.
评论 #34387070 未加载
评论 #34387105 未加载
评论 #34386065 未加载
iamevn超过 2 年前
You are Reading the Name of this Esolang[1] is my favorite of the Brainfuck derivative esolangs.<p>It consists of &quot;0&quot; and &quot;1&quot; characters which map to Brainfuck symbols via a Huffman encoding as well as brackets which wrap a subprogram which are reduced to &quot;1&quot; if the subprogram halts and &quot;0&quot; if the subprogram loops forever. This means that the problem of deciding whether a given string is a valid You are Reading the Name of this Esolang program is undecidable.<p>[1]: <a href="https:&#x2F;&#x2F;esolangs.org&#x2F;wiki&#x2F;You_are_Reading_the_Name_of_this_Esolang" rel="nofollow">https:&#x2F;&#x2F;esolangs.org&#x2F;wiki&#x2F;You_are_Reading_the_Name_of_this_E...</a>
评论 #34385873 未加载
anardil超过 2 年前
It&#x27;s an interesting&#x2F;challenging exercise to work through implementing some basic functions in BF, ie thinking only in loops.<p>I implemented an optimizing interpreter in Bash[1] on a plane ride, and it&#x27;s still one of my favorite pet projects.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;Gandalf-&#x2F;BrainBash">https:&#x2F;&#x2F;github.com&#x2F;Gandalf-&#x2F;BrainBash</a>
评论 #34386438 未加载
wheresmyshadow超过 2 年前
Ever since I learned about Brainfuck myself (which I obviously couldn&#x27;t believe at first that it&#x27;s an actual thing), I keep peeping at esolangs.org to find some bizarre creations of (often) very bored programmers.
yardie超过 2 年前
30 years?! Wow, the first time I ever heard of it was 15 years ago. And even then I thought it was some weird university group project that gained internet infamy.
评论 #34387560 未加载
siraben超过 2 年前
Brainfuck makes it very easy to benchmark various optimizations that you can do to its interpreter.[0] Rendering a Mandelbrot set goes from 28.57 to 6.49 seconds with basic preprocessing!<p><pre><code> $ nix run github:siraben&#x2F;bf </code></pre> [0] <a href="https:&#x2F;&#x2F;github.com&#x2F;siraben&#x2F;bf">https:&#x2F;&#x2F;github.com&#x2F;siraben&#x2F;bf</a>
metayrnc超过 2 年前
Today I learned that python was older than java. Nice surprise.
评论 #34387578 未加载
fouronnes3超过 2 年前
Quine relay [1] is to this day the most &quot;I will never understand this&quot; brainfuck project I have ever seen.<p>&gt; This is a Ruby program that generates Rust program that generates Scala program that generates ...(through 128 languages in total, including brainfuck!)... REXX program that generates the original Ruby code again.<p>It is so mysterious how it&#x27;s even possible, and hilariously the explanation of how it was made exists in Japanese only. I think at this point it would be easier to learn Japanese than to try to understand this project.<p>Other things like a brainfuck interpreter in brainfuck are impressive but don&#x27;t come nearly as close to black magic as quine-relay.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;mame&#x2F;quine-relay">https:&#x2F;&#x2F;github.com&#x2F;mame&#x2F;quine-relay</a>
kmstout超过 2 年前
The proceedings of SIGBOVIK 2022 has an article [0] detailing brainfuck++, which includes a number of helpful enhancements.<p>[0] <a href="http:&#x2F;&#x2F;sigbovik.org&#x2F;2022&#x2F;proceedings.pdf" rel="nofollow">http:&#x2F;&#x2F;sigbovik.org&#x2F;2022&#x2F;proceedings.pdf</a>, page 23.
评论 #34386030 未加载
Rant423超过 2 年前
I remember discovering Brainfuck... and then discovering Malbolge [0].<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Malbolge" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Malbolge</a>