Older blog entries for Ohayou (starting at number 4)

21 Feb 2005 (updated 21 Feb 2005 at 02:25 UTC) »
Javascript tip of the day:

For all the annoying cases where javascript gives you an object with numeric indices but which isn't a proper Array object, you can upgrade it to become one using Array.prototype.slice.apply(object) It's more cruft than had the language already provided us with true arrays (in cases like the arguments variable bound in functions, the window.frames list and the various arrayish return values of numerous DOM methods, to name a few), but it's one less needless javascript level loop to do the transition.

And why doesn't javascript come with your basic set of higher level methods like mapcar and friends? Sure we can cook our own, but it's as if the language tries to imitate a blunt stone age axe, when it's capable of being a real power tool, with just a few touches here and there to get a proper class library. (Is this some misguided attempt at making the language more graspable to a web developer in diapers?)

On Geek Nostalgia and Fatherhood

Sometimes I miss my more active days on the web, and wish I had a blog and spent more time doing random hacks for fun, and silently publishing them where someone sooner or later might drop by, catch on, embrace and adopt them for their own joy. I suppose most of the toys I played with at the time never did catch on and spread, but my first published scriptlets gained a happy crowd at the time and a few survived, sometimes just as ideas, but to some limited extent the code did not even rot with time.

The one thing I did in those days (late twentieth century), though, that still spuriosly returns to me like some magical boomerang through time, is the 404 page I made myself. It's a tribute to Doglas Adams (while he was still alive), where you get a page where a Marvin travesty sulkily types away at the visitor in a text field about how awfully sorry he is not being able to serve that particular file, and how generally sad it is to be a forgotten-about manic depressive web server yadda yadda yadda. You got the gist of it I'm sure. I put it there, and mostly forgot about it. At least until it started spreading to other poor web servers. They were catching that manic depression like the flue. And it was great fun to behold. (In a warmly kind of way, bless their poor souls.)

At first, I got a fan mail or two about it, but since I had not left any notice about crediting my work in the source code, or visibly for that matter, or indeed any reference to myself at all except for my webmaster contact link, the replicas were untraceable back to me and started a life in the free all on their own. I think I once contacted some website admin that had credited his 404 to himself, or maybe asked for feedback on it or something to that effect, curious about whether he received any, but decided to let my baby take on whatever niches he'd find himself without my fatherly eyes on him.

He still pops up here and there, but by now it's just a skeletal heritage -- few are the instances that stay with the original message (I'm quite sure mine was monospaced rather than using a proportional font), but on studying the code, it's always very obviously still my code. My type_text() method, the Javascript 1.0 safe code and all the rest, intact. Some change a few of the speed and delay variables I left behind, most add some message of their own, some make stylesheets to improve (or ruin) the teletype looks. Today a very tasteful example caught my eye, and again got that nostalgic feeling to find its way back to me, like so many times before.

I just did a google search for some of the code bits, and found about a hundred pages, some from tips and tricks sites offering tutorials on how to customize and use the code on your own pages, some explaining in German how to do it, with very nicely annotated source code, one substituting the textarea for a div tag, missing some polish to get newlines to work in the switch, one rather close to the original, but also pointing out that Douglas Adams has died.

I wonder if and how some note about me in the source would have changed how this play with words, code and web standards would have swept across the globe. Maybe I would have seen more mail traffic about it. Probably both in the form of the kind of joyful notes I did receive, and in the form of questions on how to adopt it and get it to run for some particular target environment. I suppose I would not have been much happier with than without that feedback, or perhaps felt bad about not responding to much of it. It is still a lot of fun to occasionally be reminded about it on random encounterns -- it's the kind of thing friends or net acquaintances occasionally tend to smile at, spread among themselves and end up broadcasting my way, too, unknowing of my relation to the code, and it is still about as fun as the first few times I saw it. It is the really simple ideas that tend to live long. The same thing applies to my scriptlets for comfy web navigation; they, too, show the same signs. In very rare cases, a complicated tool it takes hours to craft, will still be useful long afterwards, but mostly it's the small and simple ideas that live on.

