FAQ update

Just a warning about @defs not necessarily being a good idea, some code from Mike Ash to add polish to the forwarding example and…um…I’m sure I added something else. Oh yes, the fact that _cmd is the name of the SEL argument in method definitions.

I’m quite inclined to refactor the FAQ (because the source is basically the XHTML), as something like a DocBook FAQ Article, which might explain any (further) hiatus in updates. I haven’t started working on this yet but it seems more attractive, as I look at the horrendous car crash of formatting produced by a combination of different text editors I’ve been using.

Posted in objc faq docbook | Leave a comment

Why Java is so damned lame, part exp(I*M_PI)

Gah. Back when I used to work for Oxford University, I had to do the occasional bit of Java programming for a WebObjects app. Being quite a bit more familiar with ObjC than with Java, I always found this a bit of a headache…partly the way Java Foundation is semi-bridged with the "real" Java API meant I was constantly referring to my Tiger book (Java in a Nutshell, not Mac OS X Tiger), and partly because ironically Java required a lot more mystical casting voodoo than ObjC…seriously, if I never see the phrase Session session=(Session)session() again, I’ll be a happy man.

Today’s "gah, why can’t Java be as easy as ObjC" moment came courtesy of an algorithmic problem I was attacking at TopCoder, just for the hell of it. Problem is, to get to their problem definitions you have to use their applet thingy, and while I’m there I decided that I may as well type the code into their thingy after all Java’s not that bad is it? [They also accept VB, C# and C++ but my recollection of the C++ class syntax is slim and my knowledge of the STL is slimmer…I do know enough to try and avoid it though] So I think their problem definitions are proprietary, but suffice to say I wanted the ability to compare two strings, returning equal if the strings could be made the same by popping any arbitrary number of characters off the front and shifting them onto the back (i.e. treating them like rings of characters).

Well, that’s simple isn’t it? In ObjC I’d subclass NSString, override isEqual: and Robert is your parent’s sibling. I even know how to do that in Java:

class CircularString extends String {
public boolean equals(Object otherObj) {
//....
}
}

Only…no. You’re not allowed to do that, because for some unfathomable reason Gosling and the boys at Oak decided to inflict on us another voodoo keyword…final. This seems to have one purpose in existence: to stop me from subclassing the String class. In the words of Points of View, Why oh why oh why oh why?

Posted in Java, objc, sucks | Leave a comment

TGD – expanding the field

Some primarily stochastic thought processes which occurred when I tried to apply Richard Dawkin’s hypotheses to the Æsir. If your default browsing font doesn’t contain a glyph for the ligature, well, tough ;-)

I suppose one of the first things to note is that whereas Xtianity is considered a religion, the Æsir and Vanir (the Norse pantheon) are thought more often as folklore or mythology.[1] In fact, upon reading the Eddas it’s easy to have the impression that the sagas of Odin, Thor, Loki and chums have the same qualities as those associated with, for instance, Siegfried (of Das Niebelungenlied fame), King Arthur or Finn MCoul. Essentially, the gods have the air of being erstwhile real blokes (and of course blokesses), who have accumulated stories, feats and powers as people seek to glorify them, in order that when they later claim to be descended from same they can hope to persuade people of the existence of said powers.[2]

What I find interesting is that the only difference between a quirky set of historically interesting tales and gospel truth is how many people believe in what’s said. For instance, it would be easy to apply the same distinction above between religion and folklore to the Roman pantheon, which equally was a major European religion relegated to providing saints and fables once Constantine got splashed in the font. Of course, to do so would be to ignore that there were multiple pre-Christian religions in the Roman Empire. Not merely in the same way that the Norse posh nobs worshipped Odin and the thains worshipped Thor, there were actually completely different mythological universes. I’m going to choose one, completely at random.

Between the second century BC and fourth (maybe fifth) century AD, a particular popular mythos in the Empire was Mithrainism.[3] If there are any modern Mithraists, I don’t know about it. Which is not surprising, considering how wacky their religion was. [Update: apparently some Zoroastrians still venerate Mithras.]

Mithras was supposed to have been born around 270BC to a virgin Mother of God (the date of the celebration of his birth was December 25th). He was worshipped as a member of a trinity, as the mediating force between the heaven and earth. In fact, heaven was not only the celestial abode of God but also the place where atoned souls would go when they died, the true believers being absolved of their earthly sins. Those less fortunate were condemned to an infernal hell. Initiates (ceremonies were closed affairs, available only to men who had performed the appropriate rites) were baptised, and Sundays were a sacred time when the Mithraists ate bread, representing the body of their God, and drank wine, representing his blood; these were symbolic of the final supper he shared with his followers before ascending to heaven in about the 64th year of his life. Along with Odin and Osiris, he is supposed to have died and been resurrected before his final ascension.

You’d never get away with that rubbish these days, which is why this is clearly a deluded heathen folk tale as opposed to, um. You can clearly see why Dawkins didn’t talk about this one in TGD

[1] Actually, there is a religion with such a pantheon, called the Ásatrú – the word is Icelandic for Æsir faith. Despite widespread confusion, none of the major organisations of this faith are actually neo-Nazis or supremacy groups.

[2] I suppose this makes Finn and Aragorn the same being.

[3] Just through etymology I am reminded that I haven’t yet covered Jainism. I need to.

Posted in TGD | 3 Comments

That syncing feeling

So, ITunes tells me my iPod is up-to-date, and that it won’t copy a few songs to my iPod because the iPod software needs updating first. The word which springs to mind is "erk".

Posted in ipod | Leave a comment

Scary stuff

Possibly the scariest diagram anyone will ever have to look at. It’s even less penetrable than that Eric Levenez history of unix thing.

Posted in objc foundation | 2 Comments

Sacrilege!

As I wrote the @interface to an object today, I found myself wanting for but one thing:

- (NSArray <MyProtocol> *) foo;

Where – as if you hadn’t guessed it – the pointy bracket bit (the lengths to which I go to avoid typing out HTML entity names) would specify that all of the objects in the array returned by -foo conform to @protocol(MyProtocol). I then realised that this wouldn’t be quite as useful as I might think, but also decided that it wouldn’t be too hard even on the existing ObjC runtimes to come up with a nightmare function such as:

(Protocol *) objc_class_to_protocol(Class *cls);

…therefore meaning that my hitherto unattainable pipe dream:

- (NSArray <MythicalNSStringProtocol> *) foo;

may indeed be somewhat closer to realisability. Of course, with all of this being compile-time type checking (as with the similar beasties on Java) there would be no need to frob the runtime.

Update 2007-01-26T13:22: yes, I realise that the snippits above read "an NSArray or subclass, which also conforms to the MyProtocol protocol". I also know what I mean.

Posted in objc | Leave a comment

Eating one’s own dog food

I feel foolish for having made this error (especially after having so patiently explained how this stuff works on Mach), but today I did it. I reported the amount of free memory on a Linux system as being the amount reported by free as free.

My own opinion on this is that I suffer from a view of hardware management which was tainted by using micros like the Dragon 32 (Radio Shack/Tandy TRS-80 to my American readers) and the Amiga, where there were basically two types of memory usage: yes and no. A particular block was either in use by the system, or it wasn’t. On the Dragon 32 it was even easier than that of course; all bytes were available for reading and writing, but what happened was context-dependent. Also because this was the MC6809E, whether such a peek/poke made sense depended on whether you were trying to hit an I/O address, and what was plugged in. The Amiga had a particularly lame memory allocator which quickly sucked performance like a vacuum of performance suckage +2; but a byte of RAM was either in use or it was available.

But I digress. The point is, that such a simple view of memory availability is no longer sensible but it’s hard for me to think around it without a lot of work, just as it was hard for me to become a programmer after I’d been taught BASIC and Pascal. If I were involved in UNIX internals more (and indeed that would be fun, although I think maybe Linux wouldn’t be my first choice to open up) I’d probably be able to think about these things properly, just as I had to throw myself into C programming in a big way before I lost my BASIC-isms.

For the record (and so that it looks like this post is going somewhere), both operating systems have an intermediate state for RAM to be in between "used" and "not used" (where I’m ignoring kernel wired memory, and Linux kernel buffers). On Mach, there’s the "inactive" state which I’ve already described at el linko above. On Linux, it’s used as an I/O cache for (mainly disk, mainly read-ahead) operations. This means that Linux will automatically take almost all (if not all) of the memory during the boot process. The way that inactive memory gets populated on Mach means that on that system (e.g. Darwin) actually the amount of free memory starts large and inactive starts small, but over time as the active and inactive counts go up, the free count goes down, and it’s rare for memory to be re-freed. On both systems, free memory is really "memory it wasn’t worth you buying" as it’s not being put to any use at all.

Posted in kernel, linux, mach | 1 Comment

客観的なc計算機言語

Just heard from someone who wants to translate the c.l.o-c FAQ into Japanese. Sweet!

Posted in whatevs | Leave a comment

Copyleft

It is complete:

I no longer even own all the code I write in my spare time, on my own equipment.  :-)

Posted in whatevs | Leave a comment

TGD – John on acid

I’m about halfway through my OmniOutliner document of notes made while reading TGD now….

There’s a paraphrase in TGD saying that if the epistles of Saint John the Apostle represent John on pot, then the book of Revelation is "John on acid". What makes this observation more interesting is that it may be literally true – or at least closer to the mark than the quip may at first appear.

There was a documentary by Tony Robinson on Revelation and the End of Days, called The Doomsday Code. The – frankly worrying – sentiments of some of the extreme christian right in America are the same as described in TGD; namely that the Middle East instability [inclusive] or global warming or the 2005 hurricane season herald the proximity of the rapture, and that rather than doing anything to help those caught up in these situations we should be actively encouraging the Apocalypse, and xtians should let their heathen friends know that, well, they told us so. In the course of describing modern End Timers, the documentary showed us where Revelation was penned.

There are tens of apocalyptic visions penned by post-Christ Jewish theologians, but only one has been included in what is now termed the canon of the New Testament. That book of the revelation of Jesus Christ to his disciple, John (which isn’t accepted by the Eastern Orthodox as part of the divine liturgy) was written on the Greek island of Patmos sometime in the second half of the first Common Era century, and details two visions experienced by the John of the title (whether or not he be apostolic) while on the island. The other key fact to remember about Patmos is the abundance of fly agaric mushrooms, especially around the mouth of the cave of revelation.

Posted in TGD | 3 Comments