Twenty thousand lines of code that will shock the world?
Alan Kay, the author of SmallTalk, is working on an experimental STEPS system - an environment that can replace the operating system and application programs, while the amount of code in this environment should not exceed 20,000 (twenty thousand!) Lines of code. Perhaps many have heard of this . This is one of the attempts to realize the dreams of any programmer: to write everything anew and beautifully. But is it possible?
If the famous 640K is divided into 20 thousand lines of code, then we get 32 bytes per line - this is very similar to the truth. It seems that Alan Kay keeps in mind this particular landmark, he is simply embarrassed to say out loud: "640K is enough for everyone."
Bill Gates guessed about this even 3 decades ago. He spoiled his money later, and at first he was the right kid: his BASIC occupied only 4K. Over time, he guessed to adapt Moore's law to the size of software and the size of his income, and he was not up to brevity.
In his youth, Bill's parents even took him to a psychiatrist, seeing the obsession with their offspring by programming. But over time, Bill stopped programming because he became the boss. “I used to love summer. But when he grew up, he realized that summer can be all year round, if only there was money. Now I love money. ”
It would be naive to think that bloated code is written only in Redmond. Even Linus laments, looking at his creation: "The core is swollen and huge." With each new release, the Linux kernel loses about 2% of its performance. And this is inevitable, says the mighty Finn .
Let's think, can I reduce the amount of software, and significantly? Take, for example, any text editor. To implement the claimed functionality, the author uses, for example, a certain search algorithm. But the code of the browser installed on the computer also has a search, and possibly with the same algorithm. It is also in the office suite, and in games, and in the OS, on top of which all this works. It would be logical to implement this search once, and then only use it. An in-depth analysis reveals a ton of repetitive things.
A competent, jewelry decomposition can work wonders, the main thing is to see repeating fragments, highlight them in separate abstractions and then simplify. Alan Kay does this: code that implements the TCP / IP protocol takes 160 lines. He is not alone so smart. Hovik Melikyan gives an example when a program of 80,000 lines of C ++ code and 55,000 lines of VB code was replaced with 10 lines in a shell script.
But is it possible to replace everything with twenty thousand lines of code? You can, but only if you abandon many standards. For example, web pages, from the point of view of STEPS authors, need to be replaced with documents using hyperlinks. Those. “Wrong bees and wrong honey” (http, html, css, etc.) are replaced with the right ones. And so in almost everything.
And what will this code be? Well, if he were not " interference in the telegraph line ." Robert Sebesta writes about such a code: "Daniel McCracken once noted that it took him four hours to read and analyze a four-line program written in APL."
This system has high-level languages OMeta and Nile, the syntax of which looks like C and Python, respectively. Programs on them are ultimately translated into programs in the low-level language Nothing. Here is an example on OMeta: calculator syntax:
In appearance - nothing magical, easy to read and understand.
To help Alan Kay’s ideas for world domination, we have to accustom ourselves to asceticism. Take, for example, a text editor. It’s the 21st century, but it shouldn’t have a spellcheck. Why? Yes, because she does not fit into these 20 thousand. Natural languages are complex. If a hundred lines of code are suddenly enough by some miracle to analyze text in a language, then we must take into account that the number of languages, in fact, is measured in thousands. But even if the number of languages is equated to the number of states, then these one hundred lines must be multiplied by another two hundred. It turns out those same 20 thousand ...
What about drivers? If the same 100 lines are enough for one type of device, then the types of devices are much more than the number of languages and states. If device manufacturers decide to help Kay and store the drivers in the devices themselves, then the “bloated software” will simply change its storage location.
Even if we assume that 20% of the code will cover 80% of the needs of users, it turns out that each 20% of unmet needs will be different. Some will need Photoshop, some will need AutoCAD, and some will need Deep Fritz. And so in many ways.
1) Trillions of dollars have been invested in software development around the world, most of which are not at all companies with which STEPS potentially competes. There are not even compilers of the most common languages for it, so there is not even a hint of the possibility of transferring what has been gained so far.
2) There is no need for such a short code. For the sake of saving memory? Memory costs a penny, its volume even on the simplest devices exceeds the very 640K. Maybe programs will run faster? No, all programs in this system are first translated into programs in the low-level language Nothing, and only then are executed. According to Kay himself, his code is about 30% slower than the traditional one.
These are the most obvious reasons. So the development of Alan Kay and his team will not be able to supplant modern OS, browsers, office applications.
1) Then the largest taxpayers such as Microsoft, Apple, Google, Adobe and others convincingly prove to housewives and governments why Kay’s approaches are wrong. And in general, they violate a lot of patents. Under STEPS there are no familiar applications. Data on computers is not protected, security is not ensured.
2) Even the great and terrible Linus will oppose the 20 thousand lines of code that will shock the world! For what should he do? Dragging sofas ?
Even secretly sympathetic there are reasons to resist such a prospect.
3) Virus writers will find that the STEPS system is extremely friendly to them. And there, anti-virus companies will catch up. Google will popularly explain that storing data on a computer is no longer comme il faut: let the data be stored in the cloud, and the "good corporation" will write for us its 20 thousand lines of code.
This is not all ...
She will remain the blue dream of the poet. The sleep of a programmer exhausted by the routine work. A reminder that in this world there are eternal values: brevity, clarity and beauty of the code. Propaganda of the power of thought. Role Model. And, of course, a testing ground for experiments.
640K again
If the famous 640K is divided into 20 thousand lines of code, then we get 32 bytes per line - this is very similar to the truth. It seems that Alan Kay keeps in mind this particular landmark, he is simply embarrassed to say out loud: "640K is enough for everyone."
Bill Gates guessed about this even 3 decades ago. He spoiled his money later, and at first he was the right kid: his BASIC occupied only 4K. Over time, he guessed to adapt Moore's law to the size of software and the size of his income, and he was not up to brevity.
In his youth, Bill's parents even took him to a psychiatrist, seeing the obsession with their offspring by programming. But over time, Bill stopped programming because he became the boss. “I used to love summer. But when he grew up, he realized that summer can be all year round, if only there was money. Now I love money. ”
It would be naive to think that bloated code is written only in Redmond. Even Linus laments, looking at his creation: "The core is swollen and huge." With each new release, the Linux kernel loses about 2% of its performance. And this is inevitable, says the mighty Finn .
Let's think, can I reduce the amount of software, and significantly? Take, for example, any text editor. To implement the claimed functionality, the author uses, for example, a certain search algorithm. But the code of the browser installed on the computer also has a search, and possibly with the same algorithm. It is also in the office suite, and in games, and in the OS, on top of which all this works. It would be logical to implement this search once, and then only use it. An in-depth analysis reveals a ton of repetitive things.
A competent, jewelry decomposition can work wonders, the main thing is to see repeating fragments, highlight them in separate abstractions and then simplify. Alan Kay does this: code that implements the TCP / IP protocol takes 160 lines. He is not alone so smart. Hovik Melikyan gives an example when a program of 80,000 lines of C ++ code and 55,000 lines of VB code was replaced with 10 lines in a shell script.
But is it possible to replace everything with twenty thousand lines of code? You can, but only if you abandon many standards. For example, web pages, from the point of view of STEPS authors, need to be replaced with documents using hyperlinks. Those. “Wrong bees and wrong honey” (http, html, css, etc.) are replaced with the right ones. And so in almost everything.
What kind of magic code is there?
And what will this code be? Well, if he were not " interference in the telegraph line ." Robert Sebesta writes about such a code: "Daniel McCracken once noted that it took him four hours to read and analyze a four-line program written in APL."
This system has high-level languages OMeta and Nile, the syntax of which looks like C and Python, respectively. Programs on them are ultimately translated into programs in the low-level language Nothing. Here is an example on OMeta: calculator syntax:
In appearance - nothing magical, easy to read and understand.
Why is this impossible even theoretically.
To help Alan Kay’s ideas for world domination, we have to accustom ourselves to asceticism. Take, for example, a text editor. It’s the 21st century, but it shouldn’t have a spellcheck. Why? Yes, because she does not fit into these 20 thousand. Natural languages are complex. If a hundred lines of code are suddenly enough by some miracle to analyze text in a language, then we must take into account that the number of languages, in fact, is measured in thousands. But even if the number of languages is equated to the number of states, then these one hundred lines must be multiplied by another two hundred. It turns out those same 20 thousand ...
What about drivers? If the same 100 lines are enough for one type of device, then the types of devices are much more than the number of languages and states. If device manufacturers decide to help Kay and store the drivers in the devices themselves, then the “bloated software” will simply change its storage location.
Even if we assume that 20% of the code will cover 80% of the needs of users, it turns out that each 20% of unmet needs will be different. Some will need Photoshop, some will need AutoCAD, and some will need Deep Fritz. And so in many ways.
Reasons why STEPS will not “take off”.
1) Trillions of dollars have been invested in software development around the world, most of which are not at all companies with which STEPS potentially competes. There are not even compilers of the most common languages for it, so there is not even a hint of the possibility of transferring what has been gained so far.
2) There is no need for such a short code. For the sake of saving memory? Memory costs a penny, its volume even on the simplest devices exceeds the very 640K. Maybe programs will run faster? No, all programs in this system are first translated into programs in the low-level language Nothing, and only then are executed. According to Kay himself, his code is about 30% slower than the traditional one.
These are the most obvious reasons. So the development of Alan Kay and his team will not be able to supplant modern OS, browsers, office applications.
What if STEPS suddenly becomes popular?
1) Then the largest taxpayers such as Microsoft, Apple, Google, Adobe and others convincingly prove to housewives and governments why Kay’s approaches are wrong. And in general, they violate a lot of patents. Under STEPS there are no familiar applications. Data on computers is not protected, security is not ensured.
2) Even the great and terrible Linus will oppose the 20 thousand lines of code that will shock the world! For what should he do? Dragging sofas ?
Even secretly sympathetic there are reasons to resist such a prospect.
3) Virus writers will find that the STEPS system is extremely friendly to them. And there, anti-virus companies will catch up. Google will popularly explain that storing data on a computer is no longer comme il faut: let the data be stored in the cloud, and the "good corporation" will write for us its 20 thousand lines of code.
This is not all ...
What will STEPS become then?
She will remain the blue dream of the poet. The sleep of a programmer exhausted by the routine work. A reminder that in this world there are eternal values: brevity, clarity and beauty of the code. Propaganda of the power of thought. Role Model. And, of course, a testing ground for experiments.