They don't make 'em like that any more: Borland Turbo Pascal 7
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
They don’t make ‘em like that any more: Borland Turbo Pascal 7
Borland’s Turbo Pascal was one of the most successful programming tools of all time. It introduced development techniques, such as integrated source-level debugging, that we take for granted today; but which were radical at the time.
Borland 的 Turbo Pascal 是有史以来最成功的编程工具之一。它引入了诸如集成源代码级调试等开发技术,这些技术在今天看来理所当然,但在当时却是激进的。
TP 7, also known as Turbo Pascal for Windows 1.5, was the pinnacle of the Turbo Pascal line, and its end. The name ‘Turbo’ was associated with what were regarded as hobbyist products – ‘Borland Pascal’ was a different, much more expensive, product. But Turbo Pascal was enough for some quite substantial applications, and was very affordable. It was also ‘book licensed’, which I think was a new thing in the software industry. You could buy one copy of TP, and any number of people could use it – but only one at a time. Even when it was distributed on floppy disks, there was no copy protection. (Turbo) Pascal eventually gave way to Delphi which, despite its technical merits, never had the same impact.
TP 7(也称为 Turbo Pascal for Windows 1.5)是 Turbo Pascal 系列的巅峰之作,也是其终点。“Turbo”这个名字与被视为业余爱好者的产品联系在一起——而“Borland Pascal”则是另一种昂贵得多的产品。但 Turbo Pascal 足以胜任一些相当重要的应用程序,而且价格非常实惠。它还采用了“图书授权”模式,我认为这在软件行业是一个新鲜事物。你可以购买一份 TP,然后让任意数量的人使用它——但同一时间只能有一人使用。即使在通过软盘分发时,它也没有任何防拷贝保护。(Turbo)Pascal 最终让位于 Delphi,尽管 Delphi 具有技术优势,但从未产生过同样的影响。
I used TP 7 to write medical imaging software back in the 90s, to run under Windows 3.1 – which was a great operating system in its day. Like previous releases, Windows 3.1 was still, essentially, an extension to MSDOS, but with clever tricks to allow it to multitask (after a fashion) and address more memory. It had a simple, consistent user interface model – both for the user and the programmer. It had, at that time, none of the wasteful and irritating anti-features that have come to make modern Windows so depressing to use. So Windows 3.1 was a platform we all wanted our applications to support – not that there were many alternatives at that time.
我在 90 年代使用 TP 7 编写医疗成像软件,运行在 Windows 3.1 下——这在当时是一款出色的操作系统。像之前的版本一样,Windows 3.1 本质上仍然是 MSDOS 的扩展,但它通过巧妙的技巧实现了(某种方式的)多任务处理并寻址更多内存。它拥有简单、一致的用户界面模型——无论是对用户还是程序员而言。在当时,它没有任何现代 Windows 中那些令人沮丧的浪费且恼人的反功能。因此,Windows 3.1 是我们所有人都希望应用程序支持的平台——尽管当时并没有太多其他选择。
Like many other programmers, I learned the Pascal programming language specifically to use TP 7 – I was essentially a C programmer in those days, but programming for Windows in C was a horrible job. Frankly, it’s scarcely better today. It was, and is, necessary to combine a whole stack of command-line tools that take incomprehensible text files as input. TP 7 automated and concealed all that nastiness.
像许多其他程序员一样,我学习 Pascal 编程语言就是为了使用 TP 7——我当时本质上是一名 C 程序员,但用 C 语言为 Windows 编程是一项糟糕的工作。坦率地说,今天的情况也好不到哪去。过去和现在都需要组合一整套命令行工具,这些工具以难以理解的文本文件作为输入。TP 7 自动化并隐藏了所有这些令人不快的过程。
It wasn’t just the tools that were a problem: the user interface model was, essentially, object-oriented; but C did not make it easy to program in an object-oriented way. TP 5 had introduced basic object-oriented concepts to the Pascal language, and these were were to prove essential. The Windows-specific features were provided by something called Object Windows Library: a relatively thick, object-oriented wrapper around the basic Windows C API. My recollection is that Borland introduced an object-oriented programming library for Microsoft Windows before Microsoft did – and Borland’s was better.
不仅是工具存在问题:用户界面模型本质上是面向对象的;但 C 语言并不容易进行面向对象编程。TP 5 向 Pascal 语言引入了基本的面向对象概念,事实证明这些概念至关重要。Windows 特有的功能由所谓的“对象窗口库”(Object Windows Library,简称 OWL)提供:这是一个围绕基本 Windows C API 的相对厚重的面向对象包装器。我的记忆是,Borland 在微软之前就为 Microsoft Windows 推出了面向对象的编程库——而且 Borland 的版本更好。
OWL made it easy to create nice-looking user interfaces, with a bit of eye candy. The familiar ‘green tick button’ was an OWL enhancement, which graced so many Windows applications that it eventually became an irritating cliche.
OWL 使得创建美观的用户界面变得容易,并带有一些视觉特效。熟悉的“绿色勾选按钮”就是 OWL 的一项增强功能,它出现在太多的 Windows 应用程序中,以至于最终变成了一个令人厌烦的陈词滥调。
All, in all, It was much easier to program for Windows using Turbo Pascal 7 than with anything else. Not only did it provide a programming model that matched the way the Windows user interface worked, the application itself had a Windows graphical interface – many Windows programming tools at that time actually ran under MSDOS, and were entirely text-based. TP 7 also had fully-graphical tools for designing the user interface elements, like menus and icons. Laying out a menu using a definition file with an obscure format, using Windows Notepad, was never an agreeable experience. Microsoft did produce graphical tools for this kind of operation, but Turbo Pascal combined them into a seamless IDE. All I had to do to build and run my programs was to hit the F7 key. I could even set breakpoints for the debugger, just by clicking a line of code. As I said, common enough today, but revolutionary for early Windows programming.
总而言之,使用 Turbo Pascal 7 进行 Windows 编程比使用其他任何工具都要容易得多。它不仅提供了一种与 Windows 用户界面工作方式相匹配的编程模型,而且应用程序本身也拥有 Windows 图形界面——当时许多 Windows 编程工具实际上是在 MSDOS 下运行的,并且完全基于文本。TP 7 还拥有用于设计菜单和图标等用户界面元素的全图形化工具。使用 Windows 记事本通过格式晦涩的定义文件来布局菜单,从来都不是一种愉快的体验。微软确实为这类操作提供了图形化工具,但 Turbo Pascal 将它们整合到了一个无缝的集成开发环境(IDE)中。我构建并运行程序所要做的就是按下 F7 键。我甚至可以通过点击一行代码来为调试器设置断点。正如我所说,这在今天很常见,但在早期的 Windows 编程中却是革命性的。
But what really made TP 7 special was its CP/M heritage. Turbo Pascal came to Windows by way of CP/M and MSDOS, which meant it had a compiler core that was designed to run with tight memory and a comparatively slow CPU. In the days when most compilers had to write a stack of intermediate files on disk, TP just constructed everything in memory. It did this using highly-optimized code, written in assembly language, by very skilled people. It doesn’t matter much today if your compiler spits out a heap of temporary files, because disk storage is fast and cheap. But in the days of the floppy disk, you had to minimize disk access. Unfortunately, you also had to minimize memory use, because there wasn’t much of that, either. Programming for CP/M took real skill and dedication.
但真正让 TP 7 与众不同的是它的 CP/M 血统。Turbo Pascal 是通过 CP/M 和 MSDOS 演变到 Windows 的,这意味着它的编译器核心旨在在内存紧张和 CPU 相对缓慢的情况下运行。在大多数编译器必须在磁盘上写入一堆中间文件的年代,TP 只是在内存中构建一切。它通过由技术精湛的人员用汇编语言编写的高度优化代码来实现这一点。今天,如果你的编译器生成一堆临时文件并不重要,因为磁盘存储既快速又便宜。但在软盘时代,你必须尽量减少磁盘访问。不幸的是,你还必须尽量减少内存使用,因为内存也非常有限。为 CP/M 编程需要真正的技能和奉献精神。
So when TP came to Windows machines, with their 16-bit CPUs and megabytes of RAM, it was like an early Christmas for developers. A compiler designed to be adequate with 32kB of RAM and a single floppy drive will positively fly when given megabytes and a hard disk.
因此,当 TP 进入拥有 16 位 CPU 和兆字节内存的 Windows 机器时,这对开发者来说就像提前过圣诞节一样。一个设计用于在 32kB 内存和单软驱环境下就能胜任的编译器,在拥有兆字节内存和硬盘的环境下,运行速度简直是飞快。
All this meant that TP 7 was a joy to use. It was like a modern IDE, but without any of the bloat. Developers who would never have tackled Windows programming with Microsoft tools were able to move from MSDOS to Windows without too much difficulty – even if they first had to learn Pascal, as I did. The compiled code was pretty speedy but, if it wasn’t brisk enough, you could write assembly language directly in the Pascal source files.
所有这些意味着使用 TP 7 是一种享受。它就像一个现代的 IDE,但没有任何臃肿。那些原本绝不会使用微软工具进行 Windows 编程的开发者,能够毫无困难地从 MSDOS 转向 Windows——即使他们像我一样必须先学习 Pascal。编译后的代码速度相当快,但如果速度不够快,你还可以在 Pascal 源代码文件中直接编写汇编语言。
I don’t think it’s too much of an exaggeration to claim that Turbo Pascal contributed to the widespread uptake, and eventual domination, of Microsoft Windows on desktop PCs. If there had been a ‘Turbo Pascal for Linux’ in the early 90s, then we might all be running Linux on our desktops today.
我认为称 Turbo Pascal 为 Microsoft Windows 在桌面 PC 上的广泛普及和最终统治做出了贡献,并不算夸张。如果 90 年代初有“Turbo Pascal for Linux”,那么我们今天可能都在桌面上运行 Linux 了。
So what happened to Turbo Pascal? Three things, at least, contributed to its eventual downfall.
那么 Turbo Pascal 发生了什么?至少有三件事导致了它的最终衰落。
First, there was increasing competition from the C programming language. Borland did produce a Turbo C, and later a Turbo C++, but they weren’t as influential as Pascal. It’s easy to forget that PCs weren’t the first general-purpose computing devices. Most scientific and educational establishments, and many businesses, used graphical worksta
首先,来自 C 编程语言的竞争日益激烈。Borland 确实生产了 Turbo C,后来又生产了 Turbo C++,但它们的影响力不如 Pascal。人们很容易忘记,PC 并不是最早的通用计算设备。大多数科研和教育机构以及许多企业都使用图形工作站。