[racket] Common Lisp or Racket?

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Wed Nov 13 11:37:40 EST 2013

On Wed, Nov 13, 2013 at 03:12:59AM +0100, Tomasz Rola wrote:
> On Tue, 12 Nov 2013, Hendrik Boom wrote:
> 
> > On Tue, Nov 12, 2013 at 10:56:09AM -0600, Lawrence Bottorff wrote:
> > > I'm your typical newbie who is hand-wringing over what direction to go in
> > > the general functional programming world. Lisp, Scheme, or Haskell?
> > > 
> [...]
> > > 
> > > I understand that Barski is slavishly following the "let's get real stuff
> > > done" philosophy, but I'm not up to speed with functional yet to even know
> > > what's going on. Is your "Realm of Racket" better at this? I feel like I'm
> > > spinning my wheels at this point. . . .
> > > 
> > > LB
> > 
> > I should mention that another, quite different approach to functional 
> > programming is the language OCAML.  See http://ocaml.org/ for details.
> > 
> > I program using Scheme and OCAML as high-level languages.

Well, actually, I also use Modula 3, that's a copletely different kind 
of language.  And I have some code in C/C++ as well.  My code in those 
languages is hardly functional at all.

> I may be very much wrong, so I cowardly apologise in advance, but I 
> happened to subscribe to certain Haskell related NGs just in time to 
> witness, kind of, interesting exchange there. In short, some 
> incompatibilities were introduced into ghc (AFAIR) and this rendered some 
> (a lot?) of working code uncompilable.

OCaml is not Haskell.  Not remotely.  Ocaml is *not* a vehicle for 
research into lazy evaluation of purely functinoal code.

> I did not follow it to the very 
> end, because at one point I simply lost interest. The tone I remember was 
> "what, they can't update their code to agree with new compiler - too bad, 
> let's drop the ballast and move on". My conclusion was, Haskell was still 
> in the making. So if I decided to use it, I should be prepared to rewrite 
> my code from time to time. And this is exactly the thing I hate - I hate 
> rewriting the code, be it from one language to another "cooler" language 
> or from dialect to dialect or from one program fragment to another. I 
> really appreciate attitude of gcc compiler, which, at least in theory, 
> allows me to compile very old code without a problem [1].

Except gcc does try to keep up with the C standard, which does get 
revised now and then.

> 
> I'm not sure if Ocaml is more like gcc or more like ghc, but I decided to 
> learn it rather than H*.

It's an applicative language with some imperative features.  I'm not a 
masochist; I use the imperative features when appropriate.  If you want 
to look at something I wrote last year, I entered the liberated pixel 
cup challenge (http://lpc.opengameart.org/) last year with an attempt 
at a video game.  I spent the month I had (re)learning OpenGL, learning 
Ocaml, and putting together something that actually ran, and can keep 
me amused for maybe five or ten minutes.  I didn't win the liberated 
pixel cup, nor did I expect to.  My code is available at 
http://topoi.pooq.com/hendrik/dv/free/fun/wander/index.html
Have fun.  You'll need some obscure development libraries to run it.

> 
> As of Racket vs CL, I think they are very comparable, with CL's one leg 
> stuck in prehistory (the filesystem concept scared the bejesus out of me, 
> almost) and Racket being modern and a bit alien to me, who licked (shyly) 
> Dybvig's book in times of R4RS... But, the docs are great, so I can 
> actually fire up drracket, google for some pointers in the docs and write 
> code in, say, quarter hour or a few. Batteries included, thanks a lot for 
> them :-). So for a beginner, Racket is a very good choice. Ability to use 
> some Scheme introductory material, complete with real R5RS mode (it is 
> fully compatible, isn't it :-) ), is great bonus, because it allows for 
> more choices - I am trying to tutor my sister (already graduated, so 
> English and logic is not a problem), and the choice of first intro book to 
> programming is crucial. SICP have just been toppled down, now I am on the 
> look again :-).
> 
> (OTOH, I'm not sure if I'd want to write compiler in Racket. Maybe. For a 
> while, I want to use both CL and R* and see what happens.)

Scheme is a lot better than many languages for writing a compiler, 
actually.  I'd certainly prefer it to C or C++.  Recently I've noticed 
compilers being written in OCaml, which seems well-suited to it.

> > By the way, I don't do exclusively pure functional programming.  Most 
> > of my code is functional, but I use imperative mechanisms when 
> > apppropriate.  I consider that building real systems as pure 
> > functional code is extremism bordering on masochism.
> 
> Yes. One more reason to rethink using Haskell, I guess... Pure functional 
> looks cool in theory and blogs but in every day get-stuff-done it might be 
> not so cool and pure anymore, at least in my case. Besides, I understand 
> that the need for monads makes it dirty functional. So I play it safe. Of 
> course I don't mean Haskell is bad or wrong choice. It just is not the 
> best choice for every problem, but I guess I will learn it, some time 
> later.
> 
> [1] I wanted to quickly prove it with some code I downloaded in 1995, but 
> gcc complained about "redefined identifiers" and stuff, so in practice 
> some rewriting is required here, too (yes, I gave it "-ansi" but maybe 
> there is some more options to experiment with, maybe I will).

A lot of people use gcc with -Wall which is quite helpful for catching 
bugs.

> Regards,
> Tomasz Rola

-- hendrik


Posted on the users mailing list.