Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Uhm. I'm divided. Common Lisp it's the weird cousin, bloated at first but in the end you get SBCL, ECL or CCL and almost everything will work the same. With Scheme, you need to instal SRFI's to complete SICP exercises and then there's R5RS and R7RS.

You have no way to run Hypergiant under Guile. In Common Lisp, tons of packages for QuickLisp/UltraLisp will run on SBCL, CCL and ECL with ease.

In the end Scheme+Dependencies can be more convoluted than a subset of Common Lisp (you can avoid CLOS if you don't need it for instance).



Scheme SRFIs make Scheme a much bigger language while also making it painful to use because you have to research which SRFI are implemented in your scheme variant then map those SRFI numbers to what they actually do then you usually need read the raw SRFI because that's the only documentation around.

R7RS is going on 14 years old and there's still no R7RS-large either. They really need to just take the critical SFRIs, give them names and proper documentation, then call them R7RS-large and move the current work to a future R8RS.


Indeed. Scheme it's amazing for embedded (such as s9) and its small size. Also, the SICP it's cool to do with Chicken Scheme and this ~/.csirc (and chicken install srfi-203 and srfi-216):

    (import scheme)
    (import (srfi 203))
    (import (srfi 216))
 
 (define (displaynl x)
  (display x)
  (newline))
 
 (define pi (* 4 (atan 1.0)))
 
Even if Chicken has Hypergiant to play with 3D objects, Common Lisp has Kandria, Sketch, Kons-9...

From Scheme, after finishing SICP as an Scheme exercise (and CS course), just jump into Common Lisp, and finish both Gentle Introduction to Symbolic Computation and Paradigms of Artificial Intelligence, where you will implement a micro-Scheme in Common Lisp itself as an exercise.

SBCL allows you to create working stuff with very few dependencies (uiop and the like from QuickLisp/Ultralisp). With Scheme/Chicken you will get lost in a maze of eggs and SRFI's.

And, on CS/academics, if you finish SICP both GITC and PAIP on on Common Lisp will be a breeze and it will give you superpowers with these three books.


I guess you mean s7 -- I find s7 scheme fits into a lua shaped hole for scripting larger applications quite well without having to use lua (which is a personal preference). I used s7 scheme for scripting a C program years ago, and moved on to writing programs with chicken scheme.

I really think in an alternate universe chicken scheme could fit into the python niche, because the eggs feel very "batteries included". Super excited for this release!


Are there official solutions/answers to SICP?


Github has several repos, there's one which works for Guile (and Racket for the 2nd lesson), but you can just use Chicken Scheme 5 for all of them.

Here are the commands to build the addons needed for Chicken Scheme 5 and SICP compat. You need gcc, make and similar tools on your Unix machine. Install "build-essential" on Ubuntu, Debian and derivatives will just work.

     chicken-install -s srfi 203
     chicken-install -s srfi 216
     chicken-install -s trace
Then at ~/.csirc

     (define
        (displaynl x)
        (display x)
        (newline))

     (define pi (* 4 (atan 1.0)))

    (import scheme)
    (import (srfi 203))
    (import (srfi 216))
Displaynl and "pi" are just for convenience.


Thanks. I’ll look into that. What about SICP solutions that work with MIT Scheme? That’s the implementation of Scheme used in SICP. Also, what are the differences between the major Scheme implementations?


Sorry, I hit the nested comment limit. On MIT Scheme, it used to recommend some older version, specially the first edition, but on Chicken 5 with the SICP related SRFI's loaded and maybe scm-sicp you can hit an almost 100% compatibility.

On differences, I already said that there's local library overlapping from the own subdialect implementations, such as Chicken Eggs and Guile ice-9 modules, but if you start them with R5RS or RSR7 standard compatibility flags the differences fade away, altough there are rough edges:

https://doc.guix.gnu.org/guile/latest/en/html_node/R6RS-Inco...

It's like ANSI C vs C99 but worse.

So I use Scheme for small scripts with S9 (R4RS standard) plus Unix and NCurses related addons.

For learning SICP, I use Chicken 5 with 203 and 216 eggs plus the ~/.csirc and call it done. Most of the R5RS stuff from SICP will run fine under S9 too with tons of patience (and you can maybe adapt the postscript generating Scheme code from the "Computer Abstraction" books for the frame language and just spit out some PS file). It's just basic geometry with vectors in the end, something SICP will teach you throughly. If you finish SICP with Chicken you for sure will be able to even adapt the threading Scheme code from the chapters for an R4RS compliant Scheme like S9 as it already has some Unix/thereading support. Just generate some wrapping functions and call it done :). It's, for sure a great exercise for Lisp and CS, and far easier to do, for example, than making a ANSI C compiler being C99 compatible. Or, as a modern example, backporting modern Rust/Java functions to older compilers.

On S9 Scheme (s9fes) you could just hack away most of the exercises at blinding speed...

I prefer Common LIsp for bigger tasks (altough you can learn a lot of CS with Gentle Introduction to Symbolic Computation and Paradigms of Artificial Intelligence Programming too), but SICP it's 'harder' and it will put you on God low-level mode making the CL exercises at light speeds despite the design differences between Scheme and CL:

Common Lisp:

  (defun hello () (princ "hello"))
   (hello)
Scheme:

   (define (hello) (display "hello")) 
   (hello)
The reason on picking CL over Scheme: If the code runs under SBCL, CCL and ECL call it done, it will almost run on every Common Lisp compiler/interpreter, even the commercial ones. Quicklisp (and UltraLisp) will handle the dependencies itself and CLHS (Common Lisp Hyper Spec) will have everything doccumented on your hands. The editor? Emacs+Slime or Lem, with both have functions to look up functions and autocomplete, with help about a function or library in the spot. Far better than Scheme in the end for big projects.

Both will teach you iteration vs recursion, anonymous functions (lambdas), closures and so on.


That dynamic was exactly why I moved from Scheme to CL many years ago (full disclosure, Clojure is my daily driver, now). I loved the minimalism of the RxRS documents, but they really only covered the small core of the language, and then all the implementations were completely different when it came to libraries. And those differences always needed to be understood in order to write real-world programs. SRFIs helped, but adoption was spotty. Every multi-implementation language has some of that, but Scheme had more than most. For me, the choices were to use a very full-featured Scheme like Racket (which is great) or go to CL and then use something like SBCL. I went with CL and later jumped to Clojure (which, IMO, is a better, more modern Lisp that fits better with today’s multi-core hardware than either Scheme or CL).


However, with Schemes the SRFI implementations usually (?) come with the standard library, so you don't actually "have to install" them. Still gotta know the usual suspects, like SRFI for tests, SRFI for vectors, hash tables, random numbers, etc. if you want your code to be mostly portable to other Schemes.


I've never really heard of installing SRFIs (could be my ignorance); do you mean importing them? Or is installing SRFI implementations as their own packages really common? (Haven't really tried R7.)

The anti-R6/R7 folks (or what I've heard) won't see a problem so long as you can use CL to build fancy serious software, which lets Scheme stay small and simple for education. (Of course ideally you'd be able to do any SICP exercise on a Scheme implementation out of the box, though.)


For that I use Chicken 5 with trace, srfi-203 and srfi-216.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: