association-list

October 29, 2006

More maundering on about Lisp.

no tags — evan @ 2:14 pm

One of the thing that makes CL a pain in the ass some­times is that there are a lot of strangely named func­tions spe­cial­ized for dif­fer­ent types of objects. The lan­guage has a tril­lion key­words and a lot of them don’t really help the lan­guage learner get com­fort­able with the lan­guage. As an exam­ple, iteration:

In the lan­guage stan­dard there are a couple of dif­fer­ent iter­a­tion con­structs, do, dolist, docount, and loop. Strangely, there is no doarray. It’s easy enough to write one:


(defmacro do-svect ((counter array) &rest body)
  (let ((ctr (gensym)))
    (dotimes (,ctr (fill-pointer ,array)) 
       (let ((,counter (aref ,array ,ctr)))
     ,@body))))
</code>
</pre>
That's all well and good, but it's a pain to have to write a macro for
each and every sequence type of thing that you have to deal with, and
while I understand why it isn't there, I don't understand why there
isn't some generalforeach` type of function.  It would be easy enough
to write, just a macro that detects the type of the sequence type the
function was called on that writes out the appropriate thing.  There
are a number of situations where this would help a lot, to the
beginner.  Just layer them as macros over the normal syntax and
keywords, which, of course, would all still be there if you needed to
do something more complicated.

Syntax, I think, makes things easier to remem­ber, because (and I’m the­o­riz­ing here) it calls in some other part of the brain than the part that we use to remem­ber vocab­u­lary, which is what we’re being asked to do with Lisp. I’ve never in my life writ­ten a line of Smalltalk, but I can remem­ber that their lambda syntax is some­thing like [ x y | x * y ]. I know very little Erlang, but I know that their binary pat­tern match­ing syntax is << x/integer, y/float >> = val. I’ve been read­ing about lisp for years and star­ing at it for ten of the last six­teen hours and I’ll be damned if I can remem­ber how to pass mul­ti­ple values back from a function.

Per­haps Arc will fix all of this, but I think that it would be of no little value to the Lisp com­mu­nity, and to those who want to learn lisp, if people started work­ing on a pack­age that every­one agreed to include and use with their dis­tri­b­u­tions (hah!) that made some things a little easier. It could be some­thing like the modern pack­age that comes with ACL. Hell, every­one could make their own and then we could give them six months, then put them all in a ring and make them fight and then make some­thing more or less agree­able to every­one with the parts that are left over.

Lisp is famed for it’s abil­ity to quickly gen­er­ate Domain Spe­cific Lan­guages, so per­haps it’s time that we bent that abil­ity towards a dif­fer­ent kind of domain, that of learn­ing the lan­guage itself. It might also point to the kinds of things that would be inter­est­ing to put into the next ver­sion of the spec, in the far-​​off, misty future when that fabled doc­u­ment is actu­ally generated.

October 28, 2006

Yet another bookshelf update.

no tags — evan @ 4:32 pm

Quiet lately. Rather busy at work, plus trips home and being busy with other writ­ing projects.

In other news, a few words on books that I’ve fin­ished recently.

Mist­born, by Bran­don Sanderson.

Though Elantris was a promis­ing debut, this novel doesn’t step it up as much as one might wish. Although it’s pretty nice in that it is another stand-​​alone book, for which I think Mr. Sander­son should be applauded, the writ­ing hasn’t grown quite as much as one might wish, and there is also second degree abuse of the word ‘mal­adroit’. It also doesn’t prop­erly address my com­plaints about the excep­tion­al­ism inher­ent in modern fan­tasy. My big gripe with the book is that, although it has its heart in the right place, with the people and all, it doesn’t really inter­act with them very much. Even the main char­ac­ter, sup­pos­edly drawn from the lowest of the low, seems excep­tion­ally clever and not beaten down as the skaa, the proles of this par­tic­u­lar word are called, would seem to be, and they’re more or less dis­pos­able and inter­change­able through­out the course of the nar­ra­tive. There is a touch of the rev­o­lu­tion­ary van­guard party ide­ol­ogy going on here, that’s some­thing that I’ve never been able to iden­tify with, although your mileage may vary, depend­ing on your polit­i­cal stripe and tol­er­ance for that sort of thing. How­ever, Sander­son con­tin­ues to pro­duce books that stand head and shoul­ders above stan­dard extruded fan­tasy prod­uct and take on the stan­dard tropes of the genre with no small amount of rigor and inventiveness.

Trial of Flow­ers by Jay Lake.

I got ahold of a galley of this one, which is coming out soon­ish. It starts out in the vein of novels like The Etched City (which I loved) and Veniss Under­ground (which I thought was inter­est­ing, but flawed), but lacks the ulti­mate sense of hope­less­ness that many of the novels of that ilk are afflicted by, and I think is made better thereby. It’s refresh­ing to see a blend of the world-​​weary and dis­af­fected char­ac­ters most tra­di­tional to the ‘new weird’ move­ment fused with some of the grand, sweep­ing struc­tural ele­ments of tra­di­tional fan­tasy with­out being over­con­sious of the effect, and I think that this is where the great strength of this novel lies. Deeper but more dis­tant than work by Mieville, who I would hold up as the modern exem­plar, I think that a lot of people will like this one, and also that it her­alds big things for Mr. Lake.

The Demon and The City, by Liz Williams.

I really shouldn’t even have to say any­thing here. The Chen novels just get more inter­est­ing in this iter­a­tion, and Williams just gets better and better. All told, I have to admit that I slightly prefer her ‘pure’ sci­ence fic­tion stuff, but these novels are a lot of fun, and I think that they’re much more acces­si­ble to a gen­eral audience.

Night Watch by Sergei Lukyanenko.

I thought that the film was decent, but I liked the book(s) quite a bit better. The movies changed the story around to create res­o­nances that I don’t think really needed to be cre­ated, and I think that the lost a lot with­out the con­flicted voice of the nar­ra­tor. The ending feels a little like a cheat, but the set­ting is inter­est­ing, and I hope that this one does well enough to get more Russ­ian con­tem­po­rary fic­tion and genre stuff coming out in English.

The Child Garden by Geoff Ryman.

Um. Wow. I just fin­ished this and I will admit to being more than a little over­whelmed. Ryman is, in my opin­ion, one of the top three prose styl­ists work­ing in the genre at the moment. My inner sci­ence geek is appalled, at times, with the treat­ment of some of the sci­ence, but that’s about the only crit­i­cism that I can level at this par­tic­u­lar work. The world depicted is simul­ta­ne­ously intri­cately sur­real and utterly quo­tid­ian, and I would describe it, at the risk of sound­ing Cluteian, as a fic­tive world with the heft of the Real. There are some dis­turb­ing ele­ments and some absolutely har­row­ing sequences. The book really sucks you in to the point where it’s painful to read some of it, but you cannot stop. I haven’t read all of Ryman’s novels, but with every one I am more and more impressed.

Sun of Suns by Karl Schroeder.

Two words, people: Air Pirates. This book, which is a smart little novel in the vein of the old pulp adven­tures updated for con­tem­po­rary sen­si­bil­i­ties, much like Para­gaea, by Chris Rober­son. It also has one of the cooler science-​​fictional con­ceits that I’ve come across recently: The entire novel takes place in a world sized ball of air lit by giant fusion radi­a­tors that the people call the suns. The entire thing is con­vinc­ingly well thought out, but Schroeder never lets the world build­ing get in the way of the action or the dri­ving plot. I quite like Karl Schroeder, and although this is one of his lighter books, I rec­om­mend it highly. Fun fun fun, and have the inkling that this par­tic­u­lar series is really going to go places.

Blind­sight by Peter Watts.

As I’ve said before, this one is a book that you need to read to even pre­tend that you know where sci­ence fic­tion is in this day and age. There’s likely already enough breath­less prose out there describ­ing it, so I won’t add much but to say that it’s a fas­ci­nat­ing exam­ple of how to make deeply, deeply flawed char­ac­ters engag­ing and com­pelling. Hell, in this one, the char­ac­ters are barely human (and not, in some cases) but you can’t really put it down. It is not a book with­out flaws, but it works in the “if you’re not fail­ing you aren’t trying hard enough” kind of sense. Watts might not have reached his goals here, but with the aim of the novel being hit­ting the ball some­where into the next state, I think that every­one could be con­tent with just a grand slam home run.

