编程语言与软件工程2024onlinelibrary.wiley.com
按需 JSON:一种更好的文档解析方式?
On-demand JSON: A better way to parse documents?
进阶 · 约 45 分钟读完前置知识:JSON 解析器原理、SAX 与 DOM 解析模型、SIMD 优化基础
导读
这篇论文探讨按需解析(on-demand parsing)是否是解析 JSON 文档的更好方式:在 SAX 风格解析器之上构建类 DOM 的惰性按需访问接口,只在真正访问字段时才解析对应部分,从而获得比传统全量解析更快的速度。该实现已作为 SIMDJson 库的一部分发布。
HN 关注点:JSON 解析性能这一经典话题,讨论焦点是按需解析的实用性——尤其是惰性解析与数据校验之间的矛盾,以及它与 SIMDJSON 已有能力相比的新意。
HN 评论精选
这几条评论里:质疑 2 补充 1 亲历 1
质疑质疑按需解析的实用性:生产环境必须校验 JSON,惰性解析因此失去意义
抱歉,我绝不会用这个。无论从什么来源、出于什么目的消费 JSON,我都会先做校验。如果需要校验,惰性加载就毫无意义了。提示:你需要校验。
fanseepawnts查看英文原文
Sorry, I would never use this. Before I consume any json from any source or for any purpose I validate it. Lazy loading serves no purpose if you need validation. Hint: you need validation.
补充专业解读:核心是在 SAX 解析器上加类 DOM 前端,并好奇这一思路的历史先例
他们是在 SAX 风格解析器之上构建了一个类 DOM 的 API,从而获得更快的速度(FPGA 和 GPU 方向的研究除外)。已作为 SIMDJson 的一部分发布。我想知道在 SAX 解析器流行的年代有没有人做过这种前端封装?论文写得非常好。
kristianp查看英文原文
So they're creating a DOM-like api in front of a sax style parser and getting faster results (barring FPGA and GPU research). It's released as part of SIMDJson. I wonder if that kind of front end was done in the age of SAX parsers? Such a well-written paper.
亲历亲历者补充:性能极佳但与已有 SIMDJSON 能力区别不明,且不支持流式/内存映射
我不太明白相比 SIMDJSON 已支持的功能,这里的新东西是什么。不过它是我找到的(任何语言中)最好的 JSON 解析器,我基于它的 on-demand 库实现了 fastgron(https://github.com/adamritter/fastgron)。这个库的一个问题是需要在 JSON 末尾额外填充空间,因此不支持流式处理 / 内存映射。
xiphias2查看英文原文
I don't really understand what's new here compared to what SIMDJSON supported already. Anyways, it's the best JSON parser I found (in any language), I implemented fastgron (https://github.com/adamritter/fastgron) on top of it because of the on demand library performance. One problem with the library was that it needed extra padding at the end of the JSON, so it didn't support streaming / memory mapping.
质疑对论文中“JSON 是 JS 严格子集”的表述提出疑问
> JSON 语法几乎是流行编程语言 JavaScript 的严格子集。什么 JSON 不是合法的 JS?
basil-rash查看英文原文
> The JSON syntax is nearly a strict subset of the popular programming language JavaScript. What JSON isn’t valid JS?
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2024Hacker News 讨论帖166 分 · 50 评
同领域还值得读
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 分钟编辑精选