Need New Server Names

We’re setting up new servers and want to run with “incompetent sidekicks from old cartoons” theme. That gives us “Snarf” from ThunderCats and “Orko” from He-Man. Are there more classic whiny/unhelpful sidekicks that I’ve forgotten?

Reminiscing about Early Programming: OOP and Bits

When I was a high school kid in the late 80s and early 90s, OOP was new. It wasn’t taught in the programming class curriculum yet. (I was lucky to have programming classes at my high school at all, actually.)

Turbo Pascal 5.5 came with a thin 100-page book explaining OOP concepts. It was our de facto textbook on the topic. After reading it, Mike Kujawa and I had long arguments about the utility of OOP. It was easy to prove that you could code any OOP program without using OOP, and it seemed that the resulting program would always be smaller. The notion of polymorphism was neat, but you could fake that with pointers. It was hard to see the benefits of Objects right away, because of our intense awareness of the machine’s RAM.

The biggest problem with Objects was that they required you to add a pointer to every single object that you allocated. When you have 640k of RAM for the entire computer, those extra bytes add up, and you’re always conscious of exactly how big everything is. By writing your own pseudo-OOP, you could get the code tighter and more compact. If this sounds like the difference between C and C++, it pretty much is the exact same thing. 

Although the specific Turbo Pascal implementation of OOP was of debatable usefulness at the time, I have always kept that little 100-page book about OOP. Understanding the OOP concepts helped me understand code architecting, which I dearly loved, and practiced constantly throughout high school.

Although I had many things to architect, the most common project was the BBS program Mike and I were writing. It was going to run my personal BBS, replacing the crappy software I was already using. To this end, I filled dozens of spiral-bound notebooks with architecture diagrams. I used every notebook I had just for architecting and system design. It was no wonder I failed most classes, I suppose.

I found one of those old notebooks… most of them were thrown away, but one survived. It’s junk, but it struck me that this is essentially creative writing, the way I would take a concept, abstract it, then refine it over and over until it was elegant.

Because of the RAM restrictions, “elegant” usually meant “uses impressively small amounts of RAM”. Bit-packing is an inherently pleasurable sensation (at least for me). Seeing a complex concept expressed as a few bytes is like reading a tiny poem.

I don’t have need to bit-pack things much these days. I write less poetry, more prose.

Pac Man CE Strategies and Advice

I was really good at Pac Man CE, but then I took a year off. When I was playing it before, I could hit about 375,000 points. At the time, this was really good, and my score regularly got me onto the weekly leaderboards and in the top 150 overall. But times change, and I didn’t stick with it. Now, it looks like 600k is the top. Holy crap!

So I spent the afternoon trying to get my Pac Man chops back. Of course I visited Youtube, where you can see some masters doing their thing. This is incredibly helpful. But I was surprised and sad that there aren’t more people talking about the game. Sure, it’s been out a while now, but obviously people are still playing it, and getting really high scores now, so what gives? Well, let me help remedy the situation.

Find a pattern for your first 45 seconds. There are several patterns you can find at the beginning of the game — patterns of movement that will net you a whole bunch of ghosts reliably. Don’t try to memorize somebody else’s pattern; it’ll be a LOT more useful if you find one yourself. It’s not too hard: just practice chaining the power pellets together without letting them run out. When you can eat at least six power pellets without interruption, then start practicing moving in such a way that you also grab a bunch of ghosts while you do it. You’ll know you’re on the right track when your pattern earns you at least 50,000 points in the first 45 seconds!

Dying Is Not a Scaleable Strategy. When I went googling for strategy tips, I found some very old advice that suggests you kill yourself at strategic moments in order to eat more ghosts. This is good advice early on: use it when you get to the “key” levels, where you have six power pellets on screen all near the ghost house. That will help you get over the 250k hump quickly. But if you want to get really high scores, you can’t afford to die: you lose precious seconds, plus your pellet score multiplier, plus part of your speed boost. It doesn’t pay off. So you’ll need to start practicing getting the ghosts to come to you without getting killed. It’ll take some time, and it’s a lot less reliable than killing yourself, but it’s a necessary thing to learn.

You Don’t Have Time To Parlay With Ghosts. Avoiding death is really important, but you have to go even further: you have to avoid spending a lot of time avoiding ghosts, too! If ghosts corral you and force you to evade for ten seconds, you’re not a whole lot better off than if they had just killed you. You lost the most precious commodity: time.

This is why you shouldn’t try to eat ghosts with every power pellet. Instead, use most power pellets as a way to safely and quickly clear out big chunks of the board without being hampered by ghosts.

By the same token, don’t go out of your way to eat ghosts, unless you’re going to be able to eat a LOT of ghosts (at least eight, preferably 16). It’s satisfying to chomp the buggers, but they are just distracting you from getting to the higher levels of the game where things move faster and getting a high score is easier. Remember that the goal of the first several minutes is to get to the Key level as fast as you can with as few deaths as possible.

Use Extra Mode 1 To Practice High Speed Movement. When I came back to the game I found that my ability to control Pac Man at very high speeds was gone. I needed a way to practice high-speed movement, without waiting for the regular game to speed up. Extra Mode 1 to the rescue! This mode will also train you to watch the whole board for ghosts coming in from the sides. Two very useful skills in one!

I’m headed back to practice some more. I hope that helps someone!

“Evasive Maneuvers!”

Every sci fi TV show eventually has people yelling this phrase. I was just watching some Stargate SG1 episodes where this phrase was especially unhelpful.

But it’s always unhelpful: they’re trillion-ton battleships in space. They’re being attacked by laser beams that were precision-aimed via computer. So how about moving on a slightly different course than you were before? Is that gonna stop the energy beams and light-speed missiles from hitting? No? Weird!

Have you ever seen someone yell “Evasive Maneuvers!” and then “Woo! Thank god that worked!” No. It’s always “Evasive Maneuvers!” and then the whole set shakes because some indeterminate area of the ship blew off. Why doesn’t that guy do something useful instead of micro-managing the pilot?

The secret is that this phrase doesn’t mean what you think it does. In the far future, people don’t say “fuck”. Really! Nobody ever says this on TV. What they say instead is “Evasive Maneuvers!” This is high-fallutin’ captain speak for “fuck”.

Try it out in your daily life. I think you’ll find it works exceptionally well. Stuck in traffic? Some driver cut you off? “Ahh! Evasive Maneuvers!”

Off-topic: Gilgamesh

I’ve been reading Stephen Mitchell’s translation of Gilgamesh for maybe a month. Well, it’s actually pretty short, and I read it all the night I got it, but I left it on my nightstand near my bed and I keep popping it open and reading snippets. It’s pretty good.

But it’s good by modern standards. It’s freaky that the oldest story we have, the epic of Gilgamesh, is as complex as it is. It has all the regular mythical beast slayings and chest beating, plus a nice big helping of homo-eroticism, but the latter half of the book is not something you’d see in any regular myth.

When Gilgamesh’s soulmate Enkidu dies, Gilgamesh, a super hero who is “two-thirds divine and one third mortal”, suddenly realizes he isn’t going to live forever either. He can’t defeat death the way he’s defeated monsters… he is not immortal.

It terrifies him and wrecks him. He becomes a pale shadow of himself and leaves his castle (for he is the king of the greatest city in the world) so that he can wander the world in search of a way to avoid death. 

Eventually, after much effort, he finds the one man whom the gods made immortal, a man named Utnapishtim. He tracks him down in the lands of the gods and learns his story. It turns out that Utnapishtim is the pre-historic version of Noah — that is, his story will be retold as the Noah’s Ark tale in the bible, much later. Utnapishtim was made immortal after the gods realized how foolish it was to have tried to kill off all humanity. This road to immortality isn’t going to help Gilgamesh.

After he explains all he did in order to earn immortality, Utnapishtim says, “Now then, Gilgamesh, who will assemble the gods for your sake? Who will convince them to grant you the eternal life that you seek? How would they know that you deserve it?” So Gilgamesh attempts to prove that he is deserving of immortality, but cannot. He cannot even pass the first test, to stay awake for seven days. He’s so tired that he can’t stay awake for 15 minutes.

When he realizes he’s already failed the test, Gilgamesh cries, “What shall I do, where shall I go now? Death has caught me, it lurks in my bedroom, and everywhere I look, everywhere I turn, there is only death.” But Utnapishtim is not sympathetic. All men (besides him) must die. And so Gilgamesh returns home a broken and ruined man. He is left to rule his kingdom the best he can and make his city the most glorious place possible, until he inevitably dies. The end.

It’s a nuanced and rather complex tale, especially compared to tales that I’ve read from later periods. In Norse myths, for instance, death isn’t so big a deal. But even though Gilgamesh’s world has many gods, the land of the dead is an unhappy, miserable place where people “squat in the darkness, dirt is their food, their drink is clay, they are dressed in feathered garments like birds, they never see light, and on door and bolt the dust lies thick.” Not exactly Valhalla.

To me the most touching scenes are the ones where Gilgamesh tries to come to terms with his friend’s death. “For six days I would not let him be buried, thinking, ‘If my grief is violent enough, perhaps he will come back to life again.’ For six days and seven nights I mourned him, until a maggot fell out of his nose. Then I was frightened. I was terrified of death…”

This is in the same story where Gilgamesh rebuffs and then beats up a goddess, kills a horrific monster, and sleeps with everything that has legs. It’s… really odd. And really unsettling, like a good story should be. You can probably have your library deliver it right to your doorstep for free, so why don’t you google your library and get that set up right now?

PS – if anybody has any more info about the “roller bird” referenced in the myth (one of the many doomed lovers of the goddess Ishtar), please let me know. From what I can tell, the roller bird’s myth is completely lost, which is sad.

AS3 Literal Syntax for XML

ActionScript 3 has all sorts of cool things. One of them is support for “E4X”, which is “ECMAScript for XML”. In other words, it’s got built-in XML primitives. Poorly documented primitives.

One of these primitives is the ability to insert literal XML code right in your app, and have it magically compile into XML objects at runtime. This has lots of handy uses. I’m using XML as a simple communication protocol between two apps, so I don’t need to load XML files… I just want to send small blobs of prefabricated XML back and forth. But of course I don’t want it to be entirely prefabricated… I want to insert variables and such into it. In my case, I wanted to have a prefabricated blob that also had dynamically-generated children.

Insert Dynamic Values Into Nodes: If you look in the help for this, you are directed to the friggin’ E4X specification, in PDF format! There is no documentation other than that. If you google around, you can find that embedding stuff in curly braces {} lets you insert literal symbols. This blob will insert the literal value of “foo” into the XML nodes stored in “cmd”:

var cmd:XML =<cmd><id>{foo}</id></cmd>;

Great! So far, so good. But now, I want to embed several CHILDREN in there, not just the literal value of one node. How do I do it? I tried setting “foo” to a string like “<child>5</child><child>6</child>” etc., but the <> symbols in my string were helpfully turned into &lt and &gt so it was still just the textual value of a single node.

Insert Dynamic NODES into your static structure: So how do you do this? I can’t find a way to magically do this directly in the literal XML. Instead, I left the dynamic part of the data out of the literal, and after it was constructed, I tacked the missing parts into the XML structure. To dynamically create nodes, you can explicitly construct an XML object with a string of text, and it will make that into XML node thingies. Then you can use the += operator to insert those nodes into your literal XML. Let me show you an actual small code snippet:

 

public function sendCmdSetDeckList(deckIdx:uint, ids:Array):void {
    var idxml:String = “<abilities>”;
    for (var loop:int = 0; loop < ids.length; ++loop) {
        idxml += “<ability><id>” + ids[loop].toString() + “</id></ability>”;
    }
    idxml += “</abilities>”;

    var msg:XML =<cmd>
                               <id>{ID_SEND_SETDECKLIST}</id>
                               <deckIdx>{deckIdx}</deckIdx>
                          </cmd>;
    msg.cmd += new XML(idxml);
    send(msg); // casts “msg” into a String and sends it out on a network socket
}

In this bit of code, I create a string of dynamic XML and stick it in the variable “idxml”. Then I create some static XML in “msg”, and then tack my literal XML code into msg, under the “cmd” tag, which is the top-level tag. After that, the “msg” xml structure has a node named <ability>, which has all of my ability IDs in it.
 
Note that the literal string must be “valid” xml, which means it must have only a single top-level node. Thus, I had to put all the <ability> nodes inside an <abilities> tag. If I didn’t do this, I would get a runtime error when I try to stick the string into a new XML object later in the function.
 
Forgive the mediocre example but I wanted to throw something up about this before I forgot about it (but I can’t spare too much time right this second). It’s very frustrating that there’s so little documentation for this. This reference was pretty useful, as far as it goes.

A neat trick in Windows XP

If you’re a developer, try going into the Sounds control panel and assigning sound effects to “Open Program” and “Close Program” events. These actually fire whenever a process starts or stops. It can be very informative. You’ll hear a cacophany of noise when you boot up, but more than that, you can watch various programs doing sneaky things. For instance, if you’re playing WoW with these set, you’ll hear the open/close sounds go off every time you alt-tab away from the game. It’s WoW’s anti-cheat software going off.

You’ll also hear this go off when a screen saver starts or ends, or when a program decides to check for updates, or many other times. It’s pretty interesting.

Perl vs. PHP

Perl is almost obsolete. This makes me sad given how much Perl I know. Not a year ago, I loved Perl. The power I could command at just a few characters! The language flexibility! I love being able to create my own custom ”dialect” of Perl for any given problem. It’s neat, and fast, and sometimes it’s even elegant.

But not really. It’s never actually elegant in the “easy to understand” sense. Plus, Perl is not an easy language to understand in general. The syntax for deeply nested references can confound the newbie Perl programmer for a very long time. And the distinction between variable types ($, @, %) seemed like a neat distinguisher… until I used PHP more.

PHP is like a really stripped down version of Perl. But it has much better OOP support. Like, tons better. I miss some things, like enforced variable declaration. And Perl’s variable scoping is more intuitive. Perl has better warnings for some things, too. But PHP’s simpler syntax proves more elegant while providing the same level of flexibility. It doesn’t have the beautiful maleability of Perl… but then again, it’s pretty maleable in its own ways. It’s not intended to be an “only one way to do things” language like Python.

One of Perl’s great strengths for me has been its nifty tricks for file I/O and common maintenance-scripting tasks. But Perl 5 has been stagnating while PHP has been growing by leaps and bounds. Most of the neat operators in Perl now have built-in function equivalents in PHP. Often they are even better than Perl’s version. Inevitably they are easier to comprehend. I’ve actually started using CLI PHP for quick one-off scripts. My uses for Perl are waning very quickly.

A year ago, when I was an active Perl hacker, I was angry about Perl 6. Perl 6 obsoletes all Perl 5 code. It’s not backwards compatible at all. “What is the point of this?” I wondered. Perl 6 has many new features, and it cleans up a lot of the syntactic awkwardness of Perl 5. But… a whole new language under the guise of a version-number upgrade?

Now, I can’t wait for Perl 6 to actually arrive. (In a viable, not-dog-slow-beta form.) It will be another year or two, I think, before the language is viable. But I would love to love Perl again.

My little black programming book

I admit it. It came from watching the cheesy TV show “Supernatural.” They have a tattered old notebook and it always has just the right clues needed to solve whatever problem. It’s awesome and I want one.

When I was a teenager I made one, actually. I spent hundreds of hours in classes. I still have it. Every 386 assembly opcode, all the VT102 terminal emulator codes, Pascal references, the works. However, unlike the book in Supernatural, my original programming book is never, ever useful. I have never needed to refer to it in at least 15 years. Programming stuff goes obsolete a lot faster than notes about demons, apparently.

So I made a new one. I found an old leather-bound 3-ring binder my dad used to use before he retired. It has that “hand me down” sort of feel. And I started making my programming book. I create the pages in Word and then print them out and hole-punch them. There’s stuff on PHP, SQL, the C++ STL, a cheatsheet on CSS, and so on. I do actually refer to it occasionally. It sits right here so sometimes it’s faster to find a needed diagram than to look it up on Google.

It isn’t sexy enough, though. It doesn’t have that “here is all my knowledge” sort of feel. So I bought a pencil and paper notebook at the store, with a nice cover and stuff. And I started writing in the stuff by hand. But I got two pages in and realized how stupid that was. So now I have a vaguely unsatisfying Programming Notebook that isn’t quite cool enough. And a mostly-empty journal book with just two pages written on it.

I could go into ghost hunting…

Unity… So close…

Unity is cool. It’s a 3D engine that runs in your browser. It gets decent framerate (unlike its competitors) and it looks like the tools are pretty well developed. Check out the demos if you’re bored — that’s the future of web gaming right there. Low-requirement, hardware-accelerated 3D.

I would love to take this for a spin. But I can’t.

Although the Unity plug-in works on all the major OSes and browsers, the development tools are only available for the Macintosh.

The Macintosh.

I don’t own a Mac — I have nothing against them, but they are just too expensive for me. And the thing is, neither do most game companies. This is a pretty big limitation! Huge, even.

I wrote to them, and got a response from Unity’s “evangelist”, who said a PC version was coming. He said I could count the time before the PC version launches “in months rather than in years” but then took pains to make sure I understood that any number of years could also be represented in months…

Honestly, I think this misstep may be what kills them. They’ve been around a while but their adoption rate is itsy-bitsy tiny because nobody can run the IDE. Sure, in six months or a year they will finally be accessible. But Flash Player 10 finally has hardware 3D primitives. How much you want to bet Flash 10’s adoption rate will be near 95% after a single year? Sure, Flash 10 won’t come with any useful tools for 3D world modeling, but somebody will build them.

Unity’s website talks about how adoption rates aren’t the end of the world as long as the install process is clean and easy enough. And the install process was easy for Unity. But… you go to a random web page, it says, “To play this game you need to install Unity, click here!”… and you’re just going to go to some other game page instead.

I am rootin’ for you, Unity… at least in theory. I haven’t actually played with the IDE so I can’t tell how good it really is. But even a mediocre 3D editor is infinitely better than what we’ll get out of the box with Flash 10. But … you need a killer app, right now before Flash 10 catches on. Can you do that? I don’t think you can.