The Machine’s Child by Kage Baker.

I have to admit that this book annoyed me some­what, as the Com­pany sequence is still not over, and this book does little but set up the pieces for the grand finale. It seems to be that it’s going to end with an incred­i­ble bang (sup­pos­edly in the next and last book), but we’re still not there yet, so there isn’t a lot to say.

Her Smoke Rose Up For­ever by James Tip­tree, Jr.

This book makes me angry because I’d barely heard of Tip­tree before I picked it up. I have tons and tons of old year’s bests and col­lec­tions from the period in which she was writ­ing, but I don’t think that I’d read a single story from this col­lec­tion before, and that’s a crying shame. Many of the sto­ries in here are totally amaz­ing and deeply depress­ing. You will not find any­thing nice said about human nature, but you will find some really excel­lent prose, and the titles! Wow. You owe it to your­self to find a copy of this and read it. It is one of the build­ing blocks upon which modern sci­ence fic­tion is built (indeed, William Gibson owes Tip­tree a par­tic­u­larly large debt, only subtly acknowl­edged, as far as I know), and it’s ter­ri­ble that her work is more or less unknown to the modern reader (at least of my age group). Hope­fully the new biog­ra­phy will belat­edly bring her more readers.

Scar Night by Alan Campbell.

There was a lot of pre-​​release buzz for this one, but it doesn’t really live up to it, in my opin­ion. It’s a first novel, plain and simple, and doesn’t nearly have the depth or den­sity or reach of China Mieville’s sim­i­lar and, hon­estly, much better, work. Still, it isn’t ter­ri­ble and it doesn’t rule out Campbell’s work becom­ing of more inter­est in the future, although if I were Camp­bell, I would ignore the fact that the book claims to be book one of a series and write about some­where else for a while.

Memory by Linda Nagata.

I’m not all that famil­iar with Nagata’s books. This one isn’t ter­ri­ble, but it’s light read­ing. There’s some inter­est­ing stuff here, but for all that the ending costs a lot, you don’t really know all that much more when it ends than when it begins (I have a feel­ing that it was meant to be book one of a series that didn’t get writ­ten), and I don’t think that the losses, at least at the end, are deeply felt or affect the char­ac­ters very much. The world where the novel takes place is pretty inter­est­ing, and I feel like it would be pretty inter­est­ing to learn about what’s really going on there, but you don’t get there in this book.

End of the World Blues by John Courte­nay Grimwood.

In this one, Grim­wood con­tin­ues being uneven. Stamp­ing But­ter­flies was great, 9tail Fox inter­est­ing but less great, and this one falls into the latter cat­e­gory. You’re never quite sure what’s really going on or what the sig­nif­i­cance of the far future story thread is, and it never gets explained, or at least explained well enough to make me care. The best thing about this novel is the char­ac­ter­i­za­tion of the near-​​future thread’s pro­tag­o­nist, a broken, con­flicted loser who’s made some really nasty mis­takes in the past. For all that he fails to become com­pletely real at times, his story is inter­est­ing and car­ries you through the book well enough. I just feel that Grim­wood roman­ti­cizes the outsider/​pseudo-​​psychopathic male a bit too much. He has the chops to tell us a really inter­est­ing story, and he’s get­ting there. I’m bet­ting that in a book or two he’s going to make a break­through and write some­thing that’s huge and pos­si­bly quite impor­tant. I’m really look­ing for­ward to read­ing it, when it finally arrives.

Smelling the unsmellable.

no tags — evan @ 12:56 pm

