Thursday, February 23, 2006
Emacs LISP for scripting
#!/usr/bin/emacs --script
This isn't that big a deal. I've known about the --batch switch for an age, but it signals a level of intent which caused me to search further and find out that you can pass custom command line arguments into such scripts (as you would with more traditional scripting languages).
Now ELISP isn't the nicest LISP variant out there, but in the domain of text processing it is unparalleled and it has the best IDE I've ever used (developing ELISP in Emacs is a joy!). Every time I think Emacs has run out of surprises it pulls another rabbit out of the hat. I can see a whole set of problems that fall into the category of "too hairy for bash, to long winded in python" where Emacs could be doing the heavy lifting.
Thursday, February 09, 2006
The road to PLT Scheme
However my interest in GNU/Linux grew during that same period and with it a more general interest in computer science. From these things and exposure to the downright stupidity that is prevelant in large amounts of the commercial software development world I developed a conviction that there must be a better way.
Following that convinction (and a strong belief in the importance of software Freedom) I found Ruby and started using it for a few things. Ruby is a great language, and I used it as much as I could. Eventually I managed to land a job writing Python code with Cmed. That kept me happy for a while, learning what python can do (which is a lot without much effort). Still however I find that python makes you do donkey work that you shouldn't have to. I can't have been alone in that view because by the time I arrived at Cmed there was already an in-house XML language used to generate vast swaves of python code via XSLT.
XSLT works, but it's akward and it doesn't sit well with python. The quoting issues in generating python from XML are less than pleasant to deal with.
I knew there must be a better way. What was needed was a language that could template it's own syntax. I couldn't think of such a language, until one day I started reading Paul Graham's site. From Paul's postings about Common Lisp and Arc I started to read around the subject a little and came across Practical Common Lisp by Peter Seibel. This book opened my eyes to what was possible with a language that I'd always written off as an archaic AI tool (an attitude they taught me at Uni!).
I've now been playing with Common Lisp and Scheme for about a year. In that time my thoughts on the subject have developed along the following lines:
- Lisp's in general are marvelous languages that allow you to use meta-programming techniques to work smarter instead of working harder (put another way, you might say macros are the templating tools I mentioned earlier).
- Most Common Lisp imlementations are more mature and/or complete than scheme implementations.
- Scheme is a much cleaner, modern feeling language than Common Lisp
The fustration then has been that I want to work in Scheme (Common Lisp carries too much cruft and legacy for my likiing) but I can't find a simple, stable implementation with a decent library and bindings for real-world things.
I've tried to work with Bigloo, it seems great, it reads well, but it's never worked reliably for me, and I can't get Biglook working at all. I've been working with Chicken for a while now - it's nice and straight forward and the eggs system is excellent. But chicken lacks a decent GUI toolkit. I've tried qthack (segfaults), sx (libsx doesn't compile), bb (OK, but over-simplified) and I'll not sink so low as to use tk.
This was all rather depressing, until I saw Falling off the wagon with DrScheme on planet-lisp.
DrScheme is the IDE environment for PLT Scheme. I'd played with DrScheme last year some time and decided I didn't like it. The introductory documentation is heavily orientated towards teaching Scheme using a particular text (How to Design Programs) that I don't get on with. What I'd overlooked is that the IDE is written in a very mature GUI library MrED and that it can do wonderful things.
So I've just started a new project and I'm using PLT scheme and MrEd. Most of the coding with still be done in GNU/Emacs with Quack mode, but from time to time I'll be firing up DrScheme to debug code, profile and generally benefit from the wealth of sensible, professional tools this environment provides. We'll see if this is finally the Scheme implementation I've been looking for.
Tuesday, January 17, 2006
I spent some time playing with Fedora Core 5 test 2 today. I did this principally because there are a lot of nice friendly scheme RPM's out there to play with and becuase the Bigloo package on Arch Linux is little broken in that it doesn't provide bee or any sensible way to install it.
Now I was in the Fedora community way back when Red Hat first spiralled out it's non-commercial distro, and I left that community because, despite using the word twice so far in this paragraph, the last thing it Fedora had was a "community".
Even though Red Hat is freeing it's grip on Fedora a little more now, I still see some big issues that haven't faded. What's so shocking about Fedora is that despite the obvious effort and polish that's been invested broadly in the OS some really fundemental parts of the distro are still totally broken.
YUM sucks. It really sucks. Sure it's a big improvement on RPM on it's own, but compared to apt, emerge or pacman it moves on a geological timescale, is annoying to use and makes upgrading packages a painful experience.
Wireless support also sucks, Fedora is one of the few distros I've come across that can't get an IPW2100 working with relative ease. Gentoo is another, the wireless configuration there annoys the hell out of me, but at least it works. Ubuntu, Novell and SuSe can all set the card up with only a couple of questions to the user. Arch leaves it to the user, but it's well documented and the config files are trivial. Fedora wraps it in a worthless GUI that thinks the card is a normal ethernet card and gives no sensible indication that I needed to go and hunt the web for a package.
Those things are a real shame, because between them they're going to keep me far away from a distro that really has got it's house in order around development tools, and can now boast a really nicely put together Gnome desktop with Mono support.
I could use Debian or Ubuntu of course to deal with the Scheme installations. Those distro are quite well supported from that point of view (or Gentoo if the wireless config didn't make me sooooooo angry). Instead it's back to Arch - the only distro that ever really fulfills me, and where I can knock up a new package in a matter of minutes and be happy.
I spent some time playing with Fedora Core 5 test 2 today. I did this principally because there are a lot of nice friendly scheme RPM's out there to play with and becuase the Bigloo package on Arch Linux is little broken in that it doesn't provide bee or any sensible way to install it.
Now I was in the Fedora community way back when Red Hat first spiralled out it's non-commercial distro, and I left that community because, despite using the word twice so far in this paragraph, the last thing it Fedora had was a "community".
Even though Red Hat is freeing it's grip on Fedora a little more now, I still see some big issues that haven't faded. What's so shocking about Fedora is that despite the obvious effort and polish that's been invested broadly in the OS some really fundemental parts of the distro are still totally broken.
YUM sucks. It really sucks. Sure it's a big improvement on RPM on it's own, but compared to apt, emerge or pacman it moves on a geological timescale, is annoying to use and makes upgrading packages a painful experience.
Wireless support also sucks, Fedora is one of the few distros I've come across that can't get an IPW2100 working with relative ease. Gentoo is another, the wireless configuration there annoys the hell out of me, but at least it works. Ubuntu, Novell and SuSe can all set the card up with only a couple of questions to the user. Arch leaves it to the user, but it's well documented and the config files are trivial. Fedora wraps it in a worthless GUI that thinks the card is a normal ethernet card and gives no sensible indication that I needed to go and hunt the web for a package.
Those things are a real shame, because between them they're going to keep me far away from a distro that really has got it's house in order around development tools, and can now boast a really nicely put together Gnome desktop with Mono support.
I could use Debian or Ubuntu of course to deal with the Scheme installations. Those distro are quite well supported from that point of view (or Gentoo if the wireless config didn't make me sooooooo angry). Instead it's back to Arch - the only distro that ever really fulfills me, and where I can knock up a new package in a matter of minutes and be happy.
Friday, January 13, 2006
I've just put new strings no my Taylor. It's 10 years old now and starting to sweeten up nicely. It's funny how just giving it a clean and some new strings makes it such and exciting and beautiful instrument every time.
If only everything in life was so easy to rejuvinate!
Why is that then when you set out to do something simple it always spins out to something more complex.
I started writing a small python app two days ago. It needed a database to store multiple records, each with the same three fields. To avoid mucking around distributing something like PostgreSQL I made use of python's anydbm library.
So there I am at 1AM this morning writing unit tests for queries framed as the intersection of sets of keys returned from an index mechanism of my own design. How did I get there... I don't think I'll ever know. I wasn't even drinking - or perhaps that was the problem?
Thursday, January 05, 2006
LISP is 48 years old this year (50 if go all the way back to it's inception). That's scary. It's scary that Jon McCarthy was so visionary, but from another point of view it's scary that programming languages have changed so little in 50 years.
From what I can see all that's really happened is that computer hardware has caught up with the ideas. LISP in 1958 was heavy and cumbersome, but today the "exiting new languages" like python and ruby are heavier and more cumbersome than LISP is without delivering any more power (indeed many people will argue that LISP and it's direct decendent, Scheme, offer more power than either python or ruby do yet).
What's exciting is that a larger development community is really starting to buy into some of the solid foundations that LISP originated when they see how swift and pleasant development with Python and Ruby can be. I'm even noticing that there are more and more young developers playing with LISP and Scheme themeselves. Just another sign that the increased communication and sense of community between developers that the internet age has brought about is truely changing the way we work.
They key to doing things the best way possible is to be exposed to the best ideas. Corporate environments don't traditionally expose people to those ideas - indeed corporate developers used to only get information about languages delivered to them via narrow channels controlled by yet more corporations.
Companies selling solutions found it all too easy to write off ideas coming from the university's as "Ivory tower". Just a few years ago I worked for a company who told me that languages like Python and Ruby weren't "business languages". Now I work for a business that uses Python as it's primary development language. No need to guess which company is the more productive.
A couple of years back Paul Graham said something inflamatory to the effect that if you code in Python you'll get smart developers to work for you, and if you code in Java you won't. That's a fairly extreme statement, and I realise it's become really fashionable to bash Paul Graham of late, but I have to say I agree with him. I have the strongest feeling that the average hacker from the LISP or Scheme community is a lot more productive than the average C# developer.