Showing posts with label Racket. Show all posts
Showing posts with label Racket. Show all posts

Saturday, November 27, 2010

GNU readline in Racket

My main operating system is Gentoo (2.6.32-gentoo-r7), which doesn't have the Racket programming language in its package repository, so I compiled it myself from the sources available on the racket website (another side note: Racket v5.0.1 won't compile if you have a newer version of libpng installed, but Racket v5.0.2 fixes the out-of-date function call). However, I ran into a slight problem when trying to install GNU Readline support by evaluating (require readline) in the racket prompt, where I was greeted by the following error:
ffi-lib: couldn't open "libreadline.so.5" (libreadline.so.5: cannot open shared object file: No such file or directory)
Which sounds rather foreboding, but fortunately has an easy fix. The problem is caused by a tendency of later GNU Readline installations to lack the shared object file named "libreadline.so.5", instead having a file named "libreadline.so.6", a newer version of the library. The simple (and as far as I have been able to tell, correct) fix is to modify line 11 in $RACKET_DIR/lib/racket/collects/readline/mzrl.rkt from:
(define libreadline (ffi-lib "libreadline" '("5" "4" ""))) 
to
(define libreadline (ffi-lib "libreadline" '("6" "5" "4" ""))).
Hope that keeps at least one Schemer from pulling their hair out in the near future.

Racket, a new Scheme

So over this Thanksgiving holiday I took the time to read through some of the Racket documentation, something I've been meaning to do for some time now. Racket, some of you may know, is the newest incarnation of PLT Scheme, the Scheme behind the old DrScheme Scheme IDE. As a LISP aficionado and sometime web developer, I was especially interested in the web server tutorial (found here: http://docs.racket-lang.org/more/), which doesn't take that long to go through and leaves you feeling accomplished with a simple, functional webserver. I personally worked through it and I plan on making it a little more fully featured during my spare time, perhaps even adding some elements of the MVC paradigm. I highly encourage anyone, regardless of their experience with LISP, Scheme, or other functional languages, to check out Racket (racket-lang.org) and broaden their programming horizons.

For another simple server exercise (this one in C), check out my friend Jeremy's blog at http://www.cores2.com/blog/?p=81.