








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of programming languages and discusses specific languages like lisp and apl. It emphasizes the importance of user-defined types and overloaded operators in making programming more efficient and effective. The text also touches upon the idea of a master plan and its impact on the sense of identification and purpose for users.
Typology: Exams
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Guy L. Steele Jr. Sun Microsystems Lab oratories [email protected]
Octob er 22, 1998
Most of the time, I do not read my talks; I plan the main p oints and then sp eak o the top of my head. For this talk, I need to stick to a text, and for go o d cause. Please b ear with me. I think you know what a man is. A woman is more or less like a man, but not of the same sex. (This may seem like a strange thing for me to start with, but so on you will see why.) Next, I shall say that a person is a woman or a man (young or old). To keep things short, when I say \he" I mean \he or she," and when I say \his" I mean \his or her." A machine is a thing that can do a task with no help, or not much help, from a p erson. (As a rule, we can sp eak of two or more of a thing if we add an \s" or \z" sound to the end of a word that names it.)
hnouni ::= hnoun that names one thingi \s" j hnoun that names one thingi \es"
These are names of p ersons: Alan Turing, Alonzo Church, Charles Kay Ogden, Christo- pher Alexander, Eric Raymond, Fred Brooks, John Horton Conway, James Gosling, Bil l Joy, and Dick Gabriel. The word other means \not the same." The phrase other than means \not the same as." A number may b e nought, or may b e one more than a numb er. In this way we have a set of numb ers with no b ound.
hnumb eri ::= 0 j 1 + hnumb eri
There are other numb ers as well, but I shall not sp eak more of them yet. These numb ers|nought or one more than a numb er|can b e used to count things. We can add two numb ers if we count up from the rst numb er while we count down from the numb er that is not the rst till it come to nought; then the rst count is the sum.
4 + 2 = 5 + 1 = 6 + 0 = 6
We shall take the word many to mean \more than two in numb er." Think of a machine that can keep track of two numb ers, and count each one up or down, and test if a numb er b e nought and by such a test cho ose to do this or that. The
list of things that it can do and of choices that it can make must b e of a known size that is some numb er.
0
47
Q 0 up A Q 1 Q 1 down B Q 0 Q 2 Q 2 up A Q 3 Q 3 up B Q 4 Q 4 down A Q 4 Q 4
STATE
Here you can see the two numb ers and a list. Each row in the list has a state name; the word \up" or \down"; and which numb er to count up or count down. For \up," we have the name of the next state to go to (and the machine counts the numb er up by one); for \down," the machine rst tests the numb er, and so we have the name of the new state to go to if the numb er b e nought and the name of the new state to go to if the numb er b e other than nought (in which case the machine counts the numb er down by one). A computer is a machine that can do at least what that machine can|and we have go o d cause to think that if a computer task can b e done at all, then the two-numb er machine can do it, to o, if you put numb ers in and read them out in the right way. In some sense, all computers are the same; we know this thanks to the work of such p ersons as Alan Turing and Alonzo Church. A vocabulary is a set of words. A language is a vo cabulary and rules for what a string of words might mean to a p erson or a machine that hears them. (To de ne a word is to tell what it means. When you de ne a word, you add it to your vo cabulary and to the vo cabulary of each p erson who hears you. Then you can use the word.) To program is to make up a list of things to do and choices to make, to b e done by a computer. Such a list is called a program. (A noun can b e made from a verb to mean that which is done as meant by that verb; to make such a noun, we add \ing" to the verb stem. Thus we can sp eak of \programming.")
hnouni ::= hverb stemi \ing"
and in each new program we must de ne it once more. A go o d example of this is max, which yields the more large of two numb ers. It is a primitive thought to me, but few programming languages have it as a primitive; I have to de ne it. This is the sort of thing that makes a computer lo ok like a p erson who is but four years old. Next to English, all computer programming languages are small; as we write co de, we must stop now and then to de ne some new term that we will need to use in more than one place. Some p ersons nd that their programs have a few large chunks of co de that do the \real work" plus a large pile of small bits of co de that de ne new words, so to sp eak, to b e used as if they were primitives. I hop e that this talk brings home to you|in a way you can feel in your heart, not just think in your head|what it is like to have to program in that way. This should show you, true to life, what it is like to use a small language. Each time I have tried this sort of thing, I have found that I can not say much at all till I take the time to de ne at least a few new terms. In other words, if you want to get far at all with a small language, you must rst add to the small language to make a language that is more large. (In some cases we will nd it more smo oth to add the syllable \er" to the end of a word than to use the word \more" in front of it; in this way we might say \smo other" in place of \more smo oth." Let me add that better means \more go o d.")
hword that can change what a noun meansi ::= hword that can change what a noun meansi \er" In truth, the words of one syllable form quite a rich vo cabulary, with which you can say many things. You may note that this vo cabulary is much larger than that of the language called Basic English, de ned by Charles Kay Ogden in the year one-nine-three-nought. I chose not to use Basic English for this talk, the cause b eing that Basic English has many words of two or more syllables, some of them quite long, handed down to us from the dim past of Rome. While Basic English has fewer words, it do es not give the feel, to one who sp eaks full English, of b eing a small language. (By the way, from now on I shall use the word because to mean \the cause b eing that.") If we lo ok at English and then at programming languages, we see that all our program- ming languages seem small. And yet we can say, to o, in some cases, that one programming language is smaller than some other programming language. A design is a plan for how to build a thing. To design is to build a thing in one's mind but not yet in the real world|or, b etter yet, to plan how the real thing can b e built. The main thing that I want to ask in this talk is: If I want to help other p ersons to write all sorts of programs, should I design a small programming language or a large one? I stand on this claim: I should not design a small language, and I should not design a large one. I need to design a language that can grow. I need to plan ways in which it might grow|but I need, to o, to leave some choices so that other p ersons can make those choices at a later time. This is not a new thought. We have known for some time that huge programs can not b e co ded from scratch all at once. There has to b e a plan for growth. What we must stop to think on now is the fact that languages have now reached that large size where they can not b e designed all at once, much less built all at once. (Let me pause to de ne some names for numb ers. Twenty is twice ten. Thirty is thrice ten. Forty is twice twenty. A hundred is ten times ten. A mil lion is a hundred times a hundred times a hundred. Sixteen is twice eight. Seven is one plus six. Fifty is one more than seven squared. One more thing: ago means \in the past, counting back from now.")
In the past, it made sense to design a whole language, once for all. Fortran was a small language forty years ago, designed for tasks with numb ers, and it served well. PL/I was thought a big language thirty years ago, but now we would think of it as small. Pascal was designed as a small, whole language with no plan to add to it at a later time. That was ve-and-twenty years ago. What came to pass? Fortran has grown and grown. Many new words and new rules have b een added. The new design is not bad; the parts t well, one with the other. But to many programmers who have used Fortran for a long time, the Fortran of here and now is not at all the same as the language they rst came to know and love. It lo oks strange. PL/I has not grown much. It is, for the most part, just as it was when it rst came out. It may b e that this is just from lack of use. The ip side is that the lack of use may have two causes. Numb er one: PL/I was not designed to grow|it was designed to b e all things to all who program right from the start. Numb er two: for its time, it started out large. No one knew all of PL/I; some said that no one could know all of PL/I. Pascal grew just a tad and was used to build many large programs. One main fault of the rst design was that strings were hard to use b ecause they were all of xed size. Pascal would have b een of no use for the building of large programs for use in the real world if this had not b een changed. But Wirth had not planned for the language to change in such ways, and in fact few changes were made. At times we think of C as a small language designed from whole cloth. But it grew out of a smaller language called B, and has since grown to b e a larger language called C plus plus. A language as large as C plus plus could not have spread so wide if it had b een foisted on the world all at once. It would have b een to o hard to p ort. (One more rule for making words: if we add the syllable \er" to a verb stem, we make a noun that names the p erson or thing that do es what the verb says to do. For example, a buyer is one who buys. A user is one who do es use.)
hnouni ::= hverb stemi \er"
As you may by now have guessed, I am of like mind with my go o d friend Dick Gabriel, who wrote the well known screed \Worse Is Better."
http://www.ai.mit.edu/docs/articles/good-news/good-news.html http://www.naggum.no/worse-is-better.html
(The real name was \Lisp: Go o d News, Bad News, How to Win Big," which is all words of just one syllable|which might seem like go o d luck for me, but the truth is that Dick Gabriel knew how to cho ose words with punch. Yet what rst comes to mind for most p ersons is the part headed \Worse Is Better" and so that is how they cite it.) The gist of it is that the b est way to get a language used by many p ersons is not to design and build \The Right Thing," b ecause that will take to o long. In a race, a small language with warts will b eat a well designed language b ecause users will not wait for the right thing; they will use the language that is quick and cheap, and put up with the warts. Once a small language lls a niche, it is hard to take its place. Well, then, could not \The Right Thing" b e a small language, not hard to p ort but with no warts? I guess it could b e done, but I, for one, am not that smart (or have not had that much luck). But in fact I think it can not b e done. Five-and-twenty years ago, when users did
I now think that I, as a language designer helping out with the Java programming language, need to ask not \Should the Java programming language grow?" but \How should the Java programming language grow?" There is more than one kind of growth and more than one way to do it. But, as we shall see, if the goal is to b e quick and yet to do go o d work, one mo de may b e b etter by far than all other mo des. There are two kinds of growth in a language. One can change the vo cabulary, or one can change the rules that say what a string of words means. A library is a vo cabulary designed to b e added to a programming language to make the vo cabulary of the programming language larger. Libraries means more than one library. A true library do es not change the rules of meaning for the language; it just adds new words. (You can see from this that, in my view, the co de that lets you do a \long jump" in C is not a true library.) Of course, there must b e a way for a user to make libraries. But the key p oint is that the new words de ned by a library should lo ok just like primitives of the language. Some languages are like this and some are not. Those that are not are harder to grow with the help of users. It may b e go o d as well to have a way to add to the rules of meaning for a language. Some ways to do this work b etter than other ways. But the language should let work done by a user lo ok just like what was designed at the start. I would like to grow the Java programming language in such a way that users can do more of this. In the same way, there are two ways to do the growing. One way is for one p erson (or a small group) to b e in charge and to take in, test, judge, and add the work done by other p ersons. The other way is to just put all the source co de out there, once things start to work, and let each p erson do as he wills. To have a p erson in charge can slow things down, but to have no one in charge makes it harder to add up the work of many p ersons. The way that is faster and b etter than all other ways do es b oth. Put the source co de out there and let all p ersons play with it. Have a p erson in charge who is a quick judge of go o d work and who will take it in and shove it back out fast. You don't have to use what he ships, and you don't have to give back your work, but he gives all p ersons a fast way to spread new co de to those who want it. The b est example of this way to do things is Linux, which is an operating system, which is a program that keeps track of other programs in a computer and gives each its due in space and time. You ought to read what Eric Raymond had to say of how Linux came to b e. I shall tell you a bit of it once I de ne two more words for you. A cathedral is a huge church. It may b e made of stone; it may ll you with awe; but the key thought, in the mind of Eric Raymond, is that there is but one design, one grand plan, which may take a long time|many years|to make real. As the years pass, few changes are made to the plan. Many, many p ersons are needed to build it, but there is just one designer. A bazaar is a place with many small shops or stalls, where you can buy things from many p ersons who are there to sell their wares. The key thought here is that each one sells what he wants to sell and each one buys what he wants to buy. There is no one plan. Each seller or buyer may change his mind at whim. Eric Raymond wrote a short work called \The Cathedral and the Bazaar" in which he lo oks at how programs are built or have b een built in the past. (You can nd it on his web site.)
http://www.tuxedo.org/~esr/writings/cathedral-bazaar
He talks of how he built a mail fetching program with the help of more than two hundred users. He quotes Fred Bro oks as saying, \More users nd more bugs," and backs him up with tales from this example of building a program in the bazaar style. As for the role of the programmer-in-charge, Eric Raymond says that it is ne to come up with go o d thoughts, but much b etter to know them when you see them in the work of other p ersons. You can get a lot more done that way. Linux rose to its heights of fame and wide use in much the same way, though on a much larger scale. (To take this thought to the far end of the line: it may b e that one could write an op erating system by putting a million ap es to work at a million typing-machines, then just sp otting the bits of go o d work that come out by chance and pasting them up to make a whole. But that might take a long time, I guess. To o bad!) But the key p oint of the bazaar is not that you can get many p ersons to work with you at a task, for cathedral-builders had a great deal of help, to o. Nor is the key p oint that you get help with the designing as well as with the building, though that in fact is a big win. No, the key p oint is that in the bazaar style of building a program or designing a language or what you will, the plan can change in real time to meet the needs of those who work on it and use it. This tends to make users stay with it as time go es by; they will take joy in working hard and helping out if they know that their wants and needs have some weight and their hard work can change the plan for the b etter. Which brings me to the high p oint of my talk. It seems, in the last few years, at least, that if one is asked to sp eak at this meeting, one must quote Christopher Alexander. I know a bit of his work, though not a lot, and I must say thanks to Dick Gabriel for p ointing out to me a quote that has a lot to do with the main p oint of this talk. I am sad to say that I do not know what this quote means, b ecause Christopher Alexander tends to use many words of more than one syllable and he do es not de ne them rst. But I have learned to say these words by rote and it may b e that you out there can glean some thoughts of use to you. Christopher Alexander says:
Master plans have two additional unhealthy characteristics. To b egin with, the existence of a master plan alienates the users : : : After all, the very exis- tence of a master plan means, by de nition, that the memb ers of the commu- nity can have little impact on the future shap e of their community, b ecause most of the imp ortant decisions have already b een made. In a sense, under a master plan p eople are living with a frozen future, able to a ect only relatively trivial details. When p eople lose the sense of resp onsibility for the environment they live in, and realize that they are merely cogs in someone else's machine, how can they feel any sense of identi cation with the community, or any sense of purp ose there? (from The Oregon Experiment)
I think this means, in part, that it is go o d to give your users a chance to buy in and to pitch in. It is go o d for them and it is go o d for you. (In p oint of fact, a numb er of cathedrals were built in the bazaar mo de.) Do es this mean, then, that it is of no use to design? Not at all. But in stead of designing a thing, you need to design a way of doing. And this way of doing must make some choices now but leave other choices to a later time.
may b e overloaded. I would like to change that. I have said in the past, and will say now, that I think it would b e a go o d thing for the Java programming language to add generic typ es and to let the user de ne overloaded op erators. Just as a user can co de metho ds that can b e used in just the same way as metho ds that are built in, the user ought to have a way to de ne op erators for user- de ned classes that can b e used in just the same way as op erators that are built in. What is more, I would add a kind of class that is of light weight, one whose ob jects can b e cloned at will with no harm and so could b e kept on a stack for sp eed and not just in the heap. Classes of this kind would b e well-suited for use as user-de ned numb er typ es but would have other uses, to o. You can nd a plan for all this on a web page by James Gosling.
http://www.javasoft.com/people/jag/FP.html
(There are a few other things we could add as well, such as tail calls and ways to read and write those machine ags for numb ers whose p oints oat. But these are small language tweaks next to generic typ es and overloaded op erators.) If we grow the language in these few ways, then we will not need to grow it in a hundred other ways; the users can take on the rest of the task. To see why, think on these examples. A complex number is a pair of numb ers. There are rules for how to nd the sum of two complex numb ers, or a complex numb er times a complex numb er:
(a; b) + (c; d) = (a + c; b + d)
(a; b) (c; d) = (a c b d; a d + b c)
Some programmers like to use them a lot; other programmers do not use them at all. So should we make \complex numb er" a typ e in the Java programming language? Some say yes, of course; other p ersons say no. A rational number is a pair of numb ers. There are rules (not the same as the rules for complex numb ers, of course) for how to nd the sum of two rational numb ers, or a rational numb er times a rational numb er:
(a; b) + (c; d) = (a d + b c; b d)
(a; b) (c; d) = (a c; b d)
A few programmers like to use them a lot; most do not use them at all. So should we make \rational numb er" a typ e in the Java programming language? An interval is a pair of numb ers. There are rules (not the same as the rules for complex numb ers or rational numb ers, of course) for how to nd the sum of two intervals, or an interval times an interval:
(a; b) + (c; d) = (a + c; b + d)
(a; b) (c; d) = (min(a c; a d; b c; b d); max(a c; a d; b c; b d))
A few programmers like to use them a lot and wish all the other programmers who use numb ers would use them, to o; but most do not use them at all. So should we make \interval" a typ e in the Java programming language?
John Horton Conway once de ned a game to b e a pair of sets of games (see his b o ok On Numbers and Games), then p ointed out that some games may b e thought of as numb ers that say how many moves it will take to win the game. There are rules for how to nd the sum of two games, and so on:
( A ; B ) + ( C ; D) =
f a + ( C ; D) j a 2 A g [ f ( A ; B ) + c j c 2 C g; f b + ( C ; D) j b 2 B g [ f ( A ; B ) + d j d 2 D g