Structure and Interpretation of Computer Programs

date Mar 20, 2014
authors Gerald Jay Sussman, Hal Abelson
reading time 7 mins
engineering

The actual book on Structure and Interpretation of Computer Programs SICP is available freely online. It is used as a computer science text for introductory courses at MIT.

I decided to give it a read to get a better understanding of concepts like assignments, data, abstraction, etc that I was already using in my daily work in programming. But reading a thorough text such as this book especially after doing it in practice, somehow forges a better understanding.

There were many code examples of implementation in the functional programming language [Scheme](http://en.wikipedia.org/wiki/Scheme_(programming_language). Although I barely schemed through these examples, reading through the conceptual bits itself were insightful and I was able to make some realizations on why computing is done in a certain way.

By reading this book, I believe it would help anyone get a deeper understanding on the implementations of computing in today’s world. Have a go at this book :) ___

##Selected quotes

computer language for…

a computer language is not just a way of getting a computer to perform operations but rather that it is a novel formal medium for expressing ideas about methodology. Thus, programs must be written for people to read, and only incidentally for machines to execute.

use of abstractions

We control complexity by building abstractions that hide details when appropriate. We control complexity by establishing conventional interfaces that enable us to construct systems by combining standard, well-understood pieces in a “mix and match” way.

what is a program

Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate other abstract things called data. The evolution of a process is directed by a pattern of rules called a program.

3 mechanism in a programming language

Every powerful language has three mechanisms for accomplishing this: primitive expressions, which represent the simplest entities the language is concerned with, means of combination, by which compound elements are built from simpler ones, and means of abstraction, by which compound elements can be named and manipulated as units.

2 elements in programming

In programming, we deal with two kinds of elements: procedures and data … Informally, data is “stuff” that we want to manipulate, and procedures are descriptions of the rules for manipulating the data.

an environment

It should be clear that the possibility of associating values with symbols and later retrieving them means that the interpreter must maintain some sort of memory that keeps track of the name-object pairs. This memory is called the environment

visualisation of the process

To become experts, we must learn to visualize the processes generated by various types of procedures. Only after we have developed such a skill can we learn to reliably construct programs that exhibit the desired behavior.

level of abstraction

As programmers, we should be alert to opportunities to identify the underlying abstractions in our programs and to build upon them and generalize them to create more powerful abstractions. This is not to say that one should always write programs in the most abstract way possible; expert programmers know how to choose the level of abstraction appropriate to their task.

what are first class elements

Elements with the fewest restrictions are said to have first-class status. Some of the “rights and privileges” of first-class elements are: They may be named by variables. They may be passed as arguments to procedures. They may be returned as the results of procedures. They may be included in data structures.

compound data

Why do we want compound data in a programming language? For the same reasons that we want compound procedures: to elevate the conceptual level at which we can design our programs, to increase the modularity of our designs, and to enhance the expressive power of our language.

set

Informally, a set is simply a collection of distinct objects. To give a more precise definition we can employ the method of data abstraction. That is, we define “set” by specifying the operations that are to be used on sets.

representing data in bits

The application is to methods for representing data as sequences of ones and zeros (bits). For example, the ASCII standard code used to represent text in computers encodes each character as a sequence of seven bits. Using seven bits allows us to distinguish 27, or 128, possible different characters. In general, if we want to distinguish n different symbols, we will need to use log2 n bits per symbol.

coercion

Often the different data types are not completely independent, and there may be ways by which objects of one type may be viewed as being of another type. This process is called coercion. For example, if we are asked to arithmetically combine an ordinary number with a complex number, we can view the ordinary number as a complex number whose imaginary part is zero.

object vs streams

two prominent organizational strategies arising from two rather different world views of the structure of systems. The first organizational strategy concentrates on objects, viewing a large system as a collection of distinct objects whose behaviors may change over time. An alternative organizational strategy concentrates on the streams of information that flow in the system, much as an electrical engineer views a signal-processing system.

functional programming vs imperative programming

Programming without any use of assignments, as we did throughout the first two chapters of this book, is accordingly known as functional programming … In contrast to functional programming, programming that makes extensive use of assignment is known as imperative programming. In addition to raising complications about computational models, programs written in imperative style are susceptible to bugs that cannot occur in functional programs.

encapsulation

Encapsulation reflects the general system-design principle known as the hiding principle: One can make a system more modular and robust by protecting parts of the system from each other; that is, by providing information access only to those parts of the system that have a need to know.

closure

The local procedures can access the arguments of the enclosing procedure, simply by using parameter names as free variables. This is because the body of the local procedure is evaluated in an environment that is subordinate to the evaluation environment for the enclosing procedure.

concurrency

We can go further in structuring computational models to match our perception of the physical world. Objects in the world do not change one at a time in sequence. Rather we perceive them as acting concurrently – all at once. So it is often natural to model systems as collections of computational processes that execute concurrently.

stream processing

Stream processing lets us model systems that have state without ever using assignment or mutable data. This has important implications, both theoretical and practical, because we can build models that avoid the drawbacks inherent in introducing assignment.

query language

the query language’s processing of simple queries as follows: The system finds all assignments to variables in the query pattern that satisfy the pattern – that is, all sets of values for the variables such that if the pattern variables are instantiated with (replaced by) the values, the result is in the data base. The system responds to the query by listing all instantiations of the query pattern with the variable assignments that satisfy it.


##Evolving computing

Perhaps the biggest takeaway we should have from this book is why we invented certain paradigms and definitions and why it should change and evolve as we build more complicated systems.

We must constantly turn to new languages in order to express our ideas more effectively. Establishing new languages is a powerful strategy for controlling complexity in engineering design; we can often enhance our ability to deal with a complex problem by adopting a new language that enables us to describe (and hence to think about) the problem in a different way, using primitives, means of combination, and means of abstraction that are particularly well suited to the problem at hand.

Did you come across other resources that goes in depth on concepts behind computing? I would love to know them as well!

What other resources would you suggest to get an insight on computer science?