The question is as follows:
There are no shortage of vague "Scheme vs Common Lisp" questions on
both StackOverflow and programmers.SE, so I want to make this one more
focused. The question is for people who have coded in both languages:
While coding in Scheme, what specific elements of your Common Lisp
coding experience did you miss most? Or, inversely, while coding in
Common Lisp, what did you miss from coding in Scheme?
I don't necessarily mean just language features. The following are all
valid things to miss, as far as the question is concerned:
* Specific libraries.
* Specific features of development environments like SLIME,
DrRacket, etc.
* Features of particular implementations, like Gambit's ability to
write blocks of C code directly into your Scheme source.
* And of course, language features.
Examples of the sort of answers I'm hoping for:
* "I was trying to implement X in Common Lisp, and if I had
Scheme's first-class continuations, I totally would've just done Y,
but instead I had to do Z, which was more of a pain."
* "Scripting the build process in my Scheme project got
increasingly painful as my source tree grew and I linked in more and
more C libraries. For my next project, I moved back to Common Lisp."
* "I have a large existing C++ codebase, and for me, being able to
embed C++ calls directly in my Gambit Scheme code was totally worth
any shortcomings that Scheme may have vs Common Lisp, even including
lack of SWIG support."
So, I'm hoping for war stories, rather than general sentiments like
"Scheme is a simpler language" etc.
This question was originally posted here:
http://programmers.stackexchange.com/questions/41045/scheme-vs-common-lisp-war-stories
Best,
-- Matt
> Hi all, I've posted a question regarding Scheme and Common Lisp to
> programmers.stackexchange.com, but so far it has gotten few answers.
> I'm hoping that the people of comp.lang.lisp might have more insight
> to offer on the subject.
The only insight to be had is that there is no insight to be had on
this subject.
> The only insight to be had is that there is no insight to be had on
> this subject.
I suspect that Rob Warnock would have some insights on this topic,
moving as he did from working with scheme to working with common lisp.
For example:
<http://groups.google.com/group/comp.lang.lisp/msg/3daa0462a439a768>
Whether his experience is generalizable to all potential scheme or lisp
users is another question; whether the OPs question will lead to more
light than heat is yet another.
warmest regards,
Ralph
--
Raffael Cavallaro
[troll]
OMFG Scheme has no READ? Then it's totally not a Lisp!!!
[/troll]
...a little more seriously... really? No READ? That sounds like a real
WTF to me.
> ...a little more seriously... really? No READ? That sounds like a real
> WTF to me.
It has read. I didn't look back further than R3RS (its hard to search
for older reports and get instant hits) but I would expect it has
always been there.
You must be new here. Anyone who posts here on a regular basis would
have already complained loudly had they had that experience.
> I don't necessarily mean just language features. The following are all
> valid things to miss, as far as the question is concerned:
>
> * Specific libraries.
> * Specific features of development environments like SLIME,
> DrRacket, etc.
> * Features of particular implementations, like Gambit's ability to
> write blocks of C code directly into your Scheme source.
BTW, ECL can also do this.
> * And of course, language features.
>
> Examples of the sort of answers I'm hoping for:
>
> * "I was trying to implement X in Common Lisp, and if I had
> Scheme's first-class continuations, I totally would've just done Y,
> but instead I had to do Z, which was more of a pain."
> * "Scripting the build process in my Scheme project got
> increasingly painful as my source tree grew and I linked in more and
> more C libraries. For my next project, I moved back to Common Lisp."
> * "I have a large existing C++ codebase, and for me, being able to
> embed C++ calls directly in my Gambit Scheme code was totally worth
> any shortcomings that Scheme may have vs Common Lisp, even including
> lack of SWIG support."
>
> So, I'm hoping for war stories, rather than general sentiments like
> "Scheme is a simpler language" etc.
>
> This question was originally posted here:http://programmers.stackexchange.com/questions/41045/scheme-vs-common...
>
> Best,
> -- Matt
I'll ask the question I should have asked on programmers.stackexchange
here: Why do you need to know? Do you have a project that you're
considering using Scheme or CL for? Is the concern that you may pick
the wrong one after you get too far into it to switch in a reasonable
amount of time?
If you are considering using Scheme or CL for a major project, my
advice would be to try both. The two languages have very different
philosophies, so it's likely that one or the other will annoy you
pretty quickly. Then you can just go with the other.
Larry
Ok. It just seemed too strange if it hadn't it.
When programming in Scheme, I usually get a few nameclashes between
variable names and function names. I almost never get that in Common
Lisp. So when coding in Scheme, I miss the Lisp-2 "feature", and
packages/namespaces. That's actually the most important reason why I
mostly stick to Common Lisp. (There are more, but this is the most
important one.)
I also miss a more extensive set of iteration constructs. Programming
with "just" recursion is like programming in assembly language, I don't
want that.
Defmacro is also missing. There are cases where syntax-rules is too
simplistic, but syntax-case is a far too complicated alternative.
However, that's already a weaker issue, because syntax-rules actually
works surprisingly often.
There doesn't seem to be a good Scheme implementation that offers the
same breadth of support for symmetric multiprocessing as LispWorks does,
which is currently critical for my work.
When programming in Common Lisp, I sometimes miss reflective access to
the current execution stack. I sometimes wish call/cc were available,
although I'm convinced by now that call/cc is the wrong interface. I
think Smalltalk has a much more convincing story in this field.
I definitely miss a reliable way in Common Lisp to request tail call
optimization ("proper" tail recursion).
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
Selective quoting can always be used to distort what someone has said.
What you left out was the introductory phrase:
...what pulled *me* from Scheme to CL were things like these, all
nicely pre-compiled & optimized in any conforming implementation:
followed by a long [and incomplete] list of standard CL features,
*some* of which are also in Scheme, such as READ. [Quiz for the reader:
What other features of Scheme were also mentioned in that list (possibly
with different names in Scheme)? And given what is said below, why do
you think they were in the list in the first place?]
But even for READ, Scheme only offers you the choice of (READ) or
(READ port) [ports are like CL streams], and in particular Scheme READ
*doesn't* offer you a choice for what the EOF-value is -- in Scheme
it's *some* system-defined end of file object that can never be read
in using READ, but it's *not* specified what it is, and it's not
necessarily unique, that is, (AND (EOF-OBJECT? OBJ1) (EOF-OBJECT? OBJ2))
does *not* imply that (EQ? OBJ1 OBJ2) or even (EQV? OBJ1 OBJ2).
[And since Scheme has no exception system, EOF on READ will never
throw an exception.]
So, no, Scheme *doesn't* have CL's READ. Nor READ-FROM-STRING [though
the latter can be synthesized by WRITE-ing the string to a temp file
and then READ-ing from it]. Nor does Scheme's STRING->NUMBER have
CL's PARSE-INTEGER's :START/:END/:RADIX/:JUNK-ALLOWED options [though
it *does* read floats].
And that is really the main point of that 2007 posting -- that in CL
much more of the edge-case behavior is *defined* [though certainly not
all, as we know], *plus* much more of it is tweakable by the programmer
using *standard* options [e.g., :KEY/:TEST/:START/:END and the like] that
are reasonably pervasive [though, again, not uniformly nor completely]
throughout the language.
-Rob
-----
Rob Warnock <rp...@rpw3.org>
627 26th Avenue <http://rpw3.org/>
San Mateo, CA 94403
This situation has improved since then.
> But even for READ, Scheme only offers you the choice of (READ) or
> (READ port) [ports are like CL streams], and in particular Scheme READ
> *doesn't* offer you a choice for what the EOF-value is -- in Scheme
> it's *some* system-defined end of file object that can never be read
> in using READ, but it's *not* specified what it is, and it's not
> necessarily unique, that is, (AND (EOF-OBJECT? OBJ1) (EOF-OBJECT? OBJ2))
> does *not* imply that (EQ? OBJ1 OBJ2) or even (EQV? OBJ1 OBJ2).
> [And since Scheme has no exception system, EOF on READ will never
> throw an exception.]
Haven't found a need for any eof-object comparison or uniqueness. What
I don't like is that it is considered an object.
> So, no, Scheme *doesn't* have CL's READ. Nor READ-FROM-STRING [though
> the latter can be synthesized by WRITE-ing the string to a temp file
> and then READ-ing from it]. Nor does Scheme's STRING->NUMBER have
> CL's PARSE-INTEGER's :START/:END/:RADIX/:JUNK-ALLOWED options [though
> it *does* read floats].
SRFI-6 adds string-ports.
> And that is really the main point of that 2007 posting -- that in CL
> much more of the edge-case behavior is *defined* [though certainly not
> all, as we know], *plus* much more of it is tweakable by the programmer
> using *standard* options [e.g., :KEY/:TEST/:START/:END and the like] that
> are reasonably pervasive [though, again, not uniformly nor completely]
> throughout the language.
Scheme certainly doesn't have these many options but what edge cases are
insufficiently defined in Scheme? [A serious question]
> [And since Scheme has no exception system, EOF on READ will never
> throw an exception.]
As of R6RS at least, Scheme does have an exception system.
> > and then READ-ing from it]. Nor does Scheme's STRING->NUMBER have
> > CL's PARSE-INTEGER's :START/:END/:RADIX/:JUNK-ALLOWED options [though
> > it does read floats].
>
> SRFI-6 adds string-ports.
1:=> (string->number "100" 16)
256
Someone asks for a comparison of Scheme and Common Lisp and your only
contribution is this??
Okay, I'll attempt to answer Rob's first question but not his
second, using the following key:
not available (Scheme offers no comparable feature)
IEEE (it's part of IEEE/ANSI Scheme)
R5RS (it's part of R5RS Scheme)
R6RS (it's part of R6RS Scheme)
SRFI-n (it's part of SRFI-n)
EASY (base) (fairly easy to build from the named base)
- DEFMACRO
EASY (R6RS)
EASY (SRFI-72)
SRFI-96
- The almost-universal provision of :START/:END (and :START1/:END1/
:START2/:END2, when appropriate) keyword args on sequence functions.
not available
- MAKE-HASH-TABLE, GETHASH, (SETF GETHASH), & REMHASH
R6RS
SRFI-69
- Specialized vectors
SRFI-4 (homogeneous numeric vectors only)
SRFI-66 (octet vectors only)
R6RS (bytevectors only)
- multi-dimensional arrays
SRFI-25
- POSITION, MISMATCH, SEARCH, & SUBSEQ
SRFI-1 (for lists only)
EASY (SRFI-1)
- PARSE-INTEGER (in all its glory)
EASY (IEEE) (already provides number->string)
EASY (R5RS) (already provides number->string)
EASY (R6RS) (already provides number->string)
- CONCATENATE
EASY (IEEE) (already provided for lists, strings)
EASY (R5RS) (already provided for lists, strings)
EASY (R6RS) (already provided for lists, strings)
- COERCE
EASY (R5RS)
EASY (R6RS)
- MAP
EASY (IEEE) (already provided for lists)
EASY (R5RS) (already provided for lists)
EASY (R6RS) (already provided for lists, vectors)
- READ-FROM-STRING
EASY (R6RS) (already provides string ports)
EASY (SRFI-6) (already provides string ports)
- WITH-INPUT-FROM-STRING
not available
- FORMAT
SRFI-28
SRFI-48
SRFI-54
- WITH-OUTPUT-TO-STRING
not available
- LOOP
not available
- READ
IEEE
R5RS
R6RS
- Reader macros
not available
Will
> - DEFMACRO
> EASY (R6RS)
> EASY (SRFI-72)
> SRFI-96
Both Bigloo and Guile have define-macro, which is equivalent to
defmacro.
Yes, many implementations of Scheme go well beyond
the listed features. Since the part of Rob Warnock's
list that I addressed was limited to features provided
by every implementation of the ANSI standard for Common
Lisp, I thought it only fair to limit my list to features
provided by the IEEE/ANSI standard for Scheme or by one
of the more widely implemented de facto standards that
have built upon the official IEEE/ANSI standard.
Will
When programming in Common Lisp I miss the "Lisp 1" style of Scheme
where function values and continuations are stored in the same symbol
slot as other data values.
When programming in Common Lisp I do miss continuations sometimes.
When programming in either Scheme or Common Lisp I am happy and
relieved to have a full arithmetic stack, especially unbounded
integers and unbounded rationals. (Corollary: I miss that when
working in Emacs Lisp!)
When programming in Scheme I miss structures in a big way.
When programming in Scheme I miss generic functions.
When programming in Scheme I miss the richer set of standard functions
from Common Lisp - I hate reliance on SRFI's, though I'm sure glad
they exist!
When programming in Scheme I miss the portability of Common Lisp - in
Scheme I generally must rely implementation details (such as SRFI's)
so I end up sticking with one Scheme. I use several Common Lisps and
manage porting code pretty well.
When programming in Scheme I miss the more general "dirty" macros of
Common Lisp.
When programming in Scheme I miss the more general loading and
compiling (system building) of Common Lisp.
When programming in Scheme I enjoy using recursion as my interative
means(since DO is kind of crazy). But I miss LOOP because I end up
writing a lot more code at a more basic, decomposed level.
Does SRFI-1 mostly take care of that, by letting you write most loops as
folds or something similar? In Haskell at least, loops and naked
recursion are both code smells. There is usually a combinator (i.e.
something like map or fold) that does what you want to use the recursion
for.
> When programming in Scheme I miss structures in a big way.
SRFI-9 provides records.
> When programming in Scheme I miss the more general "dirty" macros of
> Common Lisp.
Bigloo, Racket, and Guile have defmacro or define-macro.
> When programming in Scheme I enjoy using recursion as my interative
> means(since DO is kind of crazy). But I miss LOOP because I end up
> writing a lot more code at a more basic, decomposed level.
http://groups.google.com/group/comp.lang.lisp/msg/3b9391273aceb7a5
NEAT!!
Except if you care about efficiency, or actually know how to use
loop and format...
I thank the gods for SRFIs - actually I thank a well organized
community!