编程与软件工程fgiesen.wordpress.com
给疯子的元编程
Metaprogramming for madmen
2014 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Fabian Giesen 介绍 Farbrausch 做 96KB 3D 射击游戏 .kkrieger 时用的一套“疯狂”做法:不手写汇编,而是照常写 C++,再用自制的工具链对编译出的目标代码做后处理,砍掉对输出没有影响的代码、合并重复的机器码,把编译器变成元编程工具来榨干每一字节。文中详细讲了这套工具的设计思路和取舍。
为什么经久不衰:它展示了一种把“数据即代码”推到极致的工程思维,是理解 demo scene 极限压缩、程序化生成和代码瘦身技术的经典入门读物。
HN 评论精选
赞赏文章揭示了 demo 的写法,认为这是“数据与代码绑定”思想的极端形态,甚至可启发自适应 JIT。
这是了解 demo 是如何写出来的绝佳视角。Farbrausch 的作品一直给我灵感。有趣的是,这是“数据模型和代码天生绑定”这一想法的极端版本:函数式编程圈里常说先针对任务设计好数据模型,剩下的代码基本就是围绕它做模式匹配;而这里把两者的耦合推得更紧,服务于更高的目的。我甚至觉得,给足时间它可以变成一个 JIT——一个随着运行自适应地剥离代码、自我精简的可执行文件。另外可以看看 .kkrieger(仅 Windows 的 96KB 3D FPS)和作者的前一篇文章。
makmanalp查看英文原文
This is an amazing insight into how demos are written. Farbrausch stuff has always been inspirational to me. It's very interesting is the sort of extreme version of the idea that data model and code are inherently tied: Especially in functional programming circles it's a maxim that you design your data models first, specifically for your task, and then the rest of the code is pretty much pattern-matching around that. This takes that coupling and makes it even tighter, to serve a higher purpose. I almost feel like given enough time, this could be a JIT: an executable that adaptively strips code and self-minifies over time as you run it. :) Also check out: - kkrieger (windows only 96kb 3D FPS, video here: https://www.youtube.com/watch?v=2NBG-sKFaB0) - the previous post (http://fgiesen.wordpress.com/2012/02/13/debris-opening-the-box/)
引发对 4k intro 极限压缩岁月的怀旧,强调数据复用能力。
这让我怀念起当年拼命把 4k 压进 4096 字节的日子。你会变得非常擅长复用数据。
camperman查看英文原文
This brings back fond memories of trying to get a 4k under the magic 4096 bytes. You get really good at reusing data.
指出 Go 覆盖率工具采用了类似的“改写源代码”思路。
Go 的测试覆盖率工具也是这么工作的,只是 Go 里做起来容易,因为标准库自带读写 Go 源码的库。
enneff查看英文原文
This is how Go's test coverage tool works, except in the Go case it was easy to do because there are libraries for reading and writing Go source code in the standard library. Details: http://blog.golang.org/cover
从信息论角度把这种技术理解为压缩:纹理压成算法,再剪掉算法中不影响输出的部分。
.kkrieger!当年看到就很震撼,那是程序化生成的胜利——把一款 FPS 塞进 96KB。从信息论角度看,这很有意思:它本质上是一种压缩,先把纹理“压缩”成生成它的算法,再把算法里对输出没有影响的部分全部砍掉。
pjc50查看英文原文
Kkreiger! I remember being amazed by that at the time, it's a triumph of procedural generation, fitting a FPS into 96kb. It's interesting to think of this from an information theoretic perspective as a form of compression. Firstly "compressing" textures into the algorithm that generates them, then cutting away all the parts of the algorithm that don't make any difference to the output.
历次讨论
同类还值得读
开源应用架构
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编辑精选