编程与软件工程nicoleorchard.com
编译器入门
An Intro to Compilers
2017 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是一篇面向初学者的编译器入门文章,简明介绍编译器如何把源代码转换为可运行程序,以及词法分析、语法分析、中间表示、优化和代码生成等核心环节。它帮助读者建立对编译器整体流程的直观认识,而不必一开始就陷入大量解析理论。
为什么经久不衰:它用很短的篇幅把编译器全流程讲清楚,是理解程序语言与底层执行之间那层“黑盒”的经典起点,所以隔几年仍会被推荐。
HN 评论精选
批评编译器课程过度停留在解析阶段,赞赏本文直接触及优化和静态分析等核心内容。
我对编译器教育有一个长期不满(本文没有重蹈覆辙,赞!):学生得先啃好几个月的解析(parsing)这类烦人内容,才能接触到真正有趣的部分(优化和静态分析)。
pbiggar查看英文原文
Pet peeve about compiler education that is not repeated by this article (yay, well done!): the way you have to wade through months of parsing bullshit to get to the really interesting stuff (optimization and static analysis).
分享一个用 Haskell 实现、用于教学 LLVM 优化思想的迷你编译器项目。
我用 Haskell 写了一个 llvm-lite,用来展示 LLVM 的主要优化思想(链接:https://github.com/bollu/tiny-optimising-compiler),也许有人会感兴趣 :)
bollu查看英文原文
I've been writing an llvm-lite in haskell to show of the main optimisation ideas of LLVM [here](https://github.com/bollu/tiny-optimising-compiler). Thought someone maybe interested :)
编译器知识能提升编程能力,理解抽象层下方很重要。
我大学上过几门编译器课,总体让我成为更好的程序员,主要是它强迫我理解特定编程概念和结构通常如何实现,也让人更深入审视写高级语言时面对的那堆抽象。我一直主张,若想真正理解所用工具,至少要理解你工作所在的“表层抽象”下面一层,能下两三层更好。游戏开发者 Jonathan Blow 有个很好的演讲,讲我们因为不理解所构建的黑盒,知识如何“代际”丢失;我不完全同意,但很有意思。
perfect5th查看英文原文
I took a couple of compiler courses in university, and I think for the most part it made me a better programmer, mainly because it enforced understanding of how specific programming concepts and constructs are generally implemented. That, and a more intense look at the "heap of abstractions" you're generally working with when you write a higher-level language. I've always advocated that, if you want to really understand the tools you are using, you need to understand at least one level below the "surface abstraction" that you are working if. Even better if you can understand two or three levels down. There's a great talk from game developer Jonathan Blow [1] that describes how knowledge is lost "generationally" due to our lack of understanding of the black boxes we build things on top of. Not sure I 100% agree with his thoughts, but it's an interesting take. [1] https://www.youtube.com/watch?v=pW-SOdj4Kkk
自写小语言编译器能带来实际工程便利和灵活的后端切换能力。
我花几天为自定义 shader 语言写了个编译器。它是个极简 Lisp,但足够覆盖我图形用途。我把它编译成 GLSL 加 CPU 侧的结构体和函数。只改 shader 时原型迭代快很多,还能在 WebGL/OpenGL 后端间切换;需要时加 Vulkan/Metal/DX12 支持应该也快。要不是懂编译器,我根本不会想到这个方案。
peacefulhat查看英文原文
I spent a couple days writing a compiler for a custom shader language. It's a very simple lisp with minimal features, but enough to do everything I use in graphics. I compile this into glsl + a struct and functions for cpu side. A lot faster to prototype when I only have to modify my shader, and I can switch out the backend between webgl and opengl. Should be quick to add support for vulkan/metal/dx12 when I need that. I never would have thought to do this solution if I didn't already know how to write compilers. Somebody might say "oh, you could have used ____" - maybe, but it wasn't much effort and I can make it work in a convenient way for me. (in position f2) (in uv f2) (all sprite tex) (all color f4) (vert (position 0.0 1.0)) (frag (* (sprite uv) color))
历次讨论
同类还值得读
开源应用架构
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编辑精选