pgstrata
Five Questions about Language Design
2

May 2001

3

(These are some notes I made for a panel discussion on programming language design at MIT on May 10, 2001.)

4

5

1. Programming Languages Are for People.

6

Programming languages are how people talk to computers.

7

The computer would be just as happy speaking any language that was unambiguous.

8

The reason we have high level languages is because people can't deal with machine language.

9

The point of programming languages is to prevent our poor frail human brains from being overwhelmed by a mass of detail.

10

Architects know that some kinds of design problems are more personal than others.

11

One of the cleanest, most abstract design problems is designing bridges.

12

There your job is largely a matter of spanning a given distance with the least material.

13

The other end of the spectrum is designing chairs.

14

Chair designers have to spend their time thinking about human butts.

15

Software varies in the same way.

16

Designing algorithms for routing data through a network is a nice, abstract problem, like designing bridges.

17

Whereas designing programming languages is like designing chairs: it's all about dealing with human weaknesses.

18

Most of us hate to acknowledge this.

19

Designing systems of great mathematical elegance sounds a lot more appealing to most of us than pandering to human weaknesses.

20

And there is a role for mathematical elegance: some kinds of elegance make programs easier to understand.

21

But elegance is not an end in itself.

22

And when I say languages have to be designed to suit human weaknesses, I don't mean that languages have to be designed for bad programmers.

23

In fact I think you ought to design for the best programmers [blocked], but even the best programmers have limitations.

24

I don't think anyone would like programming in a language where all the variables were the letter x with integer subscripts.

25

2. Design for Yourself and Your Friends.

26

If you look at the history of programming languages, a lot of the best ones were languages designed for their own authors to use, and a lot of the worst ones were designed for other people to use.

27

When languages are designed for other people, it's always a specific group of other people: people not as smart as the language designer.

28

So you get a language that talks down to you.

29

Cobol is the most extreme case, but a lot of languages are pervaded by this spirit.

30

It has nothing to do with how abstract the language is.

31

C is pretty low-level, but it was designed for its authors to use, and that's why hackers like it.

32

The argument for designing languages for bad programmers is that there are more bad programmers than good programmers.

33

That may be so.

34

But those few good programmers write a disproportionately large percentage of the software.

35

I'm interested in the question, how do you design a language that the very best hackers will like?

36

I happen to think this is identical to the question, how do you design a good programming language?, but even if it isn't, it is at least an interesting question.

37

3. Give the Programmer as Much Control as Possible.

38

Many languages (especially the ones designed for other people) have the attitude of a governess: they try to prevent you from doing things that they think aren't good for you.

39

I like the opposite approach: give the programmer as much control as you can.

40

When I first learned Lisp, what I liked most about it was that it considered me an equal partner.

41

In the other languages I had learned up till then, there was the language and there was my program, written in the language, and the two were very separate.

42

But in Lisp the functions and macros I wrote were just like those that made up the language itself.

43

I could rewrite the language if I wanted.

44

It had the same appeal as open-source software.

45

4. Aim for Brevity.

46

Brevity is underestimated and even scorned.

47

But if you look into the hearts of hackers, you'll see that they really love it.

48

How many times have you heard hackers speak fondly of how in, say, APL, they could do amazing things with just a couple lines of code?

49

I think anything that really smart people really love is worth paying attention to.

50

I think almost anything you can do to make programs shorter is good.

51

There should be lots of library functions; anything that can be implicit should be; the syntax should be terse to a fault; even the names of things should be short.

52

And it's not only programs that should be short.

53

The manual should be thin as well.

54

A good part of manuals is taken up with clarifications and reservations and warnings and special cases.

55

If you force yourself to shorten the manual, in the best case you do it by fixing the things in the language that required so much explanation.

56

5. Admit What Hacking Is.

57

A lot of people wish that hacking was mathematics, or at least something like a natural science.

58

I think hacking is more like architecture.

59

Architecture is related to physics, in the sense that architects have to design buildings that don't fall down, but the actual goal of architects is to make great buildings, not to make discoveries about statics.

60

What hackers like to do is make great programs. And I think, at least in our own minds, we have to remember that it's an admirable thing to write great programs, even when this work doesn't translate easily into the conventional intellectual currency of research papers.

