解释器 = 操作系统?

今天在 Google Plus 上看到 Russ Cox (Go语言的作者之一) 分享了 James Hague 的一篇博文:Don’t Fall in Love With Your Technology。文中提到 James 10年前迷恋于 Forth 语言的编译器,但是后来发现根本没人用这种语言。此文的目的是劝大家不要过于迷恋某一项很棒的技术(比如 Forth 语言和 Linux),以至于阻碍自己接受新技术。

随后 Ian Taylor (GNU Go 编译器的作者)回复了 Russ Cox 的分享,说到自己年轻时候“浪费精力”的一个故事:

When I was in high school I wrote a threaded language interpreter for a Forth-like language for my TRS-80. It booted up in Forth and called into the ROM to do disk access. The screen was memory mapped, of course. I wrote an editor in it, and my freshman year in college I wrote all my papers in that editor. I never wrote a real file system, the files were all accessed by block number on the disk. I think the first block might have been a directory, limiting the number of possible files. The disks only held 89K anyhow. I printed the papers on my Epson-100 that I bought with some scholarship money I won at my high school. I was quite the high-tech guy. But I never used Forth again after that. By my senior year I had a Mac, the original one.

Ian真神人也!我猜Ian是想附和一下。但是反而让我疑惑了:是不是真的得先迷恋技术,才能把握技术方向?

我向朋友们转述 Ian 的这个故事的时候,有人对用“Forth语言的解释器来控制计算机”表示不理解。Ian 提到的控制显示器和访问磁盘,现在都是通过操作系统来做的;怎么会通过一个“解释器”来做呢?

我印象里老的机器很多没有操作系统的。80年代用中华学习机(Apple II的中科院山寨)的时候,开机时是默认从 ROM 中启动一个 monitoring 程序(而不是操作系统)的。这个 monitoring 程序检查机器之后,引导一个 BASIC 语言的解释器。随后,用户可以用 BASIC 语言程序(脚本?)做任何现在只有操作系统才有权限做的事情。比如 PEEK 和 POKE 某个 IO 端口。从 BASIC 解释器里还能访问录音机,启动磁带里录制的程序,包括游戏。

从这个意义上讲,今天的 Python 和 Ruby 再牛,也没有牛到取代操作系统的份儿上。呵呵。

Ian 用的 TRS-80 是 70 年代的机器。附上几张 TRS-80 的“玉照”: