
Behind the Scenes with Chicken Scheme - fogus
http://spin.atomicobject.com/2013/05/02/chicken-scheme-part-1/?utm_source=feedly
======
thecombjelly
I learned lisp a few years ago originally with Paul Graham's ansi common lisp
and built a few products in various common lisp systems but after a while I
really fell in love with scheme. I tried out numerous scheme ecosystems and
fell in love with chicken very quickly.

Since I found chicken scheme I have used it do everything I can. I have built
numerous web applications using it and it always makes my happy inside;
something I can't say for other ecosystems. It also works great for scripts
and interfacing to system libraries.

And of course the community is amazing. Even when I was new to lisp and
chicken my questions and patches were always taken seriously and responses are
always kind and helpful.

As felix mentions chicken scheme is really fast. Even on websites with
moderate load and very little performance profiling or caching my dynamic
pages are very consistently generated in less than <20ms. If you go a bit
further and give the compiler hints it gets even faster. And if it isn't fast
enough yet you can embed C code straight in your lisp source files.

It is tough to beat a language and ecosystem that nearly never gets in the
way, is easy for rapid prototyping, and gets great performance when you need
it.

As mentioned, Henry Bakers "Cheney on the M.T.A"[1] is a great read. I have
used it to implement a scheme system as well.

In summary: use chicken scheme if you want a nearly mature, production ready,
rapid prototyping, statically or dynamically typed, fast, easy to use, and
powerful language and ecosystem.

edit: Another really cool feature of chicken scheme is the ability to
serialize continuations. It can be used to make an extremely powerful stateful
web app that operates like arc and hacker news.[2] Since you can serialize the
continuations you can write the state to a file and you won't lose the state
when you restart the app or the server crashes.

[1] <http://home.pipeline.com/~hbaker1/CheneyMTA.html>

[2] <http://wiki.call-cc.org/eggref/4/suspension> and
<http://www.paulgraham.com/arcchallenge.html>

~~~
MatthewPhillips
So I've long wanted a good scheme for CLI programs. I've evaluated Chicken
several times and passed over it every time.... but I can't remember why.
Here's what I'm looking for:

1) Fast executables 2) No runtime requirement 3) Good ecosystem (for Scheme)
4) Good ffi (though I'd prefer a great ecosystem).

That's basically all I want. I also kept going back to Gambit but it fails at
#3 which Chicken seems not to.

Is there a gotcha for Chicken that I'm not remembering? Like how Racket has a
slow startup cost, Chicken doesn't seem to have that (from my testing). I
think Gambit is probably still faster but not by much (I could be wrong here).

~~~
hilti
Maybe You should newLISP (www.newlisp.org) give a try. I'm using it for my CLI
programs (like Dropbox background syncing, web scraping). newLISP scripts can
be linked to portable executables :-)

See here: <http://www.newlisp.org/downloads/newlisp_manual.html#linking>

~~~
klibertp
The only thing I heard about (I think, don't remember that well) newLISP was a
statement that the language lacks lexical scoping because the author didn't
know how to implement it.

Is it true (I mean dynamic scoping)? If so, why was the choice to exclude
lexical scoping made? Is it practical to write a bit larger apps/scripts in
newLISP?

~~~
astrobe_
IIRC the author wanted simplicity was the reason invoked by the author.
Newlisp has dynamic scoping and contexts (namespaces), in which you get
lexical scoping, plus other features. For instance when you want to close some
function over some variable, one creates a new function by expanding the free
variables inside the existing function (or lambda), to their local value at
runtime. Which shouldn't be too much expensive if used in a smart way, I
guess. This might be a bit weird, this and the Only One Reference (ORO) memory
management strategy, but Newlisp executable is very small with regards to the
craptons of functions that are included in the core. I could make it on a low-
end 32bits micro-controller, where few interpreters can pretend to run at
acceptable speeds and/or fit (a couple MB of flash space). The context and ORO
thingies may be use in conjunction to use what they call "FOOP", for
functional object oriented programming. The association of both paradigms, in
theory, should let users scale to larger applications, assuming they can grok
it.

------
sgrove
_"But what really makes CHICKEN special is its community. A group of helpful
and faithful fanatics is actively maintaining and improving it, sometimes at a
frightening pace. If you need help, ask on the mailing lists or IRC channel
and you get it. Always."_

I can attest to this - I played around making a 3d engine in Chicken, and the
IRC channel was both super helpful, and simply nice. It's wonderful to deal
with smart, nice people. Interestingly, #clojure is similarly full of nice,
smart people.

As for the language and tooling itself, it's also extremely nice. Binding to C
libraries was simple, even for someone doing it for the firs time. The emacs
integration was tight (not as tight as slime, but still nice). It just felt
like a productive ecosystem.

------
gecko
The original title of this was correct, guys; the product is named CHICKEN.
I'm not sure why the casing got altered.

------
melling
Every now and then I get the urge to try Scheme in my iOS app. I google'd and
found this:

<https://github.com/outworlder/beamrider>

Anyone using Scheme in a shipping mobile app? Does it work well in practise or
are there a lot of hurdles?

~~~
jlongster
Heh, way back when I wrote a 3d game in Gambit Scheme, but I'm not shipping it
anymore. There are definite drawbacks, but pretty big wins too. I set up a
live REPL to the phone and was able to send code straight from Emacs to it.

My original article is here: [http://jlongster.com/s/jlongster-
old/pages/blog/write-apps-i...](http://jlongster.com/s/jlongster-
old/pages/blog/write-apps-iphone-scheme.html)

I also made a bunch of videos:

<https://www.youtube.com/watch?v=Q7c0rU9Lv28>
<https://www.youtube.com/watch?v=Fcut5__ZrSg>

There are hurdles, yes, as you will find with any "off the beaten path"
technology stack. Lack of documentation, small community, etc.

------
jopython
My only gripe with Chicken,is that it has support only for green threads.
Otherwise it is one of the best scheme implementations you can get your hands
on.

------
oskarkv
Does Chicken have immutable data structures? How about typeclasses/protocols?
How about literal syntax for hash maps, sets, vectors/arrays?

I'm coming from Clojure, and I'm interested in Chicken. I really like the
things mentioned above about Clojure and I am just interested in how Chicken
compares when it comes to these things.

~~~
demetrius
In short, no. I believe these things can be added via extensions, but the only
thing from your list to be implemented this way is a persistent-hash-map [1]
so far (the egg doesn’t provide for a reader syntax though, but it is
definitely possible to add [2]).

[1] <http://wiki.call-cc.org/eggref/4/persistent-hash-map>

[2] [http://wiki.call-cc.org/man/4/Unit%20library#reader-
extensio...](http://wiki.call-cc.org/man/4/Unit%20library#reader-extensions)

