DEV Community

Cover image for Get Started Writing Scheme

Get Started Writing Scheme

Ben Lovy on February 11, 2020

TL;DR: Download Racket, run plt-r6rs my-file.scm. Bookmark this book and check it when you have questions. Scheme is an old programming language,...
Collapse
 
downey profile image
Tim Downey • Edited

Dan Friedman was one of my professors!! 🀯 Seeing these books mentioned brings back lots of memories...

(mostly (of ('parentheses)))


I bet @daniel13rady would enjoy this post 😊

Collapse
 
daniel13rady profile image
Daniel Brady

Probably so! Will read soon πŸ˜„

Collapse
 
bonfacekilz profile image
the_savage

I used to think that scheme is locked down in academia, but it turns out I was wrong about that. You should check out GUILE, the official extension language for GNU, and turns out it's a scheme dialect . There's a whole ecosystem written in it like GUIX, shepherd(an alternative init system) and a bunch of other cool stuff. For books to read, I'd strongly recommond Structure and Interpretation of Computer Programs(SICP).

Collapse
 
deciduously profile image
Ben Lovy

I've only come across GUILE in the context of GUIX, when I was deep-diving through NixOS. Do you use Guile or Guix?

Collapse
 
bonfacekilz profile image
the_savage

I've been using GUILE for a while(wrt prototyping random things) now. I want to setup GUIX on a spare machine. I run FreeBSD so unfortunately alot of linux tooling doesn't really work out of the box. I want to create a monitoring tool in that ecosystem.

Collapse
 
bonfacekilz profile image
the_savage

Update. I've been using GUIX now for the past 3 months and I've kinda even got my hands dirty hacking on some things in that ecosystem like: gitlab.inria.fr/guix-hpc/guix-past

Collapse
 
metalmikester profile image
Michel Renaud

That brings back memories. We used Scheme in university for the Functional Programming course back in 1994.

No highlighting of opening and closing parentheses in editors. That was fun.

Collapse
 
gypsydave5 profile image
David Wickes

Highlighting is for the weak.

Collapse
 
metalmikester profile image
Michel Renaud

I program like a man. I use "copy con program.exe". :)

Collapse
 
ackzell profile image
Axel MartΓ­nez

(((()(()()()))))!!!

I had a lot of fun with Scheme / Racket at school, good times 😁

I can't remember how, but we plugged in a way to visualize the results of our programs and I even was able to animate the thing! My professor's mind was blown and I started realizing I liked "the front end" side of my projects more than anything πŸ˜›

Can't quite say the same about Prolog though.. that broke my brain.

Collapse
 
jcubic profile image
Jakub T. Jankiewicz • Edited

I've created bookmarklet that runs Scheme REPL on any website, you can use it on book or this site. The Scheme implementation is LIPS: my Scheme interpreter written in JavaScript.

Note that mod is not in R7RS standard function, so it's not defined in LIPS (it may be in R6RS but no one is using it). In order to run your example you need (define mod modulo) or change mod in the gdc function definition.

Collapse
 
jcubic profile image
Jakub T. Jankiewicz • Edited

I don't understand how anyone can recommend book like "The Little Schemer". I've got 3 books in the series without looking inside and they were worse programming books I've ever seen.

I can only see benefit if someone is learning scheme elsewhere and this is just exercises book. Since the structure of that book doesn't make any sense to me if you want to learn on your own. For me the those books were useless.

Collapse
 
deciduously profile image
Ben Lovy

Well, conversely, I don't understand how anyone can not get a lot out of this series, I devoured every entry as a self-learner. No, they were not the only material I used to learn Scheme and recursion, but but I've never learned any concept from just one resource. It's an unorthodox format, I agree. But everyone has a different learning style. I'm sorry to hear it didn't work for you, but clearly it's worked for a lot of other people. i'm glad there's a massive range of learning materials for self-learners, so if one recommendation doesn't sit well, there's always more to try.

Thread Thread
 
jcubic profile image
Jakub T. Jankiewicz

I would love to see experience from someone that has 0 knowledge and start with this book. And this is what people recommend as first book. I can understand if someone want to use this book when she already know Scheme. But the target for this book are complete newbies, which for them I would never recommend it.

For me personally best book about Scheme is Sketchy Scheme by Nils M Holm.

Collapse
 
leob profile image
leob

I recognize it as a "Lisp", right? What about Clojure, how does Scheme compare to Clojure? Clojure is/was sort of getting popular and creating a community ...

Collapse
 
deciduously profile image
Ben Lovy

Yup! It's the oldest of the commonly used Lisp families, alongside Common Lisp and Clojure. I think the rough analogy goes like this:

Scheme : C
Common Lisp : C++
Clojure : Java

Of these, Scheme and Clojure are "functional" languages, or at least functional-first, and Common Lisp is truly multi-paradigm. It's very "kitchen sink", it has a massive amount of features, like C++.

Clojure is designed specifically with interop in mind. It can be used seamlessly as a hosted language targetting either JVM bytecode or JavaScript via the Closure Compiler. It also ships with a set of persistent data structures, and Clojure code is highly suited for concurrency and immutability. It's partially a response to the relatively stagnant development models of Scheme and Common Lisp, bringing the Lisp sensibility to a more pragmatic type of tool.

In a sentence, Clojure has a focus on actually building large, robust, reliable software, whereas Scheme is primarily an academic tool focused studying abstract concepts.

Emacs Lisp gets a shout-out as the fourth "category" still in wide use, but I don't believe it really has a life outside of Emacs itself.

Collapse
 
deciduously profile image
Ben Lovy

The Little Schemer is one of my favorite books, period, not just technical. I'm also interested in The Little Typer but I'm not sure I'm smart enough.

Collapse
 
jamesliudotcc profile image
James Liu

I wrote a much, much more basic how to here: dev.to/jamesliudotcc/use-dr-racket.... It is more for someone with this problem: "I got suggested The Little Schemer and the code won't run."

Collapse
 
rudolfolah profile image
Rudolf Olah

Always good to see more Lisp and Scheme code. Hopefully you can use Racket for production code at your workplace!

Collapse
 
deciduously profile image
Ben Lovy

Workplace at all first, racket second ;)

Collapse
 
theodesp profile image
Theofanis Despoudis

Aaa you got parethesiasis?

Best if you couple your knowledge with this book
web.mit.edu/alexmv/6.037/sicp.pdf

Collapse
 
downey profile image
Tim Downey

Is there a web framework/web server for Racket that folks would recommend? This post has gotten me nostalgic.

Collapse
 
dannypsnl profile image
ζž—ε­η―†

Just take a look at awesome-racket, github.com/Junker/routy looks pretty nice. But not sure why they don't map parameters to form like:

(get "/hello/user/:name"
  (lambda (name)
    (format "hi, ~a" name)))

oh my, I already start thinking about how to build that macro get.