DEV Community

Cover image for The book that changed my development career now has a Javascript version
Manuel Odendahl
Manuel Odendahl

Posted on

The book that changed my development career now has a Javascript version

From BASIC and C teenage hacker...

SICP book cover

When I was a teenager, I used to program in QBasic, assembler and C. I had tremendous fun: I was sitting at my computer yet creating universes.

In QBasic you would write a program, run it, and get to play with it immediately (I mostly wrote games). Because we only had a very old DOS computer without a graphics card and hard drive, the only other programming tool I had access to was a program called debug.com that allowed you to mess with the program memory, and enter your own assembly code (you had to do the assembling by yourself). It was oh so painful, but I learned how a CPU works. It also made me want to never translate assembly to binary ever again.

Once I could afford an old second-hand pentium 133 Mhz, I installed linux and started to learn C. I wanted to become a hacker, sp0k3 l1k3 th1s on IRC, and had tremendous fun learning about compilers and operating systems and memory layouts.

To aspiring functional programmer...

Lambda (courtesy Wikipedia)

But in the early 2000s, a chance encounter on IRC changed my development career. A german programmer (hi forcer if you ever read this!) recommended I read this book called "Structure and Interpretation of Symbolic Programs", by Abelson, Sussman and Sussman. It is freely available online. It is a both a dry and formal book, and a very immediate book, because every code example is immediately executable. I dove right into it, and a few weeks later had built an obnoxious IRC bot to administer my channels. I later found some very clear lecture videos online, now available on MIT's youtube.

From lambda to a VM and compiler

Metacircular Evaluator (courtesy Cornell)

In a minimalistic language called Scheme, the book walks you through building programs from the simplest mathematical concepts: abstractions, evaluation rules, combining smaller functions into bigger functions. It implements everything with functions, and teaches you how functions are things you can compose and manipulate. This might seem obvious to someone growing up with Javascript, but for someone coming from C, for whom a function was basically a goto that could return, this was absolutely groundbreaking.

Things become really fun in the second chapter, where you build different mathematical algorithms. Who knew that a lot of differentiating and integrating was pretty much the manipulation of a fairly simple data structure! Coming from C, where even using an array is a painful and dangerous things, this concept of data structures and implementing them using functions was absolutely mind-shattering. Suddenly code was data and data was code.

By the third chapter, you implement stateful structures, a digital circuit simulator, infinite lazy streams, deal with concurrency at a symbolic level, all still just using Scheme, that minimalistic functional language. In the fourth chapter, the one that caused me the most problems at first, and completely shifted my brain, you implement a scheme interpreter in... scheme. And you then manipulate that interpreter in many interesting ways: probabilistic computations, logic programming, lazy evaluation. It shows you how easy these ideas are to actually implement, and how implementing them is the best way to learn how they work. This opened up an entire world to me. After this chapter, I was not intimidated by building my own languages, compilers, symbolic program manipulations, code generation. I knew there was a very elegant foundation that I could come back to.

In chapter five, you implement the culmination of all of this hard work: building a virtual machine, garbage collector, an efficient machine-optimized interpreter and finally a scheme compiler. In one book you went from what seems trivial functions to a full VM with compiler and garbage collector.

This book changed my career

Galaxy brain, courtesy wikicommons

In a beautiful foreword, Guy Steele writes about the history of programming languages, and how Javascript stands on the shoulders of giants. And I can only agree. To this day, and in all my web development endeavors, I still innerly think in scheme and abstract functions.

I am now not afraid to write functional code in the midst of a big mess of PHP. I am not afraid to introduce ideas from compiler theory, DSLs, interpreters, virtual machines into my day to day life, because I know how simple and elegant they can be expressed. It gives me the confidence to tackle daunting languages like Haskell, more experimental languages like Elm, or esoteric topics like formal theorem proving. It sheds light on the inner workings of many modern frameworks, not least React, which borrows a lot from functional programming and the concepts explored in this book.

After reading this book, I became a Common Lisp web developer, writing one of the first transpilers for Javascript out there. With my colleague Hans HΓΌbner and his forward thinking ideas (he was writing SPAs in the early 2000s), we wrote the BKNR web framework and database. With just two programmers, we built our own web server, database, frontend framework, XML import/export, templating language, constraint driven graphics layout and much more.

I wrote my own optimizing assembler for the Z80 CPU, which we used to control a speech synthesizer chip. Later on, I wrote my own CAD/CAM software to control a CNC mill, automatically generating the front panels for my electronic circuits. I wrote an algorithmic movie editor (that one is a proper mess...). I then moved away from Common Lisp to much more down to earth bare-metal C++, PHP and javascript, but I never left Scheme and functional programming behind. To this day, it informs everything I do, and one day I know I'll come back.

None of this would have happened if I hadn't worked through SICP.
It really opened my eyes to the beauty of programming, and how effective understanding the elegant fundamentals can be.

And it's now available in Javascript!

SICP JS cover

Back in the days before the internet turned to the big ball of craziness it is nowadays, it was fairly easy (well, just as easy as you could get) to get started with Scheme. You would install guile, and emacs, and get rocking.

These days, we don't even need that. We have all this wonderful environment right here in our browser, and javascript is a language that allows you to manipulate functions just as easily. It's no big surprise that a book that is about the core ideas of programming, about the elegance of functions and the power that comes with them, is now available with Javascript examples, all available for free on their website.

In some way, I miss the elegant syntax of scheme, but I am sure that the move to Javascript will help bring this amazing book to the wide, vibrant, diverse javascript developer community.

So what are you waiting for! Fire up your editor, go to SICP JS and change your life!

What about you?

Do you have any books that changed your career? Do you think functionally, but write imperatively? How long did it take you to understand the meta-circulator evaluator? Do you think you could implement a garbage collector in just a few functions?

Top comments (11)

Collapse
 
clairemattockskth67 profile image
clairemattockskth67 • Edited

Unfortunately, I didn't have such a book back then. Although I tried to read a lot of useful things. Only later something interesting came out (I mean books). Now I was reading "the miraculous journey of edward tulane", used freebooksummary.com/category/the-m... for that. I'm not even interested in java script books anymore. But I advise a lot of people who are just starting to read books to do it at the same time. You will find a lot of useful information in them at the moment.

Collapse
 
lookrain profile image
Lu Yu

Huh interesting to see someone posting about it here haha. It was the textbook used for my first CS course in National University of Singapore. The co-author of the JS version is a prof here Martin Henz.

Fun fact, the language used in the site was called JediScript, now seems to have been renamed to Source.

Collapse
 
wesen profile image
Manuel Odendahl

Martin contacted me after I wrote this article and invited me to the release lecture at MIT. What a nice person, and very committed to education and pedagogy. What was the experience like for you?

Collapse
 
lookrain profile image
Lu Yu

He's an awesome teacher and person in general, super knowledgeable and nice to interact with :)

Collapse
 
dannyengelman profile image
Danny Engelman • Edited

The TRS-80 manual definitely changed my live. I was 10, and since Dutch was my first, and at that time still only language, it was a book full of magical spells.

10 PRINT "DANNY"
20 GOTO 10
Enter fullscreen mode Exit fullscreen mode

When I learned to put a semi-colon after the first line I got hooked on programming, and learned English along the way.

In 1990, Programmer's Guide to the EGA and VGA Cards changed my mindset from being a back-end developer (I did Gopher) to "front-end".. I only want to program stuff that does something on the screen.

I then switched to 4GL Macromedia Authorware, but being able to do 3GL scripting made it powerful.

And then the Web really kicked in; Adobe bought Macromedia and killed all good tools by moving development teams to India.

And now we are all thrown back to almost only 3GL... and people get excited about retro languages like WASM.

Programming is more fashion than science.

Anyone want to buy my Peter Norton book?

Collapse
 
wesen profile image
Manuel Odendahl • Edited

Oh damn I was reminiscing about the computers I grew up with this morning, and the books that got me into programming. The Pete Norton book was the only programming book at the library and I used that in conjunction with debug.com!

And of course these books actually made me a programmer, because games.

rockpapershotgun.com/usborne-codin...

I still have this one on my desk as a talisman

adventure games

Collapse
 
dannyengelman profile image
Danny Engelman • Edited

Don't forget the monthly dose of code in SoftSide magazine.
How can young programmers learn to code without graphics like that?

SoftSide August 1981

CodeMentor april 2022

Collapse
 
wesen profile image
Manuel Odendahl

Writing this article really makes me want to go through the book again. There is also a new book called Software design for flexibility that builds upon these ideas. I found it less convincing than SICP, but haven't worked through it much yet.

mitpress.mit.edu/books/software-de...

Collapse
 
wesen profile image
Manuel Odendahl • Edited

If you are in the area, please drop by!

SICP: Past, Present, Future

Join Gerald Jay Sussman, Hal Abelson, Martin Henz, and Tobias Wrigstad as they discuss the rich history and evolving future of the classic text Structure and Interpretation of Computer Programs, just published in a new edition adapted for JavaScript.

Talk and Q&A

SICP: Past, Present, Future
4:30 - 5:15pm
Thursday, April 28
Stata Center, Room 124

Gerald Jay Sussman, Hal Abelson, Martin Henz, and Tobias Wrigstad in conversation

SICP Past present future

Collapse
 
nadjib_os profile image
nadjibOs

Thank you so much

Collapse
 
aaravrrrrrr profile image
Aarav Reddy

Very detailed, thanks.