61

Intellectually, it is just as worthwhile to design a language programmers will love as it is to design a horrible one that embodies some idea you can publish a paper about.

6–9

Programming languages are how people talk to computers. We have high level languages because people can't deal with machine language; the point is to keep our poor frail human brains from being overwhelmed by detail.

10–17

Designing bridges is clean and abstract: span a distance with the least material. Designing chairs is the other end, all about human butts. Designing languages is like designing chairs, all about human weaknesses.

18–24

Most of us hate to acknowledge this. Mathematical elegance sounds more appealing, and some of it makes programs easier to understand, but elegance is not an end in itself. This doesn't mean designing for bad programmers; you should design for the best programmers [blocked], but even they have limitations.

26–31

A lot of the best languages were designed for their own authors, the worst for other people, and that group is always people not as smart as you, so the language talks down to you. Cobol is the extreme case. C is low-level but built for its authors, which is why hackers like it.

32–36

There are more bad programmers than good, but the few good ones write a disproportionate share of the software. I want to know how to design a language the very best hackers will like, which I think is identical to designing a good one.

38–44

Many languages act like a governess, preventing what they think isn't good for you. I like the opposite: give the programmer all the control you can. What I loved about Lisp was that it considered me an equal partner: my functions and macros were just like those in the language itself, and I could rewrite the language if I wanted. It had the appeal of open-source software.

46–51

Brevity is underestimated and even scorned, but hackers love it; recall how they speak of doing amazing things in APL with a couple lines. Almost anything that makes programs shorter is good: lots of library functions, terse syntax, even short names.

52–55

The manual should be thin too. Force yourself to shorten it and, in the best case, you do it by fixing the things in the language that required so much explanation.

57–61

A lot of people wish hacking was a science. I think it's more like architecture: buildings can't fall down, but the goal is great buildings, not discoveries about statics. Designing a language programmers will love is just as worthwhile as designing a horrible one you can publish a paper about.

2–61

Languages exist to suit human weakness, not mathematical elegance, so design for the best hackers, give them control, aim for brevity, and admit that hacking is more like architecture than science.

63

64

1. How to Organize Big Libraries?

65

Libraries are becoming an increasingly important component of programming languages.

66

They're also getting bigger, and this can be dangerous.

67

If it takes longer to find the library function that will do what you want than it would take to write it yourself, then all that code is doing nothing but make your manual thick. (The Symbolics manuals were a case in point.)

68

So I think we will have to work on ways to organize libraries.

69

The ideal would be to design them so that the programmer could guess what library call would do the right thing.

70

2. Are People Really Scared of Prefix Syntax?

71

This is an open problem in the sense that I have wondered about it for years and still don't know the answer.

72

Prefix syntax seems perfectly natural to me, except possibly for math.

73

But it could be that a lot of Lisp's unpopularity is simply due to having an unfamiliar syntax.

74

Whether to do anything about it, if it is true, is another question.

75

3. What Do You Need for Server-Based Software?

76

I think a lot of the most exciting new applications that get written in the next twenty years will be Web-based applications, meaning programs that sit on the server and talk to you through a Web browser.

77

And to write these kinds of programs we may need some new things.

78

One thing we'll need is support for the new way that server-based apps get released.

79

Instead of having one or two big releases a year, like desktop software, server-based apps get released as a series of small changes.

80

You may have as many as five or ten releases a day.

81

And as a rule everyone will always use the latest version.

82

You know how you can design programs to be debuggable?

83

Well, server-based software likewise has to be designed to be changeable.

84

You have to be able to change it easily, or at least to know what is a small change and what is a momentous one.

85

Another thing that might turn out to be useful for server based software, surprisingly, is continuations.

86

In Web-based software you can use something like continuation-passing style to get the effect of subroutines [blocked] in the inherently stateless world of a Web session.

87

Maybe it would be worthwhile having actual continuations, if it was not too expensive.

88

4. What New Abstractions Are Left to Discover?

89

I'm not sure how reasonable a hope this is, but one thing I would really love to do, personally, is discover a new abstraction-- something that would make as much of a difference as having first class functions or recursion or even keyword parameters.