So read­ing Karl Schroeder’s blog (one of them, at least), pointed me to Mixing Memory, which got me think­ing about cog sci stuff, which in train with read­ing about Scott Adams get­ting his voice back got me think­ing about sense per­cep­tion and pheromones. Pre­sum­ing that human have pheromones, we can’t con­sciously detect that we’re ’smelling’ them. I use the scare quotes because although the pur­ported pheromone recep­tors are in the nose, they are not the same recep­tors with which humans actu­ally process smells that we can sense. So pre­sum­ably we sense these things, but have no con­scious knowl­edge of smelling them. It is mooted that they might affect behav­ior, but that’s not really what I’m inter­ested in. So, assum­ing that these chem­i­cals arouse some response in the brain that’s uncon­sciously processed, it seems to me that one could then, in an exper­i­men­tal con­text, asso­ciate these chem­i­cals with other chem­i­cals or stim­uli that humans can con­sciously sense. Pre­sum­ably, this would then create some sort of con­di­tioned asso­ci­a­tion with the other stim­u­lus. Then, once the asso­ci­a­tion had been con­di­tioned, the observ­able stim­u­lus could be removed, and the effects of the ‘unper­cie­ve­able’ stim­u­lus could be mea­sured (e.g. the sub­ject could press a button when they thought that they ‘smelled’ the pheromone.). Obvi­ously I don’t have the knowl­edge or expe­ri­ence to design a proper exper­i­men­tal pro­to­col, and cer­tainly could not con­struc­tively inter­pret the results, but I think that it presents a unique sort of window into human sense per­cep­tion. Essen­tially, every­thing else that we have recep­tors for, we can per­ceive, although we might not do so all of the time. Pheromones seem to be unique in that we can sense them, but not per­ceive the sen­sa­tion. If it could be asso­ci­ated with some­thing that we could sense… I have no idea what it would mean, but it sounds like some­thing inter­est­ing to try.

Lisp is annoying.

no tags — evan @ 12:49 pm

So, the other day I was read­ing pro­gram­ming blogs, which seems to be the thing do do when you don’t actu­ally want to work, and I ran into Erlang’s facil­ity for binary pat­tern match­ing. Essen­tially it’s a rather nice syntax for taking a wodge (that’s a tech­ni­cal term) of binary data and decom­pos­ing it into vari­ables. So:

<< foo:8, monkey/integer, bazzle:16, arrr:4/string, rest/binary >> = packet

will get you ubyte called foo with the first 8 bits of packet, an unsigned inte­ger called monkey from the 9th through 40th bits, a ushort called bazzle, a 4 byte string called arrr (you could spec­ify fur­ther what type of string, I think, if you needed some­thing else), and a binary glob called rest with the rest of packet. I thought that this was pretty neat, and was think­ing that making a nice, gen­eral facil­ity for this in Lisp would make an inter­est­ing project, at least for me, because even though I know a fair amount about Lisp, I haven’t really used it that much. In any case, I was read­ing up about how some­one might go about doing some­thing like this when I ran into some­thing in Prac­ti­cal Common Lisp that was more or less exactly what I was think­ing of, expressed in a macro that really isn’t that long. it’s called define-binary-class and gen­er­ates the class and a con­struc­tor that will read in binary data in a sim­i­lar manner to the above. Plus, with some triv­ial mod­i­fi­ca­tions, I’m sure that you could alter it to make either struc­tures or classes and to nest def­i­n­i­tions, which is some­thing that the static syntax of Erlang cannot do.

This, to me, is the pri­mary virtue of Lisp, but it’s some­times frus­trat­ing that most things are so triv­ial in the lan­guage that there’s noth­ing to do as an intro but leap into appli­ca­tion code. This, per­haps, is one of the things that keeps people from get­ting into the lan­guage. You can do any­thing, but it’s either triv­ial or hard (or at least time con­sum­ing). Also, you’re for­ever doing things and then real­iz­ing that the mas­sive stan­dard library already has some­thing that does exactly that. And then there’s the con­stant impe­tus to refac­tor the code into some­thing cleaner, which the macro facil­i­ties of the lan­guage makes easy, fun and pow­er­ful, so the temp­ta­tion to cat-​​hoover away all of your pro­gram­ming time clean­ing up the code is pretty strong. That all of this is exac­er­bated by my lack of abil­ity to think of enthralling soft­ware projects to work on is, I’m sure, incidental.

October 5, 2006

Notice:

no tags — evan @ 8:54 am

I don’t have time at the moment to write about it more fully, but you should likely read Peter Watts’ Blind­sight right away.