Skip to content

Commit

Permalink
first real blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jan 14, 2024
1 parent 6984ca5 commit e8c9853
Showing 1 changed file with 35 additions and 110 deletions.
145 changes: 35 additions & 110 deletions 2024-01-04-post.md
Original file line number Diff line number Diff line change
@@ -1,113 +1,38 @@
---
title: "Language and Code"
date: 2024-01-04
title: "Some Memories of Niklaus Wirth"
date: 2024-01-14
---

This is a first trial run for my blog. Let's check whether syntax highlighting works:

```scala
object Test:
def f(x: String) = s"hello, $x"
```

And something bigger:

```scala
//> using options -YXtypeclass -source future
package hylo

/** A collection of elements accessible by their position. */
trait Collection:
type Self

/** The type of the elements in the collection. */
type Element: Value

/** The type of a position in the collection. */
type Position: Value

extension (self: Self)

/** Returns `true` iff `self` is empty. */
def isEmpty: Boolean =
startPosition `eq` endPosition

/** Returns the number of elements in `self`.
*
* @complexity
* O(n) where n is the number of elements in `self`.
*/
def count: Int =
val e = endPosition
def loop(p: Position, n: Int): Int =
if p `eq` e then n else loop(self.positionAfter(p), n + 1)
loop(startPosition, 0)

/** Returns the position of `self`'s first element', or `endPosition` if `self` is empty.
*
* @complexity
* O(1)
*/
def startPosition: Position

/** Returns the "past the end" position in `self`, that is, the position immediately after the
* last element in `self`.
*
* @complexity
* O(1).
*/
def endPosition: Position

/** Returns the position immediately after `p`.
*
* @requires
* `p` is a valid position in `self` different from `endPosition`.
* @complexity
* O(1).
*/
def positionAfter(p: Position): Position

/** Accesses the element at `p`.
*
* @requires
* `p` is a valid position in `self` different from `endPosition`.
* @complexity
* O(1).
*/
def at(p: Position): Element

/** Returns `true` iff `i` precedes `j`.
*
* @requires
* `i` and j` are valid positions in `self`.
* @complexity
* O(n) where n is the number of elements in `self`.
*/
def isBefore(i: Position, j: Position): Boolean =
val e = self.endPosition
if i `eq` e then false
else if j `eq` e then true
else
def recur(n: Position): Boolean =
if n `eq` j then true
else if n `eq` e then false
else recur(self.positionAfter(n))
recur(self.positionAfter(i))

class Slice2(val base: Self, val bounds: Range[Position]):

def isEmpty: Boolean =
bounds.lowerBound.eq(bounds.upperBound)

def startPosition: Position =
bounds.lowerBound

def endPosition: Position =
bounds.upperBound

def at(p: Position): Element =
base.at(p)
end Slice2

end Collection
```
January 2024

Niklaus Wirth passed away on the first day of this year. He was one of the most important pioneers of computer science, probably the one who had the biggest practical impact while maintaining at the same time rigorous scientific and engineering principles. Niklaus described himself as an engineer, and that's what he was. As an engineer, he applied scientific discoveries and principles in the development of useful products, which included programming languages, compilers and other systems software. But he had to create a large chunk of the science himself, since it did not yet exist at the time.

I was privileged to have worked with him as his PhD student, and to have learned a lot from him. In this note I want to write about some of the ways Niklaus influenced my work and my approach to programming.

In fact, if it was not for Niklaus, it's doubtful I would have ended up in computer science at all. My first degree was in Mathematics. I got interested in Computer Science because I was fascinated by compilers and programming languages. The first language I deeply appreciated was Pascal. It was simple and clean, and easy to understand from both design and implementation aspects. Together with a Peter Sollich, a fellow student, I then stumbled upon the source code listings of the Pascal to P-Code compiler. It was amazing that a full Pascal compiler could be written in about 5000 lines of easy-to-understand code. This set in motion our project to write our own Pascal compiler for a new Microcomputer, the [Osborne 1](https://en.wikipedia.org/wiki/Osborne_1). This was a year or so before Turbo Pascal came out.

About half-way through the project, Peter discovered another pair of slim yellow-bound research reports from Niklaus Wirth at ETH. One described the language Modula-2, the other the instruction set for the Lilith computer that implemented the language. We were immediately fascinated by both the language and the instruction set, which was both simple and very compact. At the time, saving memory was of paramount importance since our computer had only 54 Kilobytes of usable memory. So we switched the compiled source language to Modula-2 and the intermediate code to a variant of Lilith's code. This compiler eventually became [Turbo Modula-2](https://github.com/Oric4ever/Turbo-Modula-2-Reloaded) for 8 bit computers. We sold it to Borland, but the company did not distribute it under their own name.

After having experienced and worked with Wirth's beautiful inventions, it was clear to me that I wanted to continue with PhD studies in programming languages and I applied to his group. I was very happy that my application was accepted and I started working at ETH in 1986.

The work in Wirth's group was quite special. I realized how different the workplace was only after I had moved on. You see, _everything_ we worked with was "homebrew" stuff, but at the same time was advanced way beyond the standard of the time. It started with the computer: A screen that could show a full a A4 page on a bitmapped display, and a mouse for interacting with it. This at least 5 years before a commercial computer with these characteristics came out. It continued with the fonts. Since there were no bitmapped displays there were no fonts for such displays either. So one member of the group was a professional font designer, and another member was a designer for font-designing tools! It continued with the operating system, and the programming tools. We had a simple but powerful text editor which was configurable to be a very productive IDE. We also had a simple and beautiful debugger that showed a thread-dump with full memory exploration in a set of tiled windows. I forgot to mention, of course the windowing system was also developed in house, everything was.

Now you might think that there would have been an army of developers doing these things. But no, it was Niklaus Wirth with 6 doctoral students, as well as some researchers in the associated groups of Jürg Gutknecht and Peter Mössenböck. The best thing was, if you had a question or suggestion, you would just walk into the office next door and talk to the person who wrote the software.

All this was possible only because Niklaus led the way with his approach to ruthless simplicity. Simplicity was mandatory. Every feature had to be justified to be both essential _and_ very compact to implement. Famously, compiler optimizations were only added if they increased the speed of bootstrapping the compiler. Niklaus led the way in his own coding and in his teaching to us.

I think of the sequence of languages that Niklaus worked as a kind of culmination of Von Neumann languages. After his thesis project EULER he worked on ALGOL-W, a proposed successor to Algol 60, that was supported by other leading lights of computer science such as Tony Hoare or Edsger Dijkstra, but that was ultimately not accepted as the official next version of Algol. Next came Pascal, with huge success in teaching and on PCs. After Pascal came Modula and then Modula-2, which was the language I personally liked best. It added to Pascal modularity concepts that allowed a team of developers to work on a common code base, as well as concurrency concepts that were cleaner and more powerful than what came 15 years later with Java. The last of the Wirth languages was Oberon, which added a minimalistic construct to support the kind of extensible programs that were the domain of object-orientation and otherwise dropped quite a few features from Modula-2. It was consequently even easier to implement than Modula-2 and it was therefore possible to develop a complete operating system with GUI and compiler in a small code base and describe it in a single book.

My own thesis was about developing a new kind of attribute grammar and writing a specification of Oberon in it.
Towards the end of my stay at ETH, I discovered and fell in love with functional programming, which was quite different from what we used to do at ETH. But the style and values I learned from Niklaus have stayed with me ever since, and I am very, very grateful that I could experience them first-hand.

A couple of specific things I remember:

- Niklaus was not fond of committees, probably as a result of his experiences on the Algol 68 committee. I was invited to be part of the ISO standardization committee for Modula-2. Wirth told me I could go if I wanted, but made it clear that he did not think it was a worthwhile endeavor. He would not consider to attend himself. I attended a few sessions of the committee and then dropped out.

- Niklaus saw his role mostly as a pioneer and a researcher, not so much as a leader of a language community. Shortly before I arrived in Zurich, Modula-2 had a small moment of fame, with a whole issue of the then leading PC Magazine _Byte_ devoted to it. With more support, Modula-2 might have become a widespread systems language, it would have certainly deserved it, There was also a successor language proposal called Modula-3 developed by Luca Cardelli, Greg Nelson and others at DEC SRC. This was also a very clean and elegant language design, and more ambitious and powerful than Modula-2. If Niklaus had joined the effort, who knows, it might have been a popular successor and competitor to C++. But he was already working on his next thing, Oberon.

Niklaus combined theoretical and practical results more deeply than any other person I know. He was one of the fathers of structured programming and pioneered program refinement, beautifully explained in his book "Data Structures + Algorithms = Programs". Yet he did all that to gain better practical abstractions that helped him design clean operating systems, compilers, and other tools, all in a few kilobytes of memory. Unlike other systems languages such as C, Wirth's languages never compromised on having tight abstractions. I believe that is his lasting legacy: how theory and abstraction _helps_ in day to day programming, but only if it is done right, with a ruthless focus on simplicity.



0 comments on commit e8c9853

Please sign in to comment.