If (or should I perhaps more likely say "when") I ever do a fun thing like this one again, I think I will make all the paramaters broken out of the code for easy customization. In the world of the web, the precious few who know programming are most frequently also the precious few who do original work. In a way, I think that gives us the responsibility of making our work easily reusable by the masses. I'm sure that is just as appreciated as the idea itself to all the smiling visitors out there. Of course, we can rigteously selfishly also ignore this Someone Else's Problem and do just as well, ourselves. But it's not really my style. If something should be worth doing, it should be worth doing right, and while I might be able to live up to that standard with my own work, when other players get in to the picture, I can only make it so much more or less likely that they also will. I think I prefer giving them an easy climb, if it doesn't cost me too much.

Oh! One more thing.

I'm so depressed.

15 Feb 2005 (updated 15 Feb 2005 at 02:40 UTC) »

After reading A Conversation with Alan Kay, I got curious about the programming language Squeak, and its Smalltalk heritage. While the interview does wave past the most interesting bits, it did toss out a few interesting thoughts worth lingering at. Just like how it would have been well off to linger more at some unstated topics. For instance -- assuming neither Intel, Motorola nor "any other chip company" know the first thing about microprocessor architecture excellence (not an entirely improbable statement to hold some amount of truth) -- please back that up with some in-depth discussion about what was in fact so good about the B5000 design.

So in sifting through the article, the most thought provoking statement was not much on the topic of tech stuff, but on culture, and pop culture, in particular. While I have not to date thought of a programming subculture as pop culture, it obviously has been since the home computing boom and probably will stay so, if not indefinetely, then at least for as long as the world of programming has any amount of romance and intriguing possibilities about it to offer the youth. Kay's observation "Once you have something that grows faster than education grows, you're always going to get a pop culture" struck a chord in me, in formulating why Perl, PHP, Java and mostly any other lesser weasel so easily and seemingly randomly get wide spread and recognized at the expense of better options, that are almost always on offer. The little perfectionist in me has festered on the subject for a fair amount of time, failing to make the connection to schools and learning institutes, despite actually aiming for the teaching profession myself.

Pop culture isn't about quality, but of perceived quality. It takes a working knowledge of a field to find and judge quality, filtering away lack of quality at a glance. Or, as Harry Järv (wise keeper of many books) stated it: "to learn to appreciate quality [in books], the only way is to read a lot". Quality or junk; without taking it all in, you won't get any frames of reference to relate to, and you will end up embracing something on random merits when browsing through your options. It applies just as well to music, as to books, art, or indeed the art of programming.

To get back to the article, though, it did rouse some curiosity about Squeak, and after a brief microfrustrating search navigating the site for a language specification, or any kind of related facts about it, I ended up with some overview outlining some history and theory of both languages. After some initial (mandatory?) waving of e-wangs and similar territorial marking rituals, the document lets the prestige levels fall to constantly berating C++ (or Java) in talking about how Smalltalk and Squawk do things instead but in a less smelly fashion. Fair enough; the document probably loses a few readers on making skirmushes of every difference between favourites and the unknown player, but in not being too attached to either target, impact was limited on my part.

I suppose this attitude is one of the random factors limiting the spread of Squeak, that I think the Python guys have addressed much better. At least my gut feeling says the Python people manage to strive for excellence and adopting raisins from other camps without making enemies this way. Of course this article doesn't have to represent the language camp's disposition, but those kinds of attitudes unnervingly often spread from a source deep within the group and then stay cemented. Let's hope this isn't the case, if Squeak is indeed something worth more than a brief surveying look. I'm not convinced yet, but have only covered half the intro too.

Kingdom of Loathing

Today I made another KoL scriptlet, a variation on a theme I did ages ago, this time customized to just make generic KoL scriptlets. Yes -- a meta scriptlet, designed to automate the creation of other nifty scriptlets. It will arm all forms, to, when submitted, present the user with a scriptlet that does that, when invoked. Any form will do, but to work outside of the kingdom it needs some tiny bit of rewriting, since it assumes that it's frame two that holds all the action.

It's based on a hack I seem to have thought out before the Millennium -- archive.org still holds a copy of my bookmarklet page from those days. I'm not sure it works very splendidly in modern browsers -- when I tried it, it seemed to have some trouble recursing through all frames, but I suppose archive.org might have caught a buggy version of it before I fixed some minor detail.

Anyway, it was a good recap. I hope some people will find it the best thing since... ...well, I don't know. My first KoL scriptlet hack? :-)

