Hungarian 匈牙利

作者: 安迪·赫茨菲尔德 日期: 1982年1月 人物: 巴德·特里布尔、汤姆·马洛伊、查尔斯·西蒙尼、比尔·阿特金森 主题: 软件设计,技术,丽莎 概要: 关于苹果第一代Macintosh的开发以及制造它的人的轶事: 一种奇怪的编程风格 , 匈牙利 Hungarian

The Macintosh computer used the same type of processor (68000) as the Lisa computer. We wanted to use as much of the code from Lisa as possible. However, most of the Lisa code was written in a programming language called Pascal. The Macintosh had less memory available, so we needed to write our code in a way that took up less space using the language that the processor understood best, which was assembly language. Even so, we could still use some of the Lisa code by translating it into assembly language by hand.

Macintosh 计算机使用与 Lisa 计算机相同类型的处理器 (68000)。我们希望尽可能多地使用 Lisa 的代码。然而,大部分 Lisa 代码是用称为 Pascal 的编程语言编写的。
Macintosh 的可用内存较少,因此我们需要使用处理器最理解的语言(即汇编语言)以占用更少空间的方式编写代码。即便如此,我们仍然可以通过手动将一些 Lisa 代码翻译成汇编语言来使用它。

We used a special graphics program called Quickdraw because it was already written mostly in a low-level language called assembly language. We also used parts of the Lisa computer’s window and menu systems, but we rewrote those in assembly language from the original code written in a different language called Pascal. This made the code smaller and easier to use. The original Pascal code was written clearly and simply, so it was easy for us to change it.

我们使用了一种名为 Quickdraw 的特殊图形程序,因为它主要是用一种称为汇编语言的低级语言编写的。
我们还使用了 Lisa 计算机的部分窗口和菜单系统,但我们用汇编语言重写了那些用另一种称为 Pascal 的语言编写的原始代码。
这使得代码更小并且更易于使用。原来的Pascal代码写得清晰简单,所以我们很容易修改它。

The Mac computer didn’t have special hardware for moving memory like bigger computers do. We needed to find a way to move memory around in the computer’s software to keep it organized. The team that worked on the Lisa computer’s word processor already made a memory manager that could move memory blocks around to prevent fragmentation (when parts of memory are wasted because blocks are too small). They called this moving parts of memory “handles”. We thought this was a good idea and decided to use it for the Macintosh. To do this, we took the memory manager’s code and translated it from a programming language called Pascal to a lower-level language called assembly language, which is faster and more powerful.

Mac 计算机没有像大型计算机那样具有移动内存的特殊硬件。我们需要找到一种方法来移动计算机软件中的内存以保持其组织有序。
开发 Lisa 计算机文字处理器的团队已经制作了一个内存管理器,可以移动内存块以防止碎片(当部分内存由于块太小而被浪费时)。他们将内存的这种移动部分称为“手柄”。
我们认为这是一个好主意,并决定将其用于 Macintosh。为此,我们获取了内存管理器的代码,并将其从称为 Pascal 的编程语言转换为称为汇编语言的较低级语言,后者更快、更强大。

Tom Malloy was the main person who made the Lisa word processor and its memory manager. He was one of the original team members and the first person from Xerox PARC (Palo Alto Research Center) that Apple hired. Tom had worked on a word processor at PARC called Bravo, and a person named Charles Simonyi was in charge. Tom took some of the skills he learned while working on Bravo and used them to make the Lisa code.

汤姆·马洛伊 (Tom Malloy) 是 Lisa 文字处理器及其内存管理器的主要开发者。他是最初的团队成员之一,也是苹果公司聘用的第一位来自施乐 PARC(帕洛阿尔托研究中心)的人员。
汤姆曾在帕洛阿尔托研究中心开发一款名为 Bravo 的文字处理器,负责人是查尔斯·西蒙尼 (Charles Simonyi)。 Tom 采用了他在 Bravo 工作时学到的一些技能,并用它们来编写 Lisa 代码。

Bud Tribble was a team member for Mac computers. But he had to leave in 1981 to continue his studies at the University of Washington. Despite this, he wanted to finish his part of the project, which was to make a memory manager program. He thought he could do it quickly after he went back to Seattle and started classes. He got the source code for the memory manager from Tom Malloy. But when he started reading the code, he was surprised and a bit shocked.

Bud Tribble 是 Mac 计算机团队的成员。但1981年他不得不离开,前往华盛顿大学继续学业。尽管如此,他还是想完成他的项目部分,即制作一个内存管理器程序。
他以为自己回到西雅图开课后很快就能做到。他从 Tom Malloy 那里获得了内存管理器的源代码。但当他开始阅读代码时,他感到惊讶,还有点震惊。

The code that manages memory didn’t have any notes or comments, which was sad. But the biggest problem was the names given to the variables and procedures. They were all made up of only consonants, with no vowels. This made it very difficult to understand the code, because it was hard to guess what each variable meant. We wondered why the code was written in such a strange way. What happened to all the vowels?

管理内存的代码没有任何注释或注释,这很遗憾。但最大的问题是变量和过程的名称。它们都仅由辅音组成,没有元音。
这使得理解代码变得非常困难,因为很难猜测每个变量的含义。我们想知道为什么代码会以如此奇怪的方式编写。所有的元音发生了什么?

It seems that Tom Malloy was greatly influenced by his teacher, Charles Simonyi, who worked at Xerox. Charles was a unique person who had strong opinions on how to make software. He developed and shared some special ways of writing code, and Tom took these ideas to the Lisa team. One of Charles’ ideas was a way to name things in a program. He thought that the part of a variable name that tells what type of thing it is should come first. This idea was a bit controversial.

汤姆·马洛伊似乎深受他的老师、在施乐公司工作的查尔斯·西蒙尼的影响。查尔斯是一个独特的人,他对如何制作软件有强烈的见解。他开发并分享了一些编写代码的特殊方法,Tom 将这些想法带到了 Lisa 团队。
查尔斯的想法之一是在程序中命名事物的方法。他认为变量名中表明事物类型的部分应该放在第一位。这个想法有点争议。

Many computers in the early 1980s only allowed variable names to be 8 characters long. This made it hard to use a name that actually explained what the variable was for, because the name had to start with a letter that showed what type of variable it was. But Charles found a way to get around this problem. He would remove all the vowels from the name, so he could use a shorter name that still made sense.

20 世纪 80 年代初的许多计算机只允许变量名的长度为 8 个字符。
这使得使用真正解释变量用途的名称变得困难,因为名称必须以显示变量类型的字母开头。
但查尔斯找到了解决这个问题的方法。他会删除名字中的所有元音,这样他就可以使用一个更短但仍然有意义的名字。

The lack of vowels made the code looked like a secret language from another country. Charles Simonyi was born and raised in Hungary, so his way of writing programs became known as “Hungarian style”. Tom Malloy’s memory manager was a good example of this Hungarian style, with the names for things looking very strange, as if they were chosen by a superpowerful being from another dimension, like Mr. Mxyzptlk.

由于缺少元音,该密码看起来像是来自另一个国家的秘密语言。 Charles Simonyi 在匈牙利出生和长大,因此他的程序编写方式被称为“匈牙利风格”。
汤姆·马洛伊的内存管理器就是这种匈牙利风格的一个很好的例子,事物的名称看起来非常奇怪,就好像它们是由来自另一个维度的超能力者选择的,比如 Mxyzptlk 先生。

Bud decided it would be too hard to directly translate the Hungarian memory manager into assembly language. So, he started by making it easier to read. First, he got rid of the special characters at the beginning of the variable names and put the vowels back in, so it wouldn’t be hard on the eyes. Then, he added lots of notes to explain what different parts of the code were for.

巴德认为直接将匈牙利内存管理器翻译成汇编语言太难了。因此,他首先让内容变得更容易阅读。
首先,他去掉了变量名开头的特殊字符,并重新放回了元音,这样就不会让眼睛感到难受。
然后,他添加了很多注释来解释代码的不同部分的用途。

Later, Bud returned to our group and brought a new version of the code that helps our computer manage its memory. It was written in a simple language that is easy to read and understand. This code became very important for our computer system, which was changing quickly at the time.

后来,巴德回到了我们的小组,并带来了新版本的代码,帮助我们的计算机管理其内存。
它是用简单的语言编写的,易于阅读和理解。这段代码对于我们当时变化很快的计算机系统来说变得非常重要。
目录