SQLite 文档的学习笔记(1)长期支持计划

2022-08-04
标签: SQLITE

前段时间偶然用了 sqlite,在阅读了文档后,感到 sqlite 背后是一个严谨、负责、专业的团队。通过阅读这些文档能学习到不少专业知识和精神。

可惜这些文档的中文版,看起来是使用机器翻译的。我打算在这里以读书笔记的方式,给出一份自己翻译的中文版。

这篇支持计划可以看做是今天的作者写给未来的参与者的信,讲述了过去和今天的做法,树立了今后 SQLite 的开发活动价值观和方法论。在我们的项目中,有值得学习的地方。

原始材料:Long Term Support,中文版:长期支持

正文

The intent of the developers is to support SQLite through the year 2050.

SQLite 开发者的意愿是,将 SQLite 一直支持到 2050 年。

At this writing, 2050 is still 34 years in the future. Nobody knows what will happen in that time, and we cannot absolutely promise that SQLite will be viable or useful that far out. But we can promise this: we plan as if we will be supporting SQLite until 2050. That long-term outlook affects our decisions in important ways.

在编写本文的时候,距离 2050 年还有 34 年之遥,谁也不知道那时的世界会是什么样子。同时,我们也不能保证,在那么久远的将来,SQLite 仍然可以使用甚至能不能运行。然而,我们今天作出保证:我们将按照我们能一直支持到 2050 年的假设去规划我们今天的开发活动,这个远期的目标指引着我们今天的价值取向,有如下几点:

Cross-platform Code: SQLite runs on any platform with an 8-bit byte, two’s complement 32-bit and 64-bit integers, and a C compiler. It is actively tested on all currently popular CPUs and operating systems. The extreme portability of the SQLite code and file format will help it remain viable on future platforms.

跨平台兼容能力:SQLite 要能运行在具备以下条件的所有平台上:8比特长的字节、2补码的二进制、32位或64位、有C编译器。SQLite 针对当前流行的CPU和操作系统积极主动地开展测试。SQLite 自身代码和使用的文件格式具备极高的可移植性,这将保证它在未来仍可以运行。

Stable, Cross-platform Database Files: SQLite database files are bit-for-bit identical on 32-bit, 64-bit, big-endian, and little-endian platforms. You can copy an SQLite database file from one system to another without having to translate or convert the database. Furthermore, the file format is well documented and stable. Database files created today will be readable and writable by future versions of SQLite decades in the future.

稳定的、多个平台一致的数据文件: SQLite 保存数据的文件能在 32-bit、64-bit、大端字节、小端字节等各种平台下,做到逐个 bit 的相同。这意味着你从一种平台拷贝数据文件到另一种平台后,不需要转换数据文件格式就能直接读取和运行。而且,数据文件的格式有着详尽而又稳定的文档。几十年后的 SQLite 仍然可以直接读写今天创建的数据文件。

Aviation-grade testing: Every machine-code branch instruction is tested in both directions. Multiple times. On multiple platforms and with multiple compilers. This helps make the code robust for future migrations. The intense testing also means that new developers can make experimental enhancements to SQLite and, assuming legacy tests all pass, be reasonably sure that the enhancement does not break legacy.

航空级的软件测试过程:SQLite 程序的每一条机器码的分支指令都从两个方向、反复多次、多种平台、多种编译器的完整测试。(注:这是乘法关系,假设有10万个测试场景、5次、5种平台、5种编译器,完整的测试次数将是:10万×5×5×5=1250万次测试)。这样做的目的是让代码保持健壮,不易出错,以备未来的各种迁移重构。另外,严格充分的测试,还能让后继的开发者(可不,现在写这套代码的人,到2050年还有几个能写?)敢于编写一些具有试验性的新功能,待这些新功能发布后,如果以往的测试集在新代码上都能通过,我们能有理由的认为,至少所有的旧功能仍然正常工作。

(关于 SQLite 的测试,有 另一篇文章 做介绍)

Extensive, detailed documentation: SQLite has candid, developer-friendly, and open-source documentation. Docs are written by and for programmers. (A few examples: [1] [2] [3] [4] [5] [6] [7] [8]) The extensive documentation helps new developers come up to speed on SQLite very quickly.

丰富、详尽的文档:SQLite 的文档内容诚恳、坦率、对开发者友好、源代码开放。这些文档从程序员中来、到程序员中去,让后继的开发者能迅速的融入 SQLite 的开发过程中。

文档的示例:

  1. Architecture of SQLite
  2. Database File Format
  3. Query Planning
  4. The SQLite Bytecode Engine
  5. Compile-time Options
  6. Dynamic Memory Allocation In SQLite
  7. Debugging Hints
  8. How To Corrupt An SQLite Database File

Heavily commented source code: The SQLite source code is over 35% comment. Not boiler-plate comments, but useful comments that explain the meaning of variables and objects and the intent of methods and procedures. The code is designed to be accessible to new programmers and maintainable over a span of decades.

大量的代码注释:SQLite 源代码中,注释占到了 35% 以上。而且这些注释都不是言之无物,反而是大有用处。这些注释的内容包括代码中变量和对象的含义、函数方法的设计意图等。这些代码旨在让新加入的程序员能够无压力的阅读,并且能在数十年的跨度内方便维护,而不至于烂到无从下手。

Disaster planning: Every byte of source-code history for SQLite is cryptographically protected and is automatically replicated to multiple geographically separated servers, in datacenters owned by different companies. Thousands of additional clones exist on private servers around the world. The primary developers of SQLite live in different regions of the world. SQLite can survive a continental catastrophe.

预防灾难:SQLite 源代码的每次更新记录的每个字节都被加密保存,而且被自动地备份在多个数据中心上,这些数据中心不仅在地理空间上分隔(注:防天灾),而且还分属于不同的公司(注:避人祸)。此外,还有数以千计的代码备份在世界各地的私有服务器上。SQLite 的主要开发者生活在世界各地。所以即使世界缺了一块(比如小行星撞地球),也不会影响到 SQLite。

Old school: Nobody is completely immune to trends and fads, but the SQLite developers work hard to avoid being sucked into the latest programming fashion. Our aim is to produce timeless code that will be readable, understandable, and maintainable by programmers who have not yet been born.

坚持旧时风格:随着软件工业的发展,每个人或多或少会受到所处时代的潮流和时尚的影响,但 SQLite 开发人员努力避免被最新的编程流行做法所吸引。我们的目标是编写永不过时的代码,好让那些今天尚未出生的程序员在以后的日子里,仍然能够阅读、理解和维护这些代码。

In addition to “supporting” SQLite through the year 2050, the developers also promise to keep the SQLite C-language API and on-disk format fully backwards compatible. This means that application written to use SQLite today should be able to link against and use future versions of SQLite released decades in the future.

除了声明“支持”(注:指被动的解决客户的问题)到2050年以外,SQLite 的开发者承诺:将 C 语言的接口和数据文件格式完全向后兼容。这意味着未来的新代码不破坏旧的接口,旧代码仍然能够调用新代码的接口、读取新版本的数据文件,新旧版本可能横跨几十年之久。

Our goal is to make the content you store in SQLite today as easily accessible to your grandchildren as it is to you.

我们的目标:您的孙辈拿到您遗留给他们的 SQLite 数据文件,仍然可以用那时的 SQLite 软件轻松的打开,那种轻松的感觉就和你今天打开别无二致。

如果您对本站内容有疑问或者寻求合作,欢迎 联系邮箱邮箱已到剪贴板

标签: SQLITE

欢迎转载本文,惟请保留 原文出处 ,且不得用于商业用途。
本站 是个人网站,若无特别说明,所刊文章均为原创,并采用 署名协议 CC-BY-NC 授权。

相关文章