Monday, June 23, 2008

Blogcraft

Obviously I'm not all that terribly good at blogging my thoughts. As I read over my previous posts my cadence is a little stilted, and perhaps my sentences/thoughts are a little too short. I've had this problem in English class before... nervousness stifles my natural loquacity, turning my ordinarily copious verbiage into short stabs of talking. Once upon a time I was a much more eloquent writer I think, but I cut away too much of the fat and now I'm getting kindof lean. But it's never too late to change, and I think (since I have nothing else to do) I'll blog more often and try to perfect my communication skills (though as of yet no one is reading my blog).

Guis

GUI code is the most tedious unsatisfying code ever. It's totally ironic that it's also maybe the most important part of the application; that's if you're planning on showing your work to non programmers. No nontechnical person cares at all how elegant or wonderful or useful or powerful your program is, if it's not wrapped in a nice flashy buttoned, color-gradient happy gui. I'm cool with the command line and a nice log file, and probably so is the hacker next door, but Joe consumer wants his menus and his checkboxes, and if I'm to get my work any attention at all I must satisfy his eye's opprobrious lust for doodads.
Even worse than the basic need for GUIs, is the fact that the APIs (on the Desktop) are all sequential, imperative, spaghetti. Swing is the quintessential java example: the API is complicated, you're encouraged to violate MVC, and there's no telling what the GUI looks like from staring at the code. At least in HTML you get an idea of the general layout; in swing you get nothing but pain.
I've been looking for alternatives to Swing. I like the look of JavaFX, but it's not out yet. I saw something called Rebol, but the language is proprietary and I don't see any hooks for tying it into the JVM (which is a must for me, cause I need my libraries). Anyway, I figure the best solution is probably some XML templating thingamabob that lets you write your swing code declaratively. Right now though I'm too discouraged, so I'm slacking off and blogging.

Sunday, June 15, 2008

Lisp

My latest thing is lisp. I tried picking it up about six months ago. I read part of Practical Common Lisp, and implemented some of their examples, but I didn't really get the point, and the fact that it was a whole different platform from the JVM turned me off. After all, what good is syntactic sorcery if I can't have my favorite libraries? No good.
But I a week or two ago I was reading Ola Bini's blog and he mentioned a dialect of lisp on the JVM called Clojure. I decided to try and learn it; which for me means using it in a project. So far I'm not quite sure if I like it. It's totally non object oriented. The guy who created it specifically stated that he thought OOP was the wrong way to go, and that pure functional programming was much better. Having no objects has thrown my code-sense off track. I'm finding it difficult to judge whether my code is good or not.
What's been nice though is the whole syntactic abstraction thing. It's shockingly easy to do metaprogramming in lisp. That's part of what I had been reading about it: that it was the original dynamically typed, garbage collected , dsl friendly and metaprogrammable language. That's pretty amazing considering it's over forty years old. Java, which is the language I associate with garbage collection, only came out like fifteen years ago. And languages that offer strong metaprogramming and dsl support like ruby and python seem only to have become popular in the last few years. Maybe lisp was just way way way ahead of its time, and still is.
I admit it was hard to get past the parenthesis at first. They honestly just don't look good. But they stopped bothering me after I spent some time with the language. I think that happens with just about any weird syntactic feature of a language: you get over it and stop seeing it as soon as you are used to the language. Essentially, besides overcoming the parenthesis, I've just been exploring the features. Clojure is interesting not just for being a lisp dialect, but for it's strong concurrency support. That's probably going to be its selling point if it ever gets wide adoption. I think it's probably unlikely to see too much light though, since though everybody admits lisp is the ultimate language, they all seem to think that it's utterly impractical for the typical programmer. Personally I think the malleable syntax is great; it's just the absence of objects that gets me. How am I going to structure my programs? Where are the nouns? How do I group functions together? I'm sure I just need to find some more material on how to do functional programming right.
Anyway, I like this whole notion of polyglot programming: that different languages can serve distinct purposes in a single program. I'd imagine you'd want to use Clojure to handle concurrency, with all its STM magic, and something like python or ruby to do the business logic (at least then you can have objects.... sheesh). What's most certainly the case is that though you'd want to be running on the JVM to get all those hot libraries, you'd certainly not want to be programming in Java.