编程语言与软件工程2020arxiv.org
面向法国税法的现代编译器
A Modern Compiler for the French Tax Code
进阶 · 约 60 分钟读完前置知识:编译原理基础、语法分析与类型检查、OCaml/函数式编程基础
导读
论文介绍为法国公共财政总局(DGFiP)使用的所得税计算专用语言开发的新一代编译器。该语言及其自制编译器最初设计于 1990 年,论文讨论如何用现代编译技术重写它(涉及解析、类型检查与工程迁移),以替代日渐难以维护的遗留实现。
HN 关注点:HN 读者对“政府遗留代码/自造语言”这类冷门但关键的软件基础设施很感兴趣,讨论延伸到 DSL 的实用价值、法律文本解析的难度以及开源替代实现。
HN 评论精选
这几条评论里:质疑 1 补充 2 亲历 1
补充提醒人们遗留系统远不止 COBOL/FORTRAN,还有大量鲜为人知的自制语言。
这段引言很有意思。提到遗留代码我们通常想到 COBOL 和 FORTRAN,但世上大概还有大量更冷门的代码在日复一日地默默干活。
weinzierl查看英文原文
> In France, income tax is computed from taxpayers' individual returns, using an algorithm that is authored, designed and maintained by the French Public Finances Directorate (DGFiP). This algorithm relies on a legacy custom language and compiler originally designed in 1990, which unlike French wine, did not age well with time. This interesting. When it comes to legacy code we think of COBOL and FORTRAN most of the time, but probably there is a huge amount of even more exotic code out there that does its duty day in day out.
亲历亲历:法律文本解析与版本 diff 极其易错难调,抽象设计是关键,项目因时间压力失败。
我曾被要求写一个解析我国法律文本的工具,还要能对文档做 diff 并合并(diff + 原文 => 最新版本),而我完全不懂那个领域。看完样本文件我估计一周能搞定(笑)。一个月后我还在痛苦挣扎,大概只完成了 20-30%。这东西极其敏感、极易出错,调试成本极高。我想是我在架构上思考得不够,另一方面我在这类工作上经验也确实很少。教训是:要易于快速、可靠地测试;要对原始文档有扎实的抽象;要对操作(比如“第 5 条的含义被修改了”)有扎实的抽象。项目最终死掉了,因为当时要求“快”(那段时间恰好是法律变动的特定时期),而我们没能足够快地做出可用版本。
tester34查看英文原文
I've been asked to write parser of _my_country_law_ and something that's capable of doing diffs and putting it together (diff+original=>newest version) docs without knowledge in that domain after seeing sample doc I've estimated it on something like 1 week of work (XD) month later I've been crying and having like 20-30% done this shit has been so sensitive (insanely error prone) and debugging was time costly. I think I didn't spent enough time on thinking about its architecture, but on the other hand my experience was pretty small with this stuff easy & fast to test and reliably have solid abstraction over original documents have solid abstraction over operation (e.g Article 5's meaning is changed) _____________ project died because it was needed "fast" (in that time there was very specific peroid of changes in law) and we weren't getting to the viable version fast enough
质疑质疑 DSL 的实际价值,并提到荷兰税务局用 JetBrains MPS 构建 DSL。
在某次顺着链接一路探索时,我发现荷兰税务部门使用 JetBrains 的 MPS 这种 DSL 构建工具。这让我好奇:为什么 DSL 没有流行起来?它宣称能让开发者把更多时间花在实现业务逻辑上,听起来合理,但这个承诺似乎并未兑现。很想听听尝试过 DSL 的人的看法。
vishnugupta查看英文原文
During one of those rabbit hole journeys I discovered that Dutch Tax authorities use MPS, a DSL creation language/tool by JetBrains [1] It makes me wonder, why haven't DSLs caught up? Their claim that it allows developers spend more time implementing the business logic makes sense. But somehow that promise hasn't been realised. I'm curious to know from those who tried DSLs. [1] https://www.jetbrains.com/mps/documentation/
补充补充资料:开源项目 OpenFisca 用代码实现税法,已被多国采用。
法国政府和议会也在使用这个法律(税收、福利等)的实现:https://github.com/openfisca/openfisca-france ,它是开源且可贡献的,因此多个国家共用同一套结构,列表见 https://openfisca.org/en/countries/ 。
sandcha查看英文原文
The French government and parliament also use this implementation of the law (taxes, benefits, ...) : https://github.com/openfisca/openfisca-france It's open source and contributive so, a common structure is used by multiple countries. They are listed here : https://openfisca.org/en/countries/
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2020Hacker News 讨论帖188 分 · 130 评
同领域还值得读
Google 的软件工程(2017)
Software Engineering at Google (2017)
介绍了 Google 的软件工程实践,包括其单一代码库(monorepo)、几乎全部开发在主干进行而非分支、代码审查、构建系统 Blaze、协议缓冲区等工具与流程,并讨论了频繁重…
编程语言与软件工程2017 · 1,127 分 · 465 评 · 引用 15入门 · 约 45 分钟编辑精选Peter Naur:编程作为理论构建 (1985)
Peter Naur – Programming as Theory Building (1985)
Peter Naur 1985 年的经典论文《Programming as Theory Building》提出:编程的本质不是写代码或文档,而是在程序员头脑中构建对程序及其运行…
编程语言与软件工程2016 · 629 分 · 74 评入门 · 约 45 分钟编辑精选SciPy 1.0:Python 科学计算的基础算法
SciPy 1.0: fundamental algorithms for scientific computing in Python
这篇发表于 Nature Methods 的论文介绍了 SciPy 1.0——Python 科学计算生态的基石库,涵盖其核心算法模块(优化、积分、插值、线性代数等)、软件架构与社…
编程语言与软件工程2020 · 387 分 · 98 评入门 · 约 45 分钟编辑精选Lisp 的历史(1979)
History of Lisp (1979)
这是 Lisp 发明者 John McCarthy 于 1979 年为 HOPL(编程语言史)会议撰写的回顾文章,讲述 Lisp 的起源、设计动机与早期演进,文中也涉及 if 表…
编程语言与软件工程2018 · 352 分 · 44 评入门 · 约 45 分钟编辑精选使用 NumPy 进行数组编程
Array Programming with NumPy
这篇 Nature 文章介绍 NumPy 的数组编程模型及其在科学计算中的核心作用:以 ndarray 为中心,通过向量化操作让 Python 高效处理多维数组。
编程语言与软件工程2020 · 318 分 · 134 评入门 · 约 40 分钟编辑精选