Those of you who were in the ECR at all during the NFQ/Incident ### game may have noticed a black laptop on the west facing wall (that nearest to the directors office) which had some nice green text on a black backdrop that updated itself pretty infuriating slowly :) That was one of mine, and something I really had some fun putting together, although it was all a bit bodgey internally. So this is going to be a walk through a download of that anyone thinking of putting together something similar can see some of the weird tricks I used, I’ll also be talking about lessons learnt from the event and things I’d change next time.
So this evening I was making a bit of junk data to time function runs over in Lisp, and for a gag I wrote it in Perl and raced the two of them. Shockingly Perl lost, so the question is, what am I doing wrong with it.
Well thought I’d better write something proper since I’ve dropped off the map rather. I’ve finally finished (at least mainly) a big chunk of work I’ve been doing for a long time (the distributed trust stuff) and hence I can actually relax now and have a proper weekend without thinking of it it, which’ll be nice. It has rather been eating my brain lately. Anyway, some of you have heard me rambling recently about the use of coding trances so I thought I’d write a little ramble about that.
Ahh yes I have indeed been partaking of quite a large volume of functional kool-aid lately, its quite scary. This week I’ve mostly just been doing lisp, lisp, lisp, and more lisp. In fact I don’t think I’ve touched Perl this whole week long, which is weird.
Still its been a good time, I’ve grappled with CLOS (let me fetch my crack pipe) and won the functionality I wanted, I’ve started to do more experimentation with some of the finer points of the whole style of coding itself.
For example, let me for a moment take you on a waffly journey around my criteria system (EDIT: Its probably worth knowing that I’m writing software that searches a graph of nodes and looks for suitable paths between any two nodes), for judging if a path has the right metrics/length/whatever to be acceptable.
We start with (make-criteria-pointer), this takes the name of a function and the arguments to pass to it, and returns a pointer to a function that takes a single path and runs the original function/args against it, returning true or false.
While that sounds a bit confusing, let me break it down for you, I’ve got a function for juding if a list is too long, which looks like this:
(defun max-length-p (path n) "Accepts a list-of-nodes (path) and an length (n) and returns T(rue) if the list is shorter than the length" (if (<= (list-length path) n) T nil))
So if I run
(make-criteria-pointer 'max-length-p 5)
it returns a pointer to a new anonymous function that looks like this:
(lambda (x) (max-length-p x 5))
i.e. it always checks to see if x is longer than 5 items long.
Now this doesn’t seem to be too useful, however there are simple ways to build a list of these function pointers, so if I do the following:
;; Maximum path length is 5 (new-criteria (make-criteria-pointer 'max-length-p 5)) ;; Path must include one of the nodes foo,bar or baz (new-criteria (make-criteria-pointer 'path-must-include-p '(foo bar baz))) ;; The minimum level of trust between nodes is 10 (new-criteria (make-criteria-pointer 'metric-p '("trust" 10)))
Then new-criteria keeps adding these function pointers to a list (called *criteria*, although you can tell it to add them to another list), and now if you say:
(check-path-p path-to-check *criteria*)
It will go through the list stored in *criteria*, passing path-to-check to each one of these functions and if the list doesn’t pass muster then check-path-p just returns false.
metric-p is also a generic checker of numeric (or other) values on links in the path, and so you can make it do crazy shit like this:
(metric-p path-to-check '("bananas" "plenty") :test #'(lambda (x y) (check-number-of-bananas x y)))
And it’ll dig up the “bananas” value about each link in path-to-check and instead of just checking this value numerically it will pass x (the value from each link) and y (“plenty”) into the newly defined function (lambda is an anonymous function), which will call check-number-of-bananas on these two values to determine if the link has “plenty” of bananas.
Now I’m sure there are plenty of other ways of doing systems like this but frankly Lisp can be deeply satisfying to write this kind of thing in. Once I got the last bits of this system in place this evening I left work pondering ways to improve it for speed or functionality, and have a list of three/four more things it could do by the end of Monday to complete it.
Just so damn shiny!
I came across this a while back whilst googling about for something or other related to that fun language at which I suck (LISP), and I’d almost forgotten about it until a discussion on the sickness of Python this evening reminded me. And so now I present Casting SPELs in LISP. Fun for all the family.
[ Edit! And while I’m here I may as well MLP to: Buster Wilde because its well funny. Ahh go on admit it. ]
Well I felt knackered today, and had a fun meeting with my Supervisor were we agreed on 2 things.
A) I’d missed the really fine conference for my architecture paper.
B) If my security paper isn’t up to snuff I’m going to get eaten alive at a security conference.
These coupled with C) They won’t accept my Thesis without papers being accepted by the outside world because they have little idea what I’m talking about leads me to conclusion 1.
1. I sometimes really wish I wasn’t part of academia. To be fair at times I wish I wasn’t working in any technical post so I could be an elitist git with my own systems and whenever someone says “Hey I’ve got this problem with X” I can just laugh in their face.
The whole business of writing papers and getting them into conferences before I’ve really got any results to discuss just grinds me down, I fear with no proper data (read: a working chunk of software and some good results from poking it) I’ll get ripped apart quite soundly. Or at least I should. It just feels like a backwards method of doing things.
Still it reminds me, I had a conversation the other day with someone about programming, they asked me if I wasn’t afraid I would one day get tired of it.
To me thats rather an odd question, it seems that hacking about with code and systems is a continually growing problem. Sure I may one day get tired of writing dull code for cash but getting tired with programming and faffing systems? Seems a little unlikely, although I may one day get distracted by other things in life more than I’d like, but then there is never enough time to do anything with enough concentration and practice in my experience, you just have to balance things.
It seems rather like asking a writer “Aren’t you worried that you’ll get bored of writing?” I mean they may get bored if they’re knocking up text to pay the bills for any-old reason (blurb on things, dull step-by-step instructions, reviews of flowerpots for “What Pot Monthly!” that kind of thing) but to suggest they’d get bored of combining ideas and things in a changing and evolving state seems just strange.
Or perhaps I’m just young and silly, time shall tell. Still after a batch of good productive writing, a film and a nice dinner courtesy of housemates I’m feeling more confident about the whole thing. Perhaps I can get this PhD afterall.
(p.s. Wow, my first bit of angst on Livejournal wasn’t it? Lawks I feel like a proper person-who-updates-their-homepage-with-a-nice-interface).
Well an interesting day of this and that (mostly writing documentation) however it lead me to ponder some interesting ponderings, of which I will now offer three.
Firstly (although last in chronological order) I went to a talk today (it was really rather good) about various parts of Celtic stuff, and the issue of Taliesin of the Mabinogion was discussed. An interesting character whose changing of shapes, melting through various forms until he becomes nothing at all, and then final rebirth as a better being seemed quite interesting and made me ponder if I could rip that off and use it. We shall see.
Secondly (again working back chronologically) I read an interesting rant today. The Tour de Babal by Steve Yegge a writer with a style close to the kind I tend to achieve myself (unless I’m pushing myself to more presentable and objective works) with a good quick run down of a number of programming languages. Although I fear he drank the Emacs kool-aid I am interested by several of his statements, and he includes the following wonderful gem:
I could probably name 20 or 30 languages that are “better” than Perl, inasmuch as they don’t look like that Sperm Whale that exploded in the streets of Taiwan over the summer. Whale guts everywhere, covering cars, motorcycles, pedestrians. That’s Perl. It’s charming, really.
But Perl has many, many things going for it that, until recently, no other language had, and they compensated for its exo-intestinal qualities. You can make all sorts of useful things out of exploded whale, including perfume. It’s quite useful. And so is Perl.
— Steve Yegge
Simply wonderfully descriptive text :)
Thirdly (and the first revelation (again, I’ve had it before but never written about it) of the day) was when I was browsing my awesome selection of morning Webcomics and that they form a new form of Soap Opera for the webby masses. Perhaps not intrinsically designed to do so but effective in shifting adverts with readers being hooked onto cliff-hanger story-lines by the authors. Or at least thats one way of looking at it.
Regardless, enjoy, and comment on anything deemed comment worthy.