Why most books on computer science use scheme and not ocaml?

Is it because of the “symbol” type or another reason ?
How do you implement the scheme “symbol” type in ocaml ?

The `Symbol notation (polymorphic variant tags) can be used to have functions which handle something like symbols.

let f = function `A -> 1 | `B -> 2 | _ -> 42;;

In my honest opinion, the main specific and interesting scheme feature is the hygienic macro (but some other languages propose such a feature).

1 Like

I think there are two reasons for the early popularity of Scheme in education (and is some older intro to CS books):

  • It was developed way back (in the 1970s) in MIT and the usage of the language there gave to it a lot of credibility as a first programming language (after all MIT is widely regarded as one of the best universities in the world). OCaml came to the scene much later when the language landscape was much more competitive.
  • More importantly, however, Scheme is a super simple and minimalist language and I think that’s perfect when you’re introducing someone to programming. Obviously you can limit how much of any language you teach to newcomers, but I think some hard boundaries make it easier.

Btw, can you share some of the CS books you’re referring to? I honestly don’t think there are that many prominent books using Scheme (I can only think of something like 5). Yeah, certainly more books use Scheme than OCaml, but I won’t say “most books” on CS are using Scheme. And the times are changing always - even the course in MIT that made Scheme famous is using Python today.

3 Likes

I agree with @bbatsov. Scheme is older, was designed and marketed as a teaching language, and it’s also super minimalist.

I think the most appealing feature of scheme as a teaching language is that there is the only syntax is operator application (aside from the dot operator, which can be ignored in the beginning) and a handful of atom literals.

Scheme allows the teacher to spend about five minutes on syntax before diving into the actual business of programming.

The other nice feature of Scheme from a didactic perspective is that it makes it very clear that programs are just another form of input data for the computer, and they can be handled like any other form of data. I think this is one of the most powerful ideas in programming.

Of course, OCaml is the perfect language for diving into program analysis and compiler design on a deeper level, but it makes you go into the nuts and bolts of creating a parser, whereas Scheme lets you use its own parser and get straight to the real fun of AST transformations.

That isn’t to say Scheme is actually better for teaching than OCaml (depends on the student, depends on the teacher, I guess), just that I can see the appeal from a didactic perspective.

5 Likes

Books,
How to design programs
Essentials of programming languages
Scheme the art of programming
Simply Scheme
Structure and interpretation of programming languages
Programming Languages : Application and Interpretation

Note that out of that list HtDP, EoPL, PLAI and S:TAoP are written by educators tied to the PLT Scheme/Racket project and the newest version of SICP uses JavaScript.

2 Likes

Note that out of that list HtDP, EoPL, PLAI and S:TAoP are written by educators tied to the PLT Scheme/Racket project

I was just about the write the same myself.

What’s TAoP in full ?

I assume it’s “Scheme and the Art of Programming” (see Amazon.com).

That’s the book you mentioned, Scheme: The Art of Programming.

For the sake of completeness.
Four other scheme books,

  • Scheme and The Art of Programming (George Springer & Daniel Friedman)
  • Programming and Meta-Programming in Scheme (Jon Pearce / David Gries / Fred B Schneider)
  • An introduction to scheme and it’s implementation ( Paul R. Wilson)
  • Programming in Scheme (Springer / Mark Watson)

In France, there are several courses to prepare the competition to the top-tier-schools. The Computer Science oriented cursus - MPSI - is based on Ocaml (the program adds C and SQL). Other courses have Python (and SQL)

In high school, Python is in the program too.