← Back to articles

NOTEBOOK

Elements of Programming, now executable

I have always loved algorithms, and I think Elements of Programming, by Alexander Stepanov and Paul McJones, is a spectacular book. It is also a demanding one: to really understand each algorithm you have to run it by hand, with pencil and paper.

Today I’m publishing a tool that makes the book easier to follow: Interactive EoP. It is the book, page by page, with a lab next to it where every algorithm runs step by step.

How it works

The screen is split in two. On the left is the PDF of the book. On the right are the algorithms from the page you are reading, ready to run. Turn the page and the lab follows you.

When you start an algorithm, the code advances one statement at a time, and at each step you see:

  • The sequence and the iterators, drawn on screen and moving whenever the code moves them.
  • The operation log: every comparison, every read, every call to the predicate.
  • The counters: predicate applications, comparisons, swaps, assignments. These are the same numbers the book states in its lemmas, so you can read a lemma and check it right there.

What else is in it

  • C++ compiled in the browser. The code is compiled and run on your machine, with nothing to install. It is the book’s C++ adapted to today’s language, with concepts and contracts. Every algorithm is also available in TypeScript.
  • Editable code. You can change the input data, or solve the book’s exercises and projects right in the lab.
  • The full catalog. All 385 entries from the book, covering algorithms, exercises, and projects, with search. Pick one and the book opens at its page.
  • In English and Spanish.

Try it

A good place to start: open page 191, start partition_bidirectional, and watch the two iterators close in on each other.

If you like it, share it: send it to someone who is reading the book, or to someone who never dared to start it. And if you have comments or run into something odd, write to me through the blog’s contact page.

Elements of Programming is by Alexander Stepanov and Paul McJones, who have offered the PDF for free at elementsofprogramming.com since 2019.

Comments are hosted by Disqus. Load them to join the conversation.