# [SICP 3] Why SICP? Why Scheme? Language-Oriented Programming.

TL;DR: After discussing the past and future of Scheme, SICP project, in this post I discuss about the education philosophy of SICP to introductory computer science, for what kind of specific problems this class is good for and why Scheme is a good fit for that, and little bit about "language-oriented programming".

# Language-Oriented Programming

6.001, emphasizes controlling the complexity of software systems through general techniques common to all engineering design: building abstractions to hide details and to separate specification from implementation, establishing conventional interfaces to allow the creation of standard modules, and shifting modes of linguistic description.

There is a central concern with the technology of implementing languages and linguistic support for programming paradigms. Students are encouraged to regard themselves as language designers and implementors rather than only language users. [1]

My inclination in computer science is shifting from “algorithms and data structures” towards the notion of programming itself. I guess this was expected. In most business context algorithms are required for getting the job, but actual work projects are done by gluing libraries and services to implement the “business logic”. On the other hand, academia has developed algorithms in so much depth which are available in terms of public libraries that it became a hard to contribute to the area. These days I started to see writing programs to deliver services/products as the essence of the craft.

My initial interest about SICP was initiated by just curiosity and a trust in that works that has earned classic status. A highly praised resource could be a great source of help with my goal of filling my education gap in computer science.

Now that I’m two chapters into the book, got some exposure to the Scheme ecosystem and slowly absorbing the philosophy behind the project I developed clearer goals about this study: “designing my own programming languages”. My work projects involve coding in multiple programming languages simultaneously and involve meta-programming techniques such as reflections and code generation. For example, my biggest problem at the moment is the lack of composition in type constants of shape data types in Hack language.

This made me realize that there is a “space” of programming languages out there. Each language is a point in that space. They can be clustered and grouped according to their features, constraints, syntax (dynamic vs. static typing, compiled vs. interpreted) etc. And that space deserves to be explored!

This exploration might help to know why the language one uses creates frictions at certain tasks and makes the life much easier for some other tasks without the user even noticing it. Another reason is to develop Domain Specific Languages (DSL) for specific tasks. From a certain perspective one can even claim that Go programming language is a DSL invented for developing highly concurrent and distributed systems to be written by inexperienced developers. [2]

Maybe one day I’ll invent a language

• for controlling the UI of a creative software and help artists in creating digital arts,
• or for teaching some behaviors to the units of an RTS games so that players can be a general and give their armies/workers higher-level commands as opposed to jumping their camera around and giving move/attack/build commands to each building/unit individually like crazy with 300 APM,
• or for composing musical scores without dealing with the distracting details of a general programming language…

Once one learns the magic of new language design the options are limitless! Reference [3] has some other ideas to I’d like to explore later. And if want to invest into the topic further [8] will give proper introduction and give more ideas.

One of the youngest Scheme dialects that is very easy to install on any platform, Racket, is promoted as “… a general-purpose programming language as well as the world’s first ecosystem for language-oriented programming” [5] I was surprised about this “programming orientation” and found it a bit extreme the first time I heard the term. But I’m warming up about this approach the more I gain experience in writing programs to satisfy requirements.

“Language-oriented programming is really an interface-design technique. It’s unbeatable for tasks that demand minimum notation while preserving maximum precision.” [6] Where minimum notation means that nothing extra that can lead to errors or reduction of focus. Maximum precision means that notation can be strongly tied to meaning. And Scheme with its homoiconicity (data and code having the same representation) simplifies writing programs that evaluate and process Scheme code, which makes it ideal for DSL design and LoP.

# Scheme for Education and Meta-Programming

Scheme has never been widely used in industry, but it's the perfect language for an introduction to CS. … it has a very simple, uniform notation for everything. Other languages have one notation for variable assignment, another notation for conditional execution, two or three more for looping, and yet another for function calls. Courses that teach those languages spend at least half their time just on learning the notation. … we spend the first hour on notation and … for the rest of the semester we're learning ideas, not syntax. [4]

AFAIU the authors’ goal was to provide a minimal language using which one can construct most essential aspects of programming. I believe that this lack of language structure in Scheme forces the students and programmers into questioning and analyzing the ones that are provided as built-in features in other languages. One can gain insights about why and how they were invented.

This is also familiar to my physics, math education background where most of the classes are about re-proving and re-deriving historical theorems. Watching the professor doing the derivation on the blackboard and repeat it yourself later. It’s a pleasure to implement these lower-level abstractions!

Their approach was in conflict with the industry job requirements where companies expect the applicants to have some level of expertise in a specific programming language, a.k.a: “Jr Java Developer Needed”.

It was very brave of Abelson and Sussman to teach their introductory course in the best possible language for teaching, paying no attention to complaints that all the jobs were in some other language. [4]

(I heard that METU and Koc Universities in Turkey also taught Scheme in Computer Science departments. But not SICP specifically.)

Peter Norvig has used LISP in first editions of Artificial Intelligence: A Modern Approach which was the de facto language of AI studies. His acronym for LISP is “LISP Is Syntactically Pure” and says:

“Beautiful part [of LISP] is its simplicity. In half a page you can define the whole language. … You can hold everything in your head. Other people say that’s too simple: ‘Here are all these things I want to do. My Java has 200 different syntax rules. Don’t I need all those?’

LISP’s answer was ‘No we are only going to give you 8 or so, but we are going to allow you define your own. That was a very powerful idea.’

I can start with my problem and data and then I can build the language I want for that problem and data and then I can make LISP define that language. You are sort of mixing levels, saying ‘I’m simultaneously programmer in a language and a language designer’. That allows a better match between your problem and your eventual code. [9]

However, compared to its power LISP is not widely adopted. Norvig believes that this is mostly due to the fact that LISP fits more for single programmer or small team environments where the language designer has a high responsibility. If they make good choices it’s great. Otherwise it hurts the team and project. “The industry grew beyond that.” [9]

Also parentheses… We had the AI textbook that uses LISP which was the common language for AI studies. Students complained “I don’t understand how this pseudo-code corresponds to this LISP code. And there was a one-to-one corresponds between symbols. Only addition was parentheses. “For some people certain number of left parentheses shuts their brain” [9]

Later he switches to Java but found it very verbose and hard to get one-to-one correspondence between algorithmic ideas expressed in pseudo-code and actual code. Later he discovered that Python was very similar to his pseudo code and chose it for his book. (He jokes about channeling his pseudo-code to Guido.) [9]. (And if you want to close the loop, in [10] Norvig writes a Lisp interpreter in Python. Could be a fun exercise to go the other way around.)

I also recommend to look at [7] for details on the essence of Lisp/Scheme. Some people hear about Lisp by the praises of notable programmers such as Paul Graham. The author finds Graham’s advertisement ambiguous and unclear and provides specific examples for what makes Lisp so expressive.

# Departing Quote

Back in 1980 (a long time ago!) I was walking around an exhibit of primitive personal computers at a trade show. I passed a station where a small girl (perhaps 9 years old) was typing furiously at a computer. While I watched, she reached over to a man standing nearby and pulled on his sleeve and said: “Daddy! Daddy! This computer is very smart. Its BASIC knows about recursive definitions!” I am sure that her father had no idea what she was talking about. But notice: the idea of a recursive definition was only a mathematician’s dream in the 1930s. It was advanced computer science in the 1950s and 1960s. By 1980 a little girl had a deep enough operational understanding of the idea to construct an effective test and to appreciate its significance. [11]

Let’s continue uplifting the cumulative intelligence of humanity by bringing more advanced concepts to everyday life!

# References

published at: 2020-08-23 20:14 edited at: 2020-08-23 20:24 UTC-5
tags: