1. 42
  1.  

  2. 9

    I feel I’ve outgrown beginner-level “primers” in regards to Lisp/Scheme, but was thoroughly surprised by the approachability and depth of this tutorial c:

    Any curious Schemer who knows their way around a defmacro but hasn’t finished SCIP/The Little Schemer ought to click right through to Section 12 in the TOC, and freely follow footnote links both back into the tutorial and out to broader resources.

    I liked the “Most Beautiful Program” talk when I saw it some time ago, and appreciate the working Guile example and accessible (see Sections 1-11) / nuanced (the why) context that the metacircular interpreter is presented in here all-the-more. Interested folks should still check out the talk (barring it’s own lengthy primer) for more depth on environments, additional special forms, and interesting applications, but I found the gist of it pleasantly distilled here. By contrast, the Lisp 1.5 Manual which inspired the talk (and many an interpreter) really throws one into the deep end of a Lisp that was not as we now know it. Excellent resource, and thank you for sharing ^u^

    1. 8

      Gosh! Thank you for this really nice feedback. It made me feel really great!

      I also tried pretty hard to make the evaluator understandable. William Byrd’s talk was the cleanest I had ever seen anyone do it, and I think the choice of using a pattern matcher really does help one see things structurally here. But I tried to make it even clearer while both a) adding support for multiple arguments to a lambda and b) having the environment be an easy to inspect association list.

      By the way, I’m glad you read the footnotes. I’ve always liked writing footnotes but I felt like I had been discouraged from doing so in college, but I had a couple of opportunities to stumble into Gerald Sussman’s office and twice he pointed at footnotes he’d written and told me to pay attention to those parts especially.

      Anyway, yeah. I aimed for the document to be usable for two different purposes:

      • As a quick skim, it’s a reasonable intro to “how to start programming with Scheme with no prior experience”. Hey, tutorials are useful!
      • But also, in less than 30 pages we manage to compress a TON of computer science ideas in a way that I think is really, really approachable.

      There’s a lot of stuff pulled out of The Little Schemer and SICP compressed into a very few pages there… I tried to get the most important things to understand about side effects / mutation being “time entering our programs” (for better and worse both) and also tail call elimination and etc. I had a few friends who didn’t know Scheme preview the paper… I was really happy to see them sending me their a-ha moments. Nothing I came up with… everything in that document has been explained elsewhere somewhere. But maybe hopefully it’ll let some of the lovely ideas reach new audiences!

      1. 1

        +1 on the job well done. I’m someone who could never really get into SICP and found lisps / s-exprs unapproachable, but once I got an editor set up with Racket and found the documentation to go along with differences in your code samples, this was a really good experience.

    2. 6

      Nice, this looks like one of the better tutorials out there. Most tutorials are either written by non-Schemers (or rank novices who are just figuring things out themselves) or severely outdated. On that note, I was a bit dismayed to see define-macro make an appearance, but I’m glad the hygienic alternative is presented right away.

      1. 6

        Thank you so much! And yes, heh, I suspected some schemers wouldn’t love define-macro making an appearance at all, but it’s much easier to understand how macros in general, including the hygienic ones we love, work by seeing the one that’s “just manually manipulating a list”, and then pushing the user towards pattern matching (which I have found requires more of a suspension of disbelief). What do you think?

        1. 3

          Yeah, I fully understand why you would want to do that. The explicit/implicit renaming macro system or syntactic closures would possibly be better in that regard (especially if the user wants to explore those further), but Guile and Racket don’t support those I think.

          1. 2

            as someone who’s written macros in emacs lisp but hadn’t grokked scheme’s yet, this approach was extremely helpful to me. thanks!

        2. 4

          This is great - the level is much better than the many shallow tutorials which only explain the quirks of prefix notation and what cons is etc. One typo:

          REPL> (for-each (lambda (str)
                            (display
                             (string-append "I just love "
                                            (string-upcase str)
                                            "!!!\n")))
                          '("strawberries" "bananas" "grapes"))
          ; prints:
          ;   I just love ICE CREAM!!!
          ;   I just love FUDGE!!!
          ;   I just love COKIES!!!
          
          1. 3

            Also in section 12:

            We can also make a lambda and apply it. Let’s make one that can perform square roots:

            actually calculates a square.

            1. 2

              I still find myself wanting a tutorial on the messy, everyday usage like reading, writing, and parsing strings from/to ports, but I enjoyed that!

              1. 3

                I still find myself wanting a tutorial on the messy, everyday usage like reading, writing, and parsing strings from/to ports, but I enjoyed that!

                I wonder if there would be any interest in a Real World CHICKEN Scheme book about practical programming, in the spirit of Real World Haskell et al. I have an urge to write one.

                1. 3

                  Please do! There’s been a long standing TODO of writing such a book.

                  1. 2

                    I would definitely read this book. this is the stage of my scheme understanding, and is greatly benefit from a real-world book.

                  2. 1

                    I had considered a section on ports, but wasn’t really sure if it would make things too large. Heck, I considered following up the metacircular evaluator part with one with implementing a simple scheme read (from ports) in a similarly small amount of code but thought, that’s probably getting to be too much and in the way of this feeling like a document someone can complete in a short amount of time. What do you think?

                    1. 1

                      Do you know of any existing articles/tutorials which fill that gap? If yes, you could link to them; if no, you could always write a separate article. I think you’ve got the length about perfect as it is.

                  3. 1

                    Great catches! I’ve updated the documents with the fixes. Thank you so much!