编程与软件工程bellard.org
混淆的微型 C 编译器
Obfuscated Tiny C Compiler
2018 — 2021,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是 Fabrice Bellard 的 OTCC(Obfuscated Tiny C Compiler)页面,展示了一个被刻意混淆、体积极小的 C 编译器,源码可读性极低。它后来衍生出更实用的 Tiny C Compiler(TCC)。
为什么经久不衰:它把编译器的体积极限和代码混淆推到近乎行为艺术的程度,同时又是 TCC 的起点,至今仍让人惊叹于 Bellard 的工程能力。
HN 评论精选
混淆后的字符串/例程难以理解,引发技术好奇。
我本来以为至少能看懂一些未混淆的 C 代码,然后看到这个怪物:t = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b"; 有人能解释一下这个例程在干什么吗?
vermilingua查看英文原文
I thought I could follow at least some of the unobsfucated C, and then this monstrosity: t = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!=\'g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b"; Could someone please explain what is going on in that routine?
用二维码容量反衬编译器体积极小。
如果我没记错,最大的二维码最多能容纳 2953 字节二进制数据。这个 C 编译器可以放进一个二维码里。
newswasboring查看英文原文
If I recall correctly the maximum binary data you can fit in the largest QR code is 2,953 bytes. This C compiler can fit on a qr code.
TCC 源自 OTCC 且质量高,适合嵌入作为脚本引擎。
我太喜欢 TCC 了。它是这个项目衍生出的基础项目。像 Bellard 的所有作品一样,这个项目货真价实且质量极高。我曾一度(在无聊之前)基本做出了一个把 C 源码当脚本输入的游戏引擎。完全愚蠢,但多亏它运行得很好。
sillysaurusx查看英文原文
I absolutely adore TCC, fwiw. It’s the base project that this one is derived from. Like all of bellard’s work, this is legit and also extraordinarily high quality. At one point before I got bored I basically had a game engine that took C source code as scripting inputs. Totally stupid, and worked great thanks to this.
TCC 由 OTCC 发展而来,小巧带来解释执行和内存生成等特性。
也看看 Tiny C Compiler,它诞生于这个项目,如今本身已是一个功能相当完整的 C 编译器。由于体积小,它有几个有趣特性,比如能“解释”C 代码,也能在内存中生成可执行文件,从而无需太多工作即可跨平台。
saagarjha查看英文原文
Also see the Tiny C Compiler, which was born out of this project and now is a pretty-full featured C compiler in its own right: https://bellard.org/tcc/. It has a couple pretty interesting features by virtue of its small size, such as being able to "interpret" C code as well as generating executables in-memory so they're portable across platforms without a lot of work.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选