How Lisp became a programming language for God

Original author: Sinclair Target
  • Transfer
When programmers discuss the advantages of these or other programming languages, they often argue about them in prose terms as tools in a set of various devices — one more suitable for system programming, the other for pasting other programs to solve the current problem. It should be so. Languages ​​have different strengths, and to declare that one language is better than other languages, without specifying concrete examples, means only to cause unproductive and sharp disputes.

However, there is one language that strangely commands universal respect: Lisp. Crusaders of keyboards, ready to attack anyone who dares to say that any language is better than others, agree that Lisp is on a different level. It goes beyond the utilitarian criteria that other languages ​​are judged because the average programmer never used Lisp to create anything practical, and probably never will, but the respect for Lisp is so deep that he is often credited with mythical properties. Everyone's favorite xkcd comics were depicted in this way Lisp at least twice: in one comic, a character achieves Lisp enlightenment, which helps him to know the fundamental structure of the Universe. In another, an old programmer in a lab coat hands over a stack of parentheses to his Padawan, explaining that this is “an elegant weapon for more civilized times”,Forces .

Another fine example is the Bob Kanefsky parody of the song “God Lives on Terra”. His parody was written in the mid-90s and is called the Eternal Flame. She describes how, apparently, God created the world with the help of Lisp. Here is the excerpt, and the full version can be found on the GNU Humor Collection website :
After all, God wrote on Lisp
when he filled the leaves with green.
Fractal flowers and recursive roots:
The most beautiful hack I've ever seen.
And when I study snowflakes,
And I don’t find two identical ones,
I know that God loves the language
With its own four-letter name.

I speak only for myself, but it seems to me that the cultural meme “Lisp is secret magic” is the strangest and most interesting phenomenon. Lisp was conceived in an ivory tower as a tool for researching artificial intelligence, so it will always be a little unfamiliar and mysterious for ordinary programmers. However, programmers are now telling each other to “try Lisp before you die,” as if it were some kind of psychedelic mind-expanding tool. They do this in spite of the fact that Lisp is the second oldest of the oldest programming languages ​​that are still used, second only to Fortran., and then, just for a year. Imagine that you would be entrusted with advertising a new programming language by the company or team that developed it. Wouldn't it be cool to convince everyone that your new language has divine powers? But how could this be achieved? How did a programming language become famous as a source of secret knowledge?

How did Lisp come to life like that?


Cover of the magazine Byte, August 1979

Theory A: axiomatic language


John McCarthy , the creator of Lisp, did not initially strive to ensure that Lisp was the elegant essence of computational principles. But, after one or two good ideas and a few improvements, Lisp turned into just that. Paul Graham - we will tell about him later - wrote that, having created Lisp, McCarthy “did the same for Euclid for programming for geometry”. Perhaps people are looking for deep meaning in Lisp, because McCarthy created it from such fundamental parts that it is hard to say whether he invented it or discovered it.

McCarthy began thinking about creating a language during the 1956 Dartmouth Summer Research Project on Artificial Intelligence. This seminar was a continuous multi-week academic conference, the very first in the field of AI. By the way, it was McCarthy, then being an associate professor of mathematics at Dartmoor, coined the term "artificial intelligence", offering to hold this meeting. The conference was attended by about ten people. Among them were Allen Newel and Herbert Simon, two researchers associated with the RAND Corporation and Carnegie Mellon University, who had just completed the development of the IPL language .

Newel and Simon tried to create a system capable of producing evidence in the logic of statements. They realized that it would be hard to do, while remaining at the level of their own computer instructions, so they decided to create a language - or, as they called it, “pseudo-code” —which will help them more naturally express the work of their “machine of theoretical logic”. Their language, IPL, “information processing language,” was more like a high-level dialect of assembler than a programming language in the modern sense. Newel and Simon, perhaps referring to Fortran, noted that "other pseudo-codes", then under development, were "busy" with the representation of the equations in a standard mathematical notation. Instead, their language focused on presenting statements in the form of lists of symbolic expressions. IPL programs used assembler macro sequences to process and evaluate expressions within one or more of these lists.

McCarthy thought it would be useful to have algebraic expressions in a language similar to Fortran. Therefore, he did not like the IPL. But he thought that symbolic lists were a good way to model tasks from the field of AI, especially those that included deduction. It was the germ of McCarthy’s desire to create an algebraic list processing language, a language that would resemble Fortran, but could also handle symbolic lists, like IPL.

Of course, today Lisp does not resemble Fortran. Over the next few years, McCarthy's ideas on the ideal language for processing lists developed. His ideas began to change in 1957, when he began writing procedures for a program in Fortran, playing chess. The long-lasting impact of Fortran convinced McCarthy that there were several unfortunate places in his design, the most important of which was the clumsy IF operator. McCarthy invented an alternative, the conditional expression “true,” returning the subexpression A, if the specified test was successful, and the subexpression B in another case, and performing only the subexpression that was returned. In the summer of 1958, when McCarthy worked on a program capable of differentiation, he understood that his conditional expression “true” made writing recursive functions simpler and more natural. The differentiation task also prompted McCarthy to write the maplist function, which takes another function as an argument, and applies it to all elements of the list. It was useful for differentiating the amounts of an arbitrary number of members.

Such things on Fortran could not be expressed, so in the fall of 1958 McCarthy asked several students the task of implementing Lisp. Since McCarthy was now an associate professor at MIT, all students studied at MIT. Translating ideas into a working code, McCarthy and the students made changes that simplified the language even more. The largest of these was the Lisp syntax. McCarthy first wanted the language used so-called. "M-expression" layer " syntactic sugar", which made Lisp's syntax look like Fortran. Although M-expressions can be translated into S-expressions - a simple list enclosed in brackets that Lisp is famous for - S-expressions were really a low-level representation intended for a computer. The only problem was that McCarthy denoted M-expressions using square brackets, and there were no square brackets on the IBM 026 punch used in MIT. Therefore, the Lisp team limited itself to S-expressions and used them to represent not only data lists, but also McCarthy and students made several simplifications, including switching to a prefix notation and a memory model, in which the language had only one type of real.

In 1960, McCarthy published the famous work on Lisp "Recursive functions of symbolic expressions and their machine computation" [Recursive Functions of Symbolic Expressions]. By that time, the language was reduced to such an extent that McCarthy realized that he had created an “elegant mathematical system,” and not just another programming language. He later wrote that many simplifications in Lisp turned it into “a way of describing calculated functions, much more accurate than Turing machines or general recursive definitions used in the theory of recursive functions”. In his work, he presented Lisp as a working programming language, and as a formalism for studying the behavior of recursive functions.

McCarthy explained Lisp to readers by building it out of a small set of rules. Later, Paul Graham followed McCarthy's footsteps, using a simpler reading language, in his essay " The Roots of Lisp"Graham can explain Lisp with just seven primitive operators, two different entries for functions, and six high-level functions defined through primitive operators. The ability to define Lisp using such a small sequence of simple rules certainly adds mystery to it. Graham called McCarthy’s work an attempt to “axiomatize computation.” I think this is a great way to reflect on the attractiveness of Lisp. Other languages ​​clearly contain artificial constructions described by such a dawn ervirovannymi words, while, typedef, or public static void, it seems that the description is limited to the most Lisp computation logic. This is a quality and original Lisp connection with such esoteric areas as "the theory of recursive functions", should explain the present prestige of the language.

Theory B: the car of the future


Two decades after its creation, Lisp has become, according to the famous " dictionary of computer scientists ", the "native language" of research in the field of AI. In the early stages, Lisp spread quickly, probably due to the fact that its systematic syntax made the task of implementing it on new machines relatively straightforward. Later, researchers continued to use it because of how well it coped with symbolic expressions, which was important in an era when most AI was symbolic. Lisp was used in such prolific AI projects as the natural language understanding program SHRDLU , the computer algebra system Macsyma , and the logical system ACL2 .

By the mid-1970s, AI researchers began to lack computer power. For example, the PDP-10, the beloved AI machine for working with AI, had 18-bit address space, which was increasingly lacking for Lisp AI programs. Many AI programs also had to be interactive, and creating a large interactive program that works well on a time-sharing system was a difficult task. The solution, which was first proposed by Peter Deutsch from MIT, was to develop a special computer for Lisp. Such machinesshould have given each user a dedicated processor optimized for Lisp. They also had to have a development environment written in Lisp for hardcore Lisp programmers. Lisp machines, designed at an awkward moment at the end of the era of mini-computers, but before the heyday of the microcomputer revolution, were high-performance personal computers for programmer elites.

For a while it seemed that Lisp machines would be the wave of the future. There were several companies that began to compete for the commercialization of this technology. The most successful of these was Symbolics, created by veterans of the MIT AI Lab. In the 1980s, Symbolics launched a line of 3600-series computers popular in AI and in industries that required high-power computing. In the 3600 line-up, there were computers with large screens, raster graphics, an interface that used a mouse, and powerful graphics and animation programs. These were impressive machines that allowed to write impressive programs. For example, Bob Cali, who worked in the field of robotics research, wrote me through Twitter that he was able to implement and visualize the algorithm for finding the path to the Symbolics 3650 in 1985. He told me that raster graphics and OOP (available on Lisp machines due to the expansion of Flavors) were new in the 1980s. Symbolics was at the forefront.



But as a result, Symbolics computers were insanely expensive. The Symbolics 3600 cost $ 110,000 in 1983. Most people could only wonder at the power of Lisp machines and the magic of the operators who wrote to Lisp from afar. But they were astonished. Byte magazine has described Lisp and Lisp machines several times between 1979 and the late 1980s. In the August 1979 issue of Lisp, the chief editors were delighted with the new machines being developed at MIT with “a mountain of memory” and an “advanced operating system”. He considered them so promising that the previous two years, in which the Apple II appeared, the Commodore PET and the TRS-80, seemed boring. Five years later, in 1985, the author in the magazine Byte described the process of writing Lisp programs for "the complex and extremely powerful Symbolics 3670," and encouraged readers to learn Lisp, stating that it was "language

I asked Paul McJohnns, who had done a lot to save Lisp at the Computer View Museum in Mountain View, about when people first started talking about Lisp as a gift of beings from a higher dimension. He said that the properties of the language itself certainly contributed to this, but also the close connection between Lisp and powerful AI applications in the 1960s and 1970s. When the Lisp machine became available in the 1980s, a few more people came to know Lisp outside of places such as MIT or Stanford, and the legend continued to grow. Today, Lisp machines and Symbolics few people remember, but they helped to maintain the aura of the mystery of Lisp until the 1980s.

Theory B: Programming Teaching


In 1985, professors from MIT, Harold Abelson and Gerald Sasman, as well as Sasman's wife, Julia, published a textbook on Structure and Interpretation of Computer Programs. In the textbook, readers were taught programming in Scheme, the Lisp dialect. It has been used at MIT for an introduction to programming for two decades. It seems to me that this is a tutorial, SICP, added Lisp mysticism. SICP took Lisp and showed how it can be used to illustrate the deep, almost philosophical concepts of the art of programming. These concepts were general enough to use any PL, but the SICP authors chose Lisp. As a result, Lisp's reputation was complemented by the notoriety of this strange and ingenious book that intrigued many generations of programmers (and became a very strange meme). Lisp has always been an "elegant formalism of McCarthy"; now it has also become a language that "teaches you hidden programming secrets").

It is worth telling a little about how strange this book is - since it seems to me that its oddity and the oddity of Lisp have merged into one today. Strangeness begins with the cover. It depicts a wizard or alchemist, approaching the table, and ready to start some kind of witchcraft. In one hand he has a caliper or compass, in the other - a globe with the inscriptions "eval" and "apply". The woman in front of him points to the table; on the background hangs in the air the Greek letter lambda, emitting light.



What is going on here? Why is the table the foot of an animal? Why is the woman pointing to the table? What is the significance of the ink? Do we need to understand that the wizard has revealed the secret knowledge of the universe, and that they consist of the eval / apply cycle and lambda calculus ? Apparently, it is. Only this image was supposed to add much to today's Lisp perception.

But the text of the book itself often turns out to be just as strange. SICP is not like most other books on computer science. The authors in the preface explain that the book is not just about programming in Lisp - it tells about "three foci, or phenomena: the human mind, a set of computer programs and a computer." Later they describe that they are convinced that programming should be viewed not as an informatics discipline, but as a new record of “procedural epistemology". Programs are a new way of structuring thoughts that are only sometimes introduced into a computer. The first chapter gives a brief tour of Lisp, but most of the book is about more abstract concepts. It discusses various programming paradigms, the nature of time and identity in OO systems, and in one place what synchronization problems may arise due to the fundamental limitations of message passing, which play the role of the speed of light in relativity. These are pretty abstruse things.

And do not say that the book is bad. She is wonderful. It discusses important concepts of programming at a higher level than in all the other books I have read, concepts that I had thought about for a long time, but could not describe. It is surprising that a textbook on introducing programming so quickly can go on to describing the fundamental shortcomings of OOP and the advantages of functional languages ​​that minimize a changing state. It's amazing how this turns into a discussion of how the flow paradigm is probably something like today's RxJS, can give you the best of both approaches. SICP highlights the very essence of developing high-level programs in a manner reminiscent of McParthy’s original Lisp work. The first thing you want to do after reading this book is to make your programmer friends read it; if they find it, see the cover, and do not read it, all they have to postpone is that some mysterious thing named eval / apply gives the wizards a special power over the tables with the feet of animals. I would still be impressed with their shoes.

But perhaps the most important contribution of the SICP was to raise the Lisp from the level of amusing curiosity to pedagogical necessity. Long before the SICP, people advised each other to study Lisp in order to improve their level as a programmer. The issue of Byte magazine from 1979 is evidence of this. The same editor, who admired new Lisp machines at MIT, explained that it is worth learning this language, since it "represents a different perspective on the tasks." However, in SICP Lisp was presented not just as a contrast to other languages. It was used as an introductory language, hinting that it is the best language for learning basic programming concepts. When today's programmers tell each other to try Lisp before they die, they probably do it because of SICP. After all, Brainfuck, too, probably offers a "different point of view on tasks."

Return Lisp


In the year of SICP's release, Bjarne Straustrup published the first edition of the book C ++ Programming Language , which brought OOP to the masses. A few years later, the market for Lisp machines collapsed, and the AI winter began . Over the next ten years, C ++ and then Java have become the languages ​​of the future, and Lisp has become stagnant.

Naturally, it is impossible to indicate when exactly people began to admire Lisp again. Perhaps this happened after Paul Graham, the co-founder of Y-Combinator and the creator of Hacker News, published several influential essays where he described Lisp as the best language for startups. In the essay " Leading the middle"Graham claimed that the Lisp macros made the language stronger than other languages. He said that using Lisp in his Viaweb startup helped him develop certain things faster than competitors could do. Some programmers were convinced. But most did not switch to Lisp.

Instead, more and more features of Lisp began to fall into all the favorite languages. In Python, list generation has appeared. In C #, Linq. In Ruby ... well, Ruby is Lisp. As Graham noted back in 2001, "the default language, embedded in many popular languages ​​that emerged later, gradually developed in the direction of Lisp." And while other languages ​​are gradually approaching Lisp, Lisp itself somehow maintains its special reputation as a mysterious language that few people understand, but everyone must learn. In 1980, the year of the Lisp 20th anniversary, McCarthy wrote that Lisp survived for so long, because it occupied "an exemplary local optimum of its own kind in the space of PL". But this underestimates the real influence of Lisp. He has been surviving for fifty years now because programmers have reluctantly recognized decade by decade that this is the best tool for their task. He survived even though that most programmers do not use it. Due to its origin and use in AI research, and possibly also the SICP heritage, Lisp continues to delight people. And until we can imagine God, who created the world with the help of some newer language, Lisp will not go anywhere.

Also popular now: