Hacker News

有趣的郎格斯的胆量

了解为什么探索小型编程语言的内部结构可以让您成为更好的构建者。了解玩具语言和 DSL 如何揭示优雅的计算机科学思想。

4 最小阅读量

Mewayz Team

Editorial Team

Hacker News

为什么深入了解小型编程语言可以让你成为更好的构建者

您使用的每一个软件——从跟踪销售线索的 CRM 到在午夜发送发票的自动化引擎——都是用编程语言构建的。但您有没有想过是什么让编程语言发挥作用?不是像 Python 或 JavaScript 这样的大型生态系统,而是开发人员在周末为了解决单个问题或只是为了学习而构建的小型、斗志旺盛、令人愉快的怪异生态系统。这些“lil' fun langs”——玩具语言、特定领域语言(DSL)和教育解释器——是计算机科学中一些最优雅的想法的所在地。了解他们的内心不仅能让你成为更好的程序员,还能让你成为更好的程序员。它从根本上改变了您对构建工具、自动化工作流程和设计真正为人们服务的系统的看法。

“Lil' Fun Langs”到底是什么?

编程世界充满了从未用于为生产服务器提供动力或处理数百万个事务的语言。像 Lox(来自 Robert Nystrom 的 Crafting Interpreters)、Monkey(来自 Thorsten Ball 的《Writing an Interpreter in Go》)这样的语言,甚至像 Brainfuck 和 Chef 这样的笑话语言的存在都是为了教学、娱乐,甚至是为了突破“语言”含义的界限。这些小型语言消除了现实世界工具链的复杂性,并揭示了代码如何变成行动的原始机制。

但“小有趣的语言”并不仅限于教育练习。特定领域的语言为市场上一些最有效的业务工具提供支持。每次您在电子表格中编写公式、在电子邮件客户端中定义过滤规则或在 Mewayz 等平台中配置自动化工作流程时,您都在与一种小型的专用语言进行交互。 Mewayz 内部的 207 个模块(涵盖 CRM、发票、人力资源、车队管理等)依赖于内部规则引擎和表达式解析器,这些引擎和表达式解析器的核心是微型语言,旨在为用户提供强大的功能,而无需计算机科学学位。

了解这些语言的解剖结构揭示了为什么有些工具感觉直观,而另一些工具则感觉像是在与另一个维度编写的手册搏斗。

词法分析器:将单词分解为原子

每种语言,无论多小,都从相同的基本步骤开始:词法分析或“词法分析”。词法分析器采用原始字符串(例如总计 = 价格 * 数量 + 税)并将其分解为称为标记的有意义的块。词法分析器还不关心含义。它只是标识total是一个标识符,=是一个赋值运算符,price是另一个标识符,*是乘法,等等。

💡 您知道吗?

Mewayz在一个平台内替代8+种商业工具

CRM·发票·人力资源·项目·预订·电子商务·销售点·分析。永久免费套餐可用。

免费开始 →

为一种小型语言构建一个词法分析器是令人惊讶的令人满意。只需不到 100 行代码,您就可以教程序识别数字、字符串、关键字和运算符。简单性就是重点——它迫使你思考你的语言需要的绝对最小的“单词”集是什么。同样的想法也适用于设计面向用户的工具。当 Mewayz 的自动化引擎让小企业主设置“当发票逾期 7 天时,发送提醒电子邮件”之类的规则时,系统会悄悄将该规则转化为可以执行的结构化令牌。最好的界面让人感觉毫不费力,正是因为有人深入思考了用户意图的最小有意义的单位是什么样的。

解析:将扁平令牌变成活树

一旦你有了代币,你就需要结构。解析将平坦的标记序列转换为抽象语法树(AST)——一种捕获表达式不同部分之间关系的分层表示形式。表达式 3 + 4 * 5 不仅仅是五个标记的序列;它也是一个序列。在这棵树中,乘法的结合比加法的结合更紧密,产生的是 23 而不是 35。

这就是事情变得真正有趣的地方。像递归下降或 Pratt 解析这样的解析算法是优雅的工程作品,适合单个文件

Frequently Asked Questions

What are "lil' fun langs" and why should I care?

Lil' fun langs are small, experimental programming languages built to explore specific ideas or teach core concepts. They range from toy interpreters written in a weekend to domain-specific languages (DSLs) designed for narrow tasks. Understanding how they work gives you deeper insight into how all software operates — including the business tools you rely on daily. That knowledge makes you a sharper developer and a more informed decision-maker when choosing or building automation systems.

How does learning about language internals help with business automation?

When you understand concepts like parsing, evaluation, and interpreters, you start seeing automation differently. You recognize patterns in workflow builders, template engines, and rule systems. Platforms like Mewayz use these same principles across their 207 modules to let you automate invoicing, CRM workflows, and more — all without writing code. Knowing the fundamentals helps you push these tools further and troubleshoot issues faster.

Do I need a computer science degree to build a tiny language?

Not at all. Many developers build their first interpreter in a single weekend using tutorials and open-source guides. Languages like Python and JavaScript make it straightforward to write a basic lexer, parser, and evaluator. The goal isn't to create the next production language — it's to learn by doing. Even a simple calculator language teaches you how expressions are parsed and executed, skills that transfer directly to real-world development.

Can understanding DSLs help me pick better business tools?

Absolutely. Many business platforms embed domain-specific languages for formulas, filters, and workflow rules. When you understand how DSLs work under the hood, you can evaluate tools more critically. For example, Mewayz offers a comprehensive business OS starting at $19/mo with built-in automation logic across its modules. Knowing DSL concepts helps you leverage those features fully rather than scratching the surface.

Build Your Business OS Today

From freelancers to agencies, Mewayz powers 138,000+ businesses with 207 integrated modules. Start free, upgrade when you grow.

Create Free Account →

免费试用 Mewayz

集 CRM、发票、项目、人力资源等功能于一体的平台。无需信用卡。

立即开始更智能地管理您的业务

加入 30,000+ 家企业使用 Mewayz 专业开具发票、更快收款并减少追款时间。无需信用卡。

觉得这有用吗?分享一下。

准备好付诸实践了吗?

加入30,000+家使用Mewayz的企业。永久免费计划——无需信用卡。

开始免费试用 →

准备好采取行动了吗?

立即开始您的免费Mewayz试用

一体化商业平台。无需信用卡。

免费开始 →

14 天免费试用 · 无需信用卡 · 随时取消