Hack mode has recently paid intermittent visits, after some time of dense inactivity on the computer front, being in a human oriented line of work since a month or two. It's a welcome change from the life I used to live, with both life and work in the geek community. Also, it was a welcome return to hobby hacking for the sheer fun of it. It's easy to forget how to have fun when you work with something for salary.

But enough about life. I've been playing Kingdom of Loathing for perhaps a quarter now, and while the joy of playing declines a bit once you have done all there is to do (it's a traditional mud, in an HTML suit, without wizards but with a healthy twisted humour, both linguistically and graphically) I seem to stick to my gaming tradition of finding other stimulating ways of expanding gameplay.

The past week or so, I've been hacking about at little more or less helpful scriptlets (okay, I think the term that won the audience was bookmarklets, but I prefer the shorter term) to do this or that more conveniently. Such as repeating an action for a number of times, which was my first stab at making boring manual labour go away.

Next in line, I made a useless hack or two (this one, for instance, will use some default item in combat, like the dictionary or the meat vortex similarly), and then I helped out a few friendly people in the clan (can a multiplayer game be without them?) with boring tasks, too.

Yesterday, as randomness had it, I advanced to something a bit more complex than the mere repeated form submittal or URL loading, in putting together a hack to search out users in a roster. I got something rather crude working after a full three hours of work, most of it lost in trial and error hacking trying to figure out ways of doing load event callback oriented triggering of the next pageload. I was too absent-minded and tired to actually get something along those lines working though, until this morning, when I gave it another stab. With a helpful hint from Andreas Lange about cooking a frameset around the page to load, and give the frameset an onLoad property that will invoke a callback, I got it to work the way I intended from the very beginning.

That feeling is rewarding. Even if it's just putting your mind to solving needless problems put up by a just barely general-purpose scripting language such as javascript. The joy of overcoming limitations has always been high on my list of sources of joy, pride or play, had I had one.

Almost the same joy as a few weeks ago, when I took down one of the fairly long outstanding bugs in AIDO (with very abundant help from Per) where metadata would get out of sync between the local medialibrary (where it broke) and the metaserver, upon joining productions. Nailing that misfeature really made my day, or night, as it were. ...I wonder when we'll see the next AIDO hack session; it's been a while again, now.

Today I sat down for a long time, spending even more time on reading up on what little has happened on the javascript front since I left the professional web a year or two ago. Not in general, but to solve the specific problem of getting a callback run after a form has been posted and the result has come back. For a while, I thought I might have struck something, on finding the W3C standard for events -- for once something potentially really good come out of that corner -- but I couldn't put it to use seccessfully for my specific application. Or, at least, didn't manage to. I want my scriptlet to post a form, get a callback, and continue chewing on the result page once it's back. The frameset technique does not lend itself to the problem, and the promising [element].addEventListener('load',callback,false) did not seem to do my bidding either.

Not that there's anything wrong about that particular system -- it's obviously great for doing these things when you can inject the code into the pages themselves (tried that, quite successfully) -- but I would have been glad to see it work if I set the listener to trig on load on a frame I posted a form in. But no such luck today.

I did, however, engross myself in the joyful study of a few sites covering scriptlets (nodding recognition for most techniques I had already found myself, except perhaps the space conservatory technique of putting the pascalesque with(object) syntax to good use which was not covered), event models (great thoroughness and clarity) and, mostly by chance, the Friend of a Friend project.

That actually surprised me somewhat -- the Semantic Web finally being put to some luser appealing purpose. Luser, here, referring to anyone not drooling about the wide prospects and dazzling possibilities offered by RDF, OWL, inference engines and XML Namespaces. That is to say, most of us. My ex employer, the easily loved Uwe Aßmann, was not one of these lusers. Unfortunately (well -- I'm not very sad, to be quite honest, but then I wasn't converted, so that opinion falls short) he did not happen to convey the glory of it to me, at the time; I mostly saw all the Really Hairy muck Martin and Leif were battling with, in making Pike the first scripting language of the Semantic Web. To make a long story shorter, I think the FOAF project, once it gathers some steam, might actually do the SWEB people more good than anything else they have mustered to date. For kicks, I made my own FOAF entry.

But truth be told, RDF still looks thoroughly dreadful. It won't ever (or at least I so hope it won't) be the hand tweaked mess HTML became. Perhaps that is actually a good thing.

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!