Chicken Scheme 6.0
code.call-cc.org
code.call-cc.org
CHICKEN is a compiler that translates Scheme source files into C, which in turn can be fed to a C compiler to generate a standalone executable. An interpreter is also available and can be used as a scripting environment or for testing programs before compilation.
But then Scheme was always less EVAL-friendly of the lisps
That's why SRFI-49 and its descendants were a possibility. Wisp, JavaScript, brainfuck, etc. implementations all exist because the tools exist in the language.
https://conservatory.scheme.org/schemers/Documents/Standards...
Not that I know why eval should be paired with reader macros.
((eval `(lambda (foo) ,exp) (scheme-report-environment 5))
foo)
(can't really think of applications for getting the current environment right now except for pseudo-macro stuff)If you want to manipulate the current environment, and defeat half the point of the language, then you're allowed that through (user-initial-environment).
(define-syntax) will also let you rewrite the bindings however you require.
Edit: Here's an eval macro I use fairly often:
(define-syntax constexpr
(syntax-rules ()
((_ expr)
(begin
(syntax->datum
(datum->syntax
(quote-syntax here)
(eval 'expr (interaction-environment))))))))
(define (factorial n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
(define n
(constexpr (factorial 10)))I was slightly worried that I'd start using v5 and then v6 would come out but it looked like they'd been working on it for a while so I figured I'd have some time on v5. Turns out I was wrong!
It is being used by many projects for this purpose: GNU Cash, Lilypond, GNU Guix... I don't know about games, however.
sdl is in the package manager, making it fairly easy to hook into, and "standard". From there its about the same as anything else.
Because I was cross-compiling, I compiled to C and had a... Somewhat complicated Makefile for building Linux, Windows, Android binaries all at once.
Debugging Android made me give up, in the end. The platform, not the tools I had, was the pain point.
Congratulations to the team, Chicken Scheme is a little gem!
The generated C is reasonably portable, so you can run Scheme programs on systems that “don’t run Scheme”.
And we did call it basilisk.
It has good emacs support with geiser-chicken.
Because it compiles down to C the FFI provides a lot of nice ergonomics beyond what I get with Chez Scheme.
Error messages are actually useful with a stacktrace. Can't overstate this.
It supports optional type definitions which reduces the number of tests I need.
The docs are adequate, though I frequently add "MIT scheme" to my search queries. I wasn't able to get chicken-doc setup in NixOS, and the docs website has gone down on me a bunch lately. I wish Chicken had complete documentation available including its eggs in an offline format, like a PDF.
It has good emacs support with geiser-chicken.
I wrote the initial support for chicken some 11 years ago; it wasn't _great_, but I see that Jao and others have worked on it some since then. Glad to see it's working well!SBCL is not compact and its "image" concept is not universally liked by everyone.
Guile and Racket are not fast (nor compact).
Chez Scheme is not "ready to use".
It is certainly not compact, though.
FWIW: I enjoy working with Gambit, especially since it can compile to C and standalone binaries and also scores even higher than Racket.
- Strings and symbols passed to foreign code are not copied, they are
passed directly, any mutations done by external code will be visible on the
Scheme side.
- Complex numbers, C structs and unions can now be passed directly as
arguments and returned as results when interfacing to C code.
Those were major bottlenecks for any FFI-heavy Chicken Scheme app, and would often result in brittle and unsafe abstractions to work around. Glad to see this changed.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).
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.)
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.
(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 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!
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.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.