90

This may be an impossible dream.

91

These things don't get discovered that often.

92

But I am always looking.

65–69

Libraries are increasingly important and big, which is dangerous: if finding the function takes longer than writing it, the code only thickens your manual, as the Symbolics manuals showed. We need to organize them so a programmer can guess which call does the right thing.

70–74

Are people really scared of prefix syntax? I've wondered for years and still don't know. It seems perfectly natural to me, except maybe for math. But a lot of Lisp's unpopularity may simply be its unfamiliar syntax.

76–81

A lot of the most exciting applications of the next twenty years will be Web-based: programs on the server, reached through a browser. They'll need support for getting released as a series of small changes, maybe five or ten a day, with everyone always on the latest version.

82–87

Just as you design programs to be debuggable, server-based software has to be designed to be changeable. Continuations might also help: continuation-passing style gets the effect of subroutines [blocked] in the stateless world of a Web session, so actual continuations might be worthwhile, if not too expensive.

89–92

I'd love to discover a new abstraction, one that makes as much difference as first class functions or recursion. It may be an impossible dream. But I am always looking.

63–92

Four things I still don't know: how to organize big libraries, whether prefix syntax really scares people, what server-based software needs, and what new abstractions are left to find.

94

95

1. You Can Use Whatever Language You Want.

96

Writing application programs used to mean writing desktop software.

97

And in desktop software there is a big bias toward writing the application in the same language as the operating system.

98

And so ten years ago, writing software pretty much meant writing software in C. Eventually a tradition evolved: application programs must not be written in unusual languages.

99

And this tradition had so long to develop that nontechnical people like managers and venture capitalists also learned it.

100

Server-based software blows away this whole model.

101

With server-based software you can use any language you want.

102

Almost nobody understands this yet (especially not managers and venture capitalists).

103

A few hackers understand it, and that's why we even hear about new, indy languages like Perl and Python.

104

We're not hearing about Perl and Python because people are using them to write Windows apps.

105

What this means for us, as people interested in designing programming languages, is that there is now potentially an actual audience for our work.

106

2. Speed Comes from Profilers.

107

Language designers, or at least language implementors, like to write compilers that generate fast code.

108

But I don't think this is what makes languages fast for users.

109

Knuth pointed out long ago that speed only matters in a few critical bottlenecks.

110

And anyone who's tried it knows that you can't guess where these bottlenecks are.

111

Profilers are the answer.

112

Language designers are solving the wrong problem.

113

Users don't need benchmarks to run fast. What they need is a language that can show them what parts of their own programs need to be rewritten.

114

That's where speed comes from in practice.

115

So maybe it would be a net win if language implementors took half the time they would have spent doing compiler optimizations and spent it writing a good profiler instead.

116

3. You Need an Application to Drive the Design of a Language.

117

This may not be an absolute rule, but it seems like the best languages all evolved together with some application they were being used to write.

118

C was written by people who needed it for systems programming.

119

Lisp was developed partly to do symbolic differentiation, and McCarthy was so eager to get started that he was writing differentiation programs even in the first paper on Lisp, in 1960.

120

It's especially good if your application solves some new problem.

121

That will tend to drive your language to have new features that programmers need.

122

I personally am interested in writing a language that will be good for writing server-based applications.

123

[During the panel, Guy Steele also made this point, with the additional suggestion that the application should not consist of writing the compiler for your language, unless your language happens to be intended for writing compilers.]

124

4. A Language Has to Be Good for Writing Throwaway Programs.

125

You know what a throwaway program is: something you write quickly for some limited task.

126

I think if you looked around you'd find that a lot of big, serious programs started as throwaway programs. I would not be surprised if most programs started as throwaway programs. And so if you want to make a language that's good for writing software in general, it has to be good for writing throwaway programs, because that is the larval stage of most software.

127

5. Syntax Is Connected to Semantics.

128

It's traditional to think of syntax and semantics as being completely separate.

129

This will sound shocking, but it may be that they aren't.

130

I think that what you want in your language may be related to how you express it.

131

I was talking recently to Robert Morris, and he pointed out that operator overloading is a bigger win in languages with infix syntax.

132

In a language with prefix syntax, any function you define is effectively an operator.

133

If you want to define a plus for a new type of number you've made up, you can just define a new function to add them.

134

If you do that in a language with infix syntax, there's a big difference in appearance between the use of an overloaded operator and a function call.

96–99

Writing applications used to mean desktop software, biased toward the operating system's language, which ten years ago meant C. A tradition evolved that applications must not be written in unusual languages, so old that even managers and venture capitalists learned it.

100–105

Server-based software blows away this model: you can use any language you want. Almost nobody understands this yet, especially not managers and VCs. A few hackers do, which is why we hear about indy languages like Perl and Python at all. For us it means there's now an actual audience for our work.

107–111

Implementors like compilers that generate fast code, but that isn't what makes languages fast for users. Knuth pointed out long ago that speed only matters in a few critical bottlenecks, and you can't guess where they are. Profilers are the answer.

112–115

Language designers are solving the wrong problem. Users need a language that shows them which parts of their own programs to rewrite. It might be a net win to take half the time spent on compiler optimizations and write a good profiler instead.

117–122

The best languages all evolved alongside some application. C came from systems programming; Lisp came partly from symbolic differentiation, and McCarthy was so eager he was writing differentiation programs in the first paper on Lisp in 1960. It especially helps if the application solves a new problem, which drives the language toward new features.

125–126

A throwaway program is something you write quickly for a limited task. A lot of big, serious programs started as throwaways; I'd guess most did. So a language good for software in general has to be good for throwaways, because that's the larval stage of most software.

128–134

It's traditional to think of syntax and semantics as separate, but they may not be: what you want in a language may be related to how you express it. Robert Morris pointed out that operator overloading is a bigger win with infix syntax. In a prefix language any function is effectively an operator, so to add a new kind of number you just define one; with infix there's a visible difference between an overloaded operator and a function call.

94–134

Server-based software lets you use any language; speed comes from profilers, not fast compilers; languages need a driving application; they must suit throwaway programs; and syntax turns out to be connected to semantics.

136

137

1. New Programming Languages.

138

Back in the 1970s it was fashionable to design new programming languages.

139

Recently it hasn't been.

140

But I think server-based software will make new languages fashionable again.

141

With server-based software, you can use any language you want, so if someone does design a language that actually seems better than others that are available, there will be people who take a risk and use it.

142

2. Time-Sharing.

143

Richard Kelsey gave this as an idea whose time has come again in the last panel, and I completely agree with him.

144

My guess (and Microsoft's guess, it seems) is that much computing will move from the desktop onto remote servers.

145

In other words, time-sharing is back.

146

And I think there will need to be support for it at the language level.

147

For example, I know that Richard and Jonathan Rees have done a lot of work implementing process scheduling within Scheme 48.

148

3. Efficiency.

149

Recently it was starting to seem that computers were finally fast enough.

150

More and more we were starting to hear about byte code, which implies to me at least that we feel we have cycles to spare.

151

But I don't think we will, with server-based software.

152

Someone is going to have to pay for the servers that the software runs on, and the number of users they can support per machine will be the divisor of their capital cost.

153

So I think efficiency will matter, at least in computational bottlenecks.

154

It will be especially important to do i/o fast, because server-based applications do a lot of i/o.

155

It may turn out that byte code is not a win, in the end.

156

Sun and Microsoft seem to be facing off in a kind of a battle of the byte codes at the moment.

157

But they're doing it because byte code is a convenient place to insert themselves into the process, not because byte code is in itself a good idea.

158

It may turn out that this whole battleground gets bypassed.

159

That would be kind of amusing.

138–141

Designing new languages was fashionable in the 1970s and hasn't been lately, but server-based software will revive it. Since you can use any language, if someone designs one that seems better, people will take a risk on it.

143–147

Time-sharing is an idea whose time has come again. My guess, and Microsoft's, is that much computing will move from the desktop onto remote servers, and that will need support at the language level. Richard Kelsey and Jonathan Rees have done a lot of process-scheduling work within Scheme 48.

149–154

Lately it seemed computers were finally fast enough, and byte code implied we had cycles to spare. But with server-based software we won't: someone has to pay for the servers, and users per machine is the divisor of their capital cost. So efficiency will matter again, especially i/o.

155–159

Byte code may turn out not to be a win. Sun and Microsoft are in a battle of the byte codes, but only because it's a convenient place to insert themselves, not because it's a good idea. This whole battleground may just get bypassed. That would be kind of amusing.

136–159

Server-based software will make designing new languages fashionable again, bring back time-sharing, and make efficiency matter once more, while the byte-code battleground may simply get bypassed.

161

162

1. Clients.

163

This is just a guess, but my guess is that the winning model for most applications will be purely server-based.

164

Designing software that works on the assumption that everyone will have your client is like designing a society on the assumption that everyone will just be honest. It would certainly be convenient, but you have to assume it will never happen.

165

I think there will be a proliferation of devices that have some kind of Web access, and all you'll be able to assume about them is that they can support simple html and forms. Will you have a browser on your cell phone?

166

Will there be a phone in your palm pilot?

167

Will your blackberry get a bigger screen?

168

Will you be able to browse the Web on your gameboy?

169

Your watch?

170

I don't know.

171

And I don't have to know if I bet on everything just being on the server.

172

It's just so much more robust to have all the brains on the server [blocked].

173

2. Object-Oriented Programming.

174

I realize this is a controversial one, but I don't think object-oriented programming is such a big deal.

175

I think it is a fine model for certain kinds of applications that need that specific kind of data structure, like window systems, simulations, and cad programs. But I don't see why it ought to be the model for all programming.

176

I think part of the reason people in big companies like object-oriented programming is because it yields a lot of what looks like work.

177

Something that might naturally be represented as, say, a list of integers, can now be represented as a class with all kinds of scaffolding and hustle and bustle.

178

Another attraction of object-oriented programming is that methods give you some of the effect of first class functions.

179

But this is old news to Lisp programmers.

180

When you have actual first class functions, you can just use them in whatever way is appropriate to the task at hand, instead of forcing everything into a mold of classes and methods.

181

What this means for language design, I think, is that you shouldn't build object-oriented programming in too deeply.

182

Maybe the answer is to offer more general, underlying stuff, and let people design whatever object systems they want as libraries.

183

3. Design by Committee.

184

Having your language designed by a committee is a big pitfall, and not just for the reasons everyone knows about.

185

Everyone knows that committees tend to yield lumpy, inconsistent designs.

186

But I think a greater danger is that they won't take risks.

187

When one person is in charge he can take risks that a committee would never agree on.

188

Is it necessary to take risks to design a good language though?

189

Many people might suspect that language design is something where you should stick fairly close to the conventional wisdom.

190

I bet this isn't true.

191

In everything else people do, reward is proportionate to risk.

192

Why should language design be any different?

163–164

The winning model will be purely server-based. Designing software that assumes everyone has your client is like designing a society that assumes everyone is honest: convenient, but you have to assume it'll never happen.

165–172

There will be a proliferation of devices with Web access, and all you can assume is simple html and forms. Browser on your cell phone? The Web on your gameboy, your watch? I don't have to know, if I bet on everything just being on the server, with all the brains on the server [blocked].

174–177

I don't think object-oriented programming is such a big deal. It's fine for things that need that data structure, like window systems and simulations, but not the model for all programming. Part of why big companies like it is that it yields a lot of what looks like work: a list of integers becomes a class with all kinds of scaffolding and hustle and bustle.

178–182

Methods give some of the effect of first class functions, but that's old news to Lisp programmers, who use the real thing however suits the task. So don't build object-oriented programming in too deeply; offer general underlying stuff and let people build object systems as libraries.

184–187

Designing your language by committee is a big pitfall. Committees yield lumpy, inconsistent designs, but the greater danger is they won't take risks a single person in charge would.

188–192

Is it necessary to take risks to design a good language? Many suspect you should stick close to conventional wisdom. I bet that isn't true. In everything else, reward is proportionate to risk. Why should language design be any different?

161–192

The winning model will be purely server-based, object-oriented programming isn't such a big deal, and designing a language by committee is a pitfall because committees won't take the risks a good language needs.