Saturday, October 07, 2006
Render targets, multipass glow buffers and more
Some other neat features that I've added gameplay wise are tracking missles and the start of a pretty full featured particle system. The tracking missles and bullets have been refactored to use the same particle system.
On another note, I got my old domain back jrepp.com and am pretty much finished with the migration of my recent content, links etc. I don't have all the old stuff from the previous jrepp.com (sources, cocoabb, arcane programming docs) but I'll be digging it up out of the archives to get things cool again. I also plan on writing a few short postmortum articles about XNA development when I hit my stopping point.
My kids are both really into playing the game right now. The key mechanics for them are the "star fox roll" and the debug camera. On a side note this months Retro Gamer has a couple good articles, one of which is about the making of Star Fox which is really a good read.
Friday, September 29, 2006
Holdem: Bug fixing career mode, UI tweaks
On the UI side I cleaned up the main menu so continue career only shows up when you have a save game. From the in game options menu when you cash out or save and quit it does a nice transition back to the game and then either fades out to career or play now or shows the currently slightly broken quit confirmation.
I would love to get one more art pass over all the menus and background stuff. I may just experiment with altering the existing menu background to make it more color blend friendly and change to a larger font. I want the UI to feel very tangible and inviting.
Thursday, September 28, 2006
XNA Shmup Update
Before ragging on the game any more I've gotten a bunch of neat things working. There's a few big things that currently don't exist in the XNA beta that will bite you as soon as you start to scratch the surface of the framework:
- No support for model loading or animation
- No support for fonts or UI
I then spent another hour and wrote a very small but usable UI/menuing system. When the debug camera is not enabled the left trigger brings up the menu. You use the DPAD to navigate the menu (A button also opens submenus). Certain items can have 'tweakables' attached to them which can be either a float, vector3 or vector4 value type. The tweakable fields (3 or 4 for vectors) can be selected using the shoulder buttons. The right analog stick adjusts the value in the field and an update event is sent to an attach IEventTarget object. I use eventing all over the engine already for animations, game logic etc. The one tweakable I have now for example is the LightDir tweakable which is wired to an UpdateLightDirection event on the scene. In the first picture you can see the specular highlights on the water (please excuse cheazy really bad shader code). You can tweak the lighting with the controller to get the desired effect.

So then that brings me to the issue of the model loading, which I was also content to let be and just use the standard cubes. I remembered that I had some old 3DS loader code laying around and porting C++ to C# is pretty darn easy IMO so I spent a few hours and ported the 3ds code. There were a few wierd things to work out in the translation but the C++ code was written with some nice abstractions so it went very smootly.
So now I've got some free 3ds models from the web running around in the engine with some more interesting lighting and it's actually looking a little bit more decent at this point. The next two shots are just of a free 3ds model I found that is composed of about 16 mesh chunks and has custom basic materials (no textures). To handle the materials I created a MeshMaterialGroup object that accepts the material with face indexes from the loader and resolves the faces into prim indexes. When you call Mesh.SubmitPrimitives() it looks to see if it has any material groups and if so it submits them in order instead of sumbitting the entire prim batch for the whole mesh.
Close ups of 3ds model:

Saturday, September 23, 2006
XNA Shmup
A few concepts that I am borrowing for the GD are:
- Roll defense from starfox
- Polarized attack for the enemies ala ikaruga (radiant silvergun), the difference here is that ground targets must be bombed, squigies must be railed with mass driver weapons and conventially shielded enemies require beam weapons.
- All weapons are effective against all enemies but certain weaons are much more effective. This technique is vital to survival.
- Ability to equip a small pod that can has limited controlled and it's own set of upgrades.
- Clip/reload system for mass drivers/bombs, energy system for beam weapons. Ammo is plentiful but must actually be collected and you cannot hold the fire button the whole time.
Here's a screenshot debugging one of the triggers for a mob spawn and the new bullet system:
Again, not very impressive looking (it looks better in action) but I'll just layout a few of the things that are working now. - Follow camera
- Scene trigger system that can fire proximity events
- Mob controller with spawn/death management (hooked to trigger system)
- Mob action scripting pcodes with time driven events (Fire, Rotate, Change properties etc)
- Random terrain generator
I'm not trying to do a fully polished game currently. Just something that starts up allows you to play through a random level with increasing difficulty and records your high score. I will probably implement a few different types of weapons as well.
I don't know if I want to finish it all in one shot.. I have to get back to some other stuff.. really ;)
Friday, September 22, 2006
XNA: Yes I'm a bit addicted now
Thursday, September 21, 2006
Migrating Outlook Express to a Mac
dbxconv *.dbx
Copy all the mbox files to a windows file share.
On the mac in the finder 'Connect to Server (OpenApple-K)' enter the address:
smb://your.server.address
Import them in Mail.app.
Once the mailboxes are imported you export the contacts to a CSV file in outlook. Paste them into: Csv2Vcard and save the output to a vcf file.
Import it into Address Book as Vcards.
XNA rainbow mesh

Well it's certainly not much to look at. I haven't put too much time into getting things pretty yet but I have ported a bunch of game engine concepts from rampart already. I've got a simple scene system with multiple vertex/pixel shader support and runtime switching between shaders. An animation system is hooked up to the avatar with event callbacks. Multiplayer support with actions wired into avatar. Debug mode with flying camera and ability to control scene rendering parameters (pictured wireframe mode). Oh and sound effect events.
The shader in the screenshot is the simple ffshader.fx that is shown as an example in the XNA docs. I have another shader that I put together off the template in NVIDIA's FX Composer. You can toggle between the two and there is a dynamic effect binding system that binds scene/object parameters automatically for the selected effect.
And yes the rainbow terrain mesh is super fruity!The XNA docs overall are very good but they don't go very deep. I had to dig a bit deeper to discover how to handle the effect files more generic than in the examples which simply loaded a vertex shader function.
Essentially what I have is an scene effect object per .fx file. They derive from an abstract class with the following members:
OnEffectLoaded() -- called after the effect is loaded to get handles to the various parameters.
BindSceneParameters() -- called once per scene render to bind global scene parameters.
BindSceneObjectParameters() -- called once per scene object to bind local object parameters.
This is handy for switching effects on the fly.
I'll post some more XNA shader stuff later.
Wednesday, September 20, 2006
Goofing around with the XNA Framework
So I downloaded XNA framework and so far I'm really happy with how things are setup. The API is really solid and easy to use. I had everything downloaded, installed and a spinning cube with 360 controller support in about 3 hours. Some things I like a lot and are worth mentioning:
- 360 controller support is awesome, no remapping wierd DINPUT Z-trigger or hats to in game actions. The game pad state that you read has members like Triggers.Left which is a floating point value. You can easily do things like Buttons.A == ButtonState.Pressed.
- The Matrix object is very easy to use and has a bunch of very helpful static methods for getting various types of matrices.
- C# is pretty fun to write game code in.
- The framework is nice and lean and does things 'The Right Way', they don't eat all your CPU when you're running a basic idle loop or in the background.
- All the heavy lifting is done in shaders via .fx files. This is very handy and works well with the VertexBuffer classes.
I couldn't get stuff to work initially on WinXP 64bit edition until I found this post
I'll probably post some screenshots before I go back to regular stuff. I don't know how far down the XNA path I'm willing to go just yet.
Friday, September 15, 2006
Jeff Minter gets his llama print undies in a bunch
Rumor #1: There were some llamas that popped up and we made him take them out.
Rumor #2: There are still llama shapped buffers/backplanes used in the visualizer.
So tonight I followed a jump to his blog where he posted some test particle screenshots. These shots came out before the vids that clearly show he's doing a very tempest-like game. Now if you go and read the comments a fellow going by the name alanc5 asks him if he's just doing another tempest clone and Jeff flies off the handle. Alan has posted some retorts on his blog. I feel that Minter could have handled this much better than he did. Luckily nobody knows or cares about any of the stuff I'm working on so I will likely not have to prove that out ;)
Jeff is doing another tempest-y type thing which is boring but fine really yet he never did admit the guy called him out on it before he even showed off the game play. Alan might apparently have a history of goating Minter but at least he doesn't back down even when the whole yakyak forums come crashing down on him. I feel kinda bad for the guy.
Thursday, September 14, 2006
Holdem: UI bug fixes
At least on a green background it looks semi-decent. It looked better in 32bit color. I think that dithering to 12bit makes the colors harder to pick out. I 'skinnied' (if that's even a word) up the action menu which sacrificed the 'best hand' display and the bet ammount. That should make it more consistent with the other phone UI elements. The left action button is bound to the menu.

Career mode got some love. I fixed a bunch of character select bugs. But I think I'll the last glyph in the font should be swapped with a RUB button. Probably just a back arrow would be fine. The hiphen glyph is serving this purpose now.

I also fixed the career continue mode a bit. All menu animations have been cleaned up and are sliding in and out nice and smooth.
Wednesday, September 13, 2006
Funny quotes from IRC
#349567 +(9050)- [X]
Rabidplaybunny87: Okay, so my neighbors officially hate me
GarbageStan23: why?
Rabidplaybunny87: Well, me, david and andrew were having a bonfire in the backyard, and we were making s'mores and all... and suddenly we here sirens, and see a firetruck turn into the street in front of us.
Rabidplaybunny87: So we all went running to see what was up, and our neigbor's house was on fire!
GarbageStan23: oh shit!
Rabidplaybunny87: Yeah, and when we got there, the wife was crying into her husbands arms, and we were just kinda standing there, and then she saw us, and then like for 10 seconds, gave us the dirtiest look ever
Rabidplaybunny87: Turns out, we were still holding our sticks with marshmallows on it, watching the fire....
Rabidplaybunny87: talk about bad timing...
Tuesday, September 12, 2006
Holdem: bugs, bugs, bugs
Sunday, September 10, 2006
Holdem: Nokia 6682 photo
Massimo says:
so what are you up to now? working on getting the animation running? Cuz I know what you're not doing :) you're not posting pictures of Hold'em running on your phone :)
Well somebody has to keep me honest.
Holdem is finally running, woot!
The line that was crashing first was:
if(path.compare(rec->name, rec->namelen))
This looks totally innocent.. I'll just say right away that it wasn't any of the usual suspects. Keep in mind that this ran fine on other hardware architectures. The problem was actually memory alignment.
The records that are being referenced here are part of a block of index records stored in the resource file. I have a tool that transforms and packs files into a single file and creates one block of memory to be used as a searchable index. The structure in memory used to look like this:
struct RecordRef
{
uint32 offset;
uint16 nextrec;
uint16 namelen;
// char name[namelen + 1]
};
If I tried to access offset or nextrec and the field didn't lay on a 4 or 2 byte boundary respectively my application would crash. This kind of problems are pretty hard to track down without a debugger. I used loglines traced to a text file on the phones internal memory through multiple builds to track this down.
The new structure looks like this:
struct RecordRef
{
uint32 offset;
uint16 nextrec;
uint16 namelen;
uint16 padding;
uint16 reserved;
// char name[namelen + 1]
};
I calculate the padding when the records are built in memory and before they are stored into the resource file. When they load from the file they are all nicely aligned and the code that searches the index just has to take into account padding when doing any pointer/index math.
Seeing the title screen on my phone makes me very happy!
Saturday, September 09, 2006
Holdem: More progress
..\..\..\..\..\DEV\ZTEAM\HOLDEM\S60\SRC\Series60.cpp(220): Starting window session
..\..\..\..\..\DEV\ZTEAM\HOLDEM\S60\SRC\Series60.cpp(232): Setting up direct screen access
..\..\..\..\..\DEV\ZTEAM\HOLDEM\S60\SRC\Series60.cpp(236): Creating double buffered drawable
..\..\..\..\..\DEV\ZTEAM\HOLDEM\S60\SRC\Series60.cpp(270): Initializating game engine with data path: E:\System\Apps\Holdem\data
..\..\..\..\..\DEV\ZTEAM\CORE\SRC\Gameengine.cpp(56): GameEngine::initialize(): game engine data path: E:\System\Apps\Holdem\data
..\..\..\..\..\DEV\ZTEAM\CORE\SRC\Gamearchive.cpp(68): GRPIndex::_reserve(): reserving: 1409 bytes, buffer: 0x00000000
..\..\..\..\..\DEV\ZTEAM\CORE\SRC\Gamearchive.cpp(95): GRPIndex::_reserve(): finished, buffer: 0x004121c4
..\..\..\..\..\DEV\ZTEAM\CORE\SRC\Gamearchive.cpp(734): GRPFileSystem: loading file: default.ini, packfile: E:\System\Apps\Holdem\data.grp
Could be a few things right now but pretty promising that game engine startup has gotten this far. Now if I can get that config file to load it will be on like donkey kong.
Thursday, September 07, 2006
Beatbox: Sound is back
Since music and sound is at the core of the game I'm considering building a specialized sound library/sequencer for the game. It would use an existing format and tracker for the editor probably screamtracker3 since I'm most comfortable writing tracks in that. Right now I'm using fmod which actually allows you to get event callbacks from the sequence. I'll probably just play with that for now.
I wrote a really nice scene graph when I was on vacation in mexico so that eventually needs to make it into the gfxlib but it's a pretty big change at this point so I may put that off too..
Oh well, lots of stuff to put off per-the-usual. I really am trying to keep the tasks smaller and more achievable but at some point I know I need to make bigger bets to make sure the stuff can be finished, polished and pushed out the door.
Globals are still considered harmful to your health
Sometimes there are well defined technical reasons for this. Some people detest them because they have been told they are bad. Other more thoughtful people understand some of the serious problems that globals have. Many times in rapid prototyping (ala beatbox) or in general game dev people get a bit too global-happy and it can be a serious problem... I'll list a few of my main reasons for really not liking them:
- Globals can hide bugs, if you don't name them intelligently they can be overriden by locally scoped variables.
- Globals don't have well defined access patterns, anything in any thread can access them. This can make porting a single-threaded app to multi-core a super fun hairpulling exercise.
- Globals enable sloppy coding and can ruin layering.
- Globally defined classes don't have deterministic initialization order, you better not count on one class being ready before another one. Go for two-phase construction if you need a global class.
It's not all bad though:
- Having your root system(s) as objects at global scope simplifies your life.
- Pre/Static allocation is your friend. Many applications can be designed to require vary little dynamic allocation and this can really improve speed.
- Sometimes when you're maintaining code it is less intrusive to add a global or static method then touch every method on down the call stack.
They're there for a reason. What's yours?
Tuesday, September 05, 2006
It's coming along

Well there is more or less something there now. It is actually playable, although not being able to see scores and combos is a bit of a drag. Also the thing is completely full of bugs. It has gotten a lot funner to work on now though. Much less doing the boring plumbing that runs the show and more doing the AI and gameplay that I enjoy.
Monday, September 04, 2006
Beatbox: A story

Okay well this isn't the sky falling but screenshots are so much fun, especially really dumb ones during development. What was at one point actually a fairly fun playable little game is currently a shadow of itself living on top of all new (actually rehashed I get to that in a minute) stuff.

Now I'll provide a little story about beatbox, mostly for my own benefit. About a year ago I was having a lot of trouble getting any coding done after our second kid came along. I still had time but I just couldn't really get myself motivated to do anything good. Discouragement mostly came from the fact that I didn't figure that I had time to really write anything of any good quality.
So I got this idea to just hack, not worry much about proper design or object orientation or really doing anything right at all. I wanted to get back to the root of what I loved, the thing that made me write reams of code in Jr and Sr High School. Just get something up and going no matter how sloppy or lame it was and have fun doing it. So I put some 3d graphics to music using glut, and it was a blast.
After awhile just doing different 3d scenes at different sample points in the song became a bit mundane for my own personal enjoyment so I decided to make the blocks fall down and controllable. And that's more or less how beatbox was born. I wanted to have poyupoyu style gameplay with my own individual twists because that was really what I wanted to play and I didn't have a poyupoyu game on hand to enjoy.This whole time I was still hacking. The entire game logic was in poyu.cpp and the rendering was in render.cpp. It was a pretty mess. I copy-pasted chunks of code that I dragged in from all kinds of personal projects from as far back as 2002, yeah a glorius mess. At some point I just dropped the binaries in a folder and called it good. I realized this was a dead end and I was re-inventing and ruining all kinds of work I had already done for the past few years as well as writing some code that would never again be useful. So I made a big choice. I was going to take 5 years of code and make it into a set of consistent usable libraries and make all my games compile off of that. I knew this was a huge project but I decided that it would be fun and good for me.
So I've come to a summit of that work. I actually have the original beatbox code retrofit into the new set of libraries with a new resource system thrown in for good measure. It feels good but all I have to show for it is a white triangle on a grey background. At least I'm happy.
Beatbox: Was it.. nope
Sunday, September 03, 2006
Some things are running again

The UI widget test app is up and running again. This time using the final resource system from the game library. I took a screenshot to prove how unimpressive this actually is ;) This is some of that TDD stuff that I posted about earlier. There is a unit test framework (built using a command line system that is part of the game engine) for testing object models and what not but this is a simple test graphics app. It doesn't do anything besides create a view, add some UI components, test strings and setup the layout. This makes it really easy to get up and running fast and find a variety of little bugs.
Tuesday, August 29, 2006
Ich Pwne Newbs
Monday, August 28, 2006
This is Hardcore

PULP LYRICS
"This Is Hardcore"
You are hardcore, you make me hard.
You name the drama and I'll play the part.
It seems I saw you in some teenage wet dream.
I like your get up if you know what I mean.
I want it bad. I want it now.
Oh can't you see I'm ready now.
I've seen all the pictures,
I've studied them forever.
I wanna make a movie so let's star in it
together.
Don't make a move 'til I say, "Action."
Oh, here comes the Hardcore life.
Put your money where your mouth is tonight.
Leave your make-up on & I'll leave on the light.
Come over here babe & talk in the mic. Oh yeah I hear you now.
It's gonna be one hell of a night.
You can't be a spectator. Oh no.
You got to take these dreams & make them whole.
Oh this is Hardcore -
there is no way back for you.
Oh this is Hardcore -
this is me on top of you &
I can't believe that it took me this long. That it took me this long.
This is the eye of the storm.
It's what men in stained raincoats pay for but in here it is pure.
Yeah. This is the end of the line.
I've seen the storyline played out so many times before.
Oh that goes in there.
Then that goes in there.
Then that goes in there.
Then that goes in there. & then it's over. Oh, what a hell of a show
but what I want to know:
what exactly do you do for an encore? 'Cos this is Hardcore.
Beatbox: Track names
Bomberman DS
Pheonix Wright: Ace Attorney
The general lesson seems to be: if you hear a DS game is good and you see it, swoop it yo.
Oh back to the topic, so we're talking about beatbox which is my music based puzzle game I sent out to a few people and the tracks so far which are named:
I Was a Teenage Mecha (MkII)
Luxury Carpet Comparison (bitwise)
Siding is Exciting
I'm going for a bit of an abstract techno feel with these tracks but the names are inspired by local Seattle band Minus the Bear who have great song names such as:
Hey! Is that a Ninja up There?
Monkey!!!Knife!!!Fight!!!
Thanks for the Killer Game of Crisco® Twister
I Lost All My Money at the Cock Fights -
I mistakenly said one of their songs was 'Monkey Monkey!!!Knife!!!Knife!!!Knife!!!' and for that I'm sorry because I really think that is a much funnier title anyways ;)
And while I'm at it I might as well thank Ryan Blinsky for introducing Minus the Bear to me.. As well as tons of other awesome music.
On Hobby Coding: Test driven development
I took this job intentionally, not just because everyone I interviewed with completely impressed me technically but because I really wanted to stretch myself in this role. It has taught me a lot of new things about design and every day coding and it has really evolved my hobby coding as well. I don't write exclusively test oriented code any more but I'm even more sold than ever on the benefit of approaching things from a testability angle.
Wikipedia has a good definition of TDD. Your milage may very. Personally, I usually write the 'client' functionality test and then implement either a no-op interface for it at first or something very basic. If I'm working on something new and complicated I spend some time mulling it over and drawing pictures first. If it's adding some small functionality to existing I'll do the simplest implemention.
During the time I'm implementing I'm always looking for ways to collapse functionality (ie. refactor) or simplify things. A lot of times you find issues before hand as you're writing the test, things you didn't think of when designing. Here's some warning signs you'll likely see:
- This code is totally not testable..
- If I could only get at that lower level thing, this would go way faster
- If I shared that dohicky than I only need to write n/2 lines of test code
- This is going to take some serious time.. do I don't really need this?
These are all really net-positive things to discover early on. Most importantly.. these things are discovered before you write 2k lines of dense game library code. There are some real challenges to be solved here that are going to make you a better designer and coder:
- Proper layering of your code, decoupling and exposing multiple layers so they can be tested individually. This is a non-trivial design challenge to do correctly but done right is really great.
- Cutting down uneccessary feature-creep when you really actually don't need something. When there is nothing left to remove you have the perfect product ;)
And at the end of the day, if you did a half-decent job you have a properly designed testable system that you can easily make changes to because you have a proper test framework for it. There's more here but I'll save it for other posts. Less theory more practice.
On Hobby Coding: Prelude
So this started again. I've been doing some hobby coding since I finished saint's row and dead rising (not the good ending yet though) and wanted to get some ideas out about my recent methods.
I sat down to start writing about TDD (test driven development) and decided I needed a new approach. So here it is. This is a blog after all so I'll try to post little snippets on the topic under an umbrella subject and see if that motivates me better to get the ideas into writing.
It could work.
Tuesday, August 15, 2006
Interesting hoax
James Ransome
More options Aug 8
The Heritage Trust Group,
8,Caledonia Place,
St Helier,
Jersey JE4 9YL
Channel Islands.
Warm greetings!
I am James Ransome, Senior Credit Officer, Heritage Trust Group. I am writing
following an opportunity in my office that will be of immense benefit to both
of us.
In my department we discovered the sum of £12.5 Million British Pounds
Sterling (Twelve Million Five Hundred Thousand British Pounds Sterling) in a
Trust Account that belongs to one of our foreign customers Late Mr. Morris
Thompson, an American who unfortunately lost his life in the plane crash of
Alaska Airlines Flight 261 which crashed on January 31 2000, including his
wife and only daughter. Please check the following website for further
reference:
http://www.cnn.com/2000/US/02/01/alaska.airlines.list/
Since his death, we have been expecting his next of kin or relation to come
over and claim his money because the Bank cannot release the funds unless
somebody applies for it as next of kin or relation to the deceased as
indicated in our financial guidelines.
Unfortunately we learnt that his supposed next of kin being his only daughter
died along with him in the plane crash leaving nobody with the knowledge of
these funds behind for the claim. It is therefore upon this discovery that two
other officials in this department and I decided to do business with you and
release the money to you as the next of kin or beneficiary of the funds for
safe keeping and subsequent disbursement since nobody is coming for it and we
do not want this money to go back into Government treasury as unclaimed bill.
We agreed that 20% of the funds would be for you as foreign partner, 10% would
be given to charity while the balance will be for my colleagues and I. We will
visit your country upon conclusion for the disbursement according to the
percentages indicated above once the funds are safely deposited in your
account. Please be honest with us as trust is our watchword in this
transaction.
As soon as you receive this email you should contact me by return email
whether or not you are willing to enter into this deal. In the event you are
not interested, I sincerely ask that you disregard this email and tell no one
about it. I hope you can be trusted in this regard.
Please, note that all necessary arrangements for the smooth release of these
funds to you have been finalized. We will discuss much in details when I do
receive your response via any of the contacts as given above.
Please in your response include your telephone and fax numbers for a better
communication between us to my email address : jamesransome@uk2.net
Yours truly,
James Ransome
Monday, August 07, 2006
Iced Coffee
AOL Proudly Release Personal Data
Thursday, July 20, 2006
Michigan Police Brutality
Thursday, May 11, 2006
FreeBSD on dell 8600 laptop
Sunday, April 30, 2006
Changing gears
We really had some suprises this time around though. I don't think that anyone was ready for the fact that using an async model in ASP.NET would actually hurt us on overall performance, ASP.NET 1.1 seems to have a peak throughput of 1k req/sec on the machines that we use as well as some really nasty thread contention problems. With IAsyncHttpRequest we ended up using a maxio/maxworker setting of 5 which allows us to saturate at around 600 req/sec. If you leave the setting at the default of 20 or use 100 as we were using for the old sync model you quickly land in thread contention land, population 1 very unhappy cpu.
So anyways, back to doing research, coding and thinking. I will be doing a lot of reading on SQL performance tuning but if there's one thing that I've learned through the years of working on large servers: think about and do the hard stuff first. The best optimizations will be made in the overall application design. It must account for the difficult performance problems because it's the one part that you will have the most trouble changing later on if it's wrong.
Finally got a solid SVN setup at home.. I had been wondering for so long why I couldn't reach my wired machines from the wireless network but the converse worked just fine. I was thinking I had problems with my routing tables etc until I got the idea to look at my firewall settings. Ding! We have a winner. I feel like an idiot :P
Sunday, April 09, 2006
How bored am I?
So I'm pretty bored, it is 4:30am and it's hard to sleep now since I actually got _too_ much sleep today, 6 hrs about standard for me currently. I updated my myspace profile.. they should rename it wasteofspace.com but apparently a lot of people like it and now that so many of my friends use it to communicate I have to link myself in with that whole business. Eventually it will probably go the way of friendster and be replaced by some new hip and trendy ad-riddled bling-fest.
Actually got to go out with Lindsey tonight, we went to Ross' art show. He had some really cool mixed-media stuff on display. We had thai food just off of mercer and went to this rock-n-roll piano dualing bar called 'Howl at the Moon' to meet another friend.
Watching my stress simulation ramp up.. It doesn't look too hawt, we had to back out a really good performance improvement because it broke everyone else. Boohoo ;)
Wednesday, March 29, 2006
Wednesday, March 22, 2006
Pragmatic Programmer Quick Reference
I highly recommend buying the real deal. And if you like that also get this one.
Welcome to the war
And so I present you with a vi vs. emacs link fest:
An impartial view with good factoids on both sides.
Bullet lists sucks.
An emacs guy takes some pot shots at the VI crowd.
I have to wonder though did he think before he used the subheading, "Emacs: the tool of tools"? This is typical of the war-time volley, here's a sample smithering:
"I often tell people that you only need to know one vi command: :q!. This way, if you ever accidentally start up vi, you can get right back out. You might want to follow that up with rm /bin/vi to keep it from happening again. In reality, I know just enough vi to get the system up and running and to get Emacs installed; I'll then leave vi behind and never look back."
The vi lovers guide
If the title didn't give you enough of a hint of the flavour perhaps this will:
"I use Vim because I simply don't know of a better editor, but, admittedly, I haven't seriously tried anything else."
He makes up for this with a great set of links to useful information and a concise history of vi in the beginning.
A study of novice and regular users usage of the two editors.
"There appears to be no advantage for a regular user of one editor to switch to the other."
However novices liked emacs better.
References
to actual 'scientific' research into the perfect editor.Yes there are actually people trying to have a scientific discourse about this stuff.
Tim O'Reilly uses VI.
I have to admit that although I'm not a big Tim supporter lately the fact that he uses VI almost makes up for his web/mix 2.0 conferences but his response here is high on the rubbish factor. Shenanigans!
A funny little rant.
"Emacs is for people who desperately want to get drunk, but feel guilty doing so without a reason."
A typical flame war.
Taking a poll of public published net opinion.
An emacs user admits that emacs key bindings make you retarded.
You can always bat for either side.
Conclusion:
If you're a programmer and you've never given your editor any serious thought it would benefit you to think about the tools you use to ply your craft. I don't encourage people to select one editor over another but whatever you use you should invest at least some invest some time into your tools. My preference is vi, I've used it for 10 years and it feels like a natural extension of my brain at this point. It pains me to see people programming by using the mouse to select words from an intellisense drop down menu.
Tuesday, March 21, 2006
Justin Frankel is not dead
MDX On the Xbox360
Here's a few links to some related blogs.
Saturday, March 18, 2006
Croquet: 3d collaboration environment video
Ruby Hacking Guide
Friday, March 17, 2006
Game development on rails
I am trying to determine what the right user interface for this game would be. Currently I'm leaning towards an abstract, hex based board that is implemented using javascript. I haven't really had much experience in client side javascript but seeing what people are doing with ajax these days makes me wonder what kind of interactive environment one could build with these technologies. First step would be to produce a proof of concept and see what kinds of ideas that sparks.
Writing this stuff in ruby is a blast.
The little game world is fun to play in so far I can do the following:
Farming: Fish, wood, metals, plants
Crafting: No recipe parsing yet just old shoes are created for any recipe
Movement: Move to any linked location
Respawn: Materials are respawned at variable rates
Skills: Object actions are tied to skills, you level the skill based on difficulty
Inventory: All items can be stored in inventory and then added to a recipe and crafted
At some point combat would probably be a requirement but I'm so bored with combat systems anyways that it's just fun to play with harvesting, crafting and exploration.
Anyways, this is all just mental gymnstics.. Here's a little sample log of fishing in the opening instance:
>> Welcome proj
>> Got 5 Potions
>> Got 2 Pickaxes
>> Got 2 Axes
>> Got 1 RabbitsFoots
>> Got 1 BasicFishingRods
/mats
>> Executing command: 'mats' nargs: 0
>> Material: Stream 2/10
>> Material: Stream 2/10
>> Material: Stream 2/10
>> Material: Lake 2/10
>> Material: Stream 2/10
/use BasicFishingRod
>> Executing command: 'use' nargs: 1
>> Use requires target, please /target 'thing-name' or 'self'
/target Lake
>> Executing command: 'target' nargs: 1
>> Targeted harvest location for material: # 2 resources left
/use BasicFishingRod
>> Executing command: 'use' nargs: 1
>> Got one RainbowTrout
/use BasicFishingRod
>> Executing command: 'use' nargs: 1
>> Got one RainbowTrout
/target Stream
>> Executing command: 'target' nargs: 1
>> Targeted harvest location for material: # 3 resources left
/use BasicFishingRod
>> Executing command: 'use' nargs: 1
>> Failed skill test for 'fishing' (level: 1) on Stream (difficulty: 15)
Thursday, March 16, 2006
I want PyChecker for Ruby
http://pychecker.sourceforge.net/
I wonder what work from the ruby2c folks could be used in this endeavor.
Singletons considered harmful to your health
Here's the conversions that I've made in order of difficulty:
First conversion, helping compiler remove .data segments with const:
static uint [] card_seq { ... }
Becomes:
static const uint [] card_seq { ... }
static const char * string_table {}
Becomes:
static const char * const string_table {}
Second conversion, removing uninitailized data in the .bss segment:
void single_threaded_converter(byte *buffer, uint32 size) {
static byte more_than_buf[1024]; // becomes stack variable or input variable
...
}
Third conversion, converting singletons to explicit initialization:
class MyEngine {
static MyEngine &instance();
};
Becomes:
class MyEngine {
static MyEngine *create();
static void release(MyEngine *p);
};
... There is lots of references to cleanup here since lots of stuff likes to refer to engine (yeah I know I'm lazy)
There is a single exported entry to bootstrap your application in SymbianOS. It now creates the engine. There is still the issue of getting sub-system pointers to objects that need them in a clean way. I have to visit the whole object heirachy at this point to clean this up. The funny thing is that I really don't like singletons that much anyways. This is similar to the wake up call I had when I thought it would be a good idea to use STL in a large production server.
Slow movement is better than no movement
Wednesday, March 15, 2006
The evolution of a programmer
Tuesday, March 14, 2006
GameHack March 2006 - Gspace Postmortum
Last weekend a few friends got together for a game hack party. Nothing too formal just sitting down and working on some game ideas. The idea was to use scripting languages to build the games. I feel that the success of the projects that we undertook had a lot to do with this choice.
I've been pretty addicted to ruby since I picked it up recently and so I was pretty determined to build a game with it.
People started showing up between 2 and 3 and after eating some food and chatting it was time to get down to business. John decided that he wanted to work on the game with me so we started brainstorming. We both are interested in board games, tactical rpgs and sci-fi so it comes as no suprise that we decided to put together a little turn based space game.
John is well versed in the lingo and logistics of interstellar warfare so I let him drive a lot of game design. I focused on asking the correct questions and focusing these ideas into a working game.
Quickly I had drawn a sample game board and some units on the whiteboard.
We drew up some tables for unit strenghts, sketched out the flow of the game, round and turn transitions and talked about how combat would resolve.
At this point John had never written a lick of ruby so I worked with him directly to begin defining the game. Step one was the game model. I coded up the game base classes: Game, Player, Location, Unit, Weapon, Defense, AttackType, DefenseType. Once we got this out of the way John went off and started creating tons of different weapons, ships and defenses. I wrote a game loop driver to test the turn logic and make sure the basic objects were working together then I went off to write all the graphics for the game. It took a few hours to get this stuff pounded out. I basically just created the units out of 2d primitives. I created a selection cursor and enabled the user to select and move units using a simple arrows and spacebar as selector control scheme.
John's wife Leslie had some dinner waiting for us at their house so we went over there ate and I spent some time writing a zoomer that would interpolate scale and translate of the board to a selected unit. This was supposed to be for the unit information HUD but I ended up scrapping it. It still looked pretty cool though (you can press 'I' on a selected unit to zoom in on it). The fact that all the units are vector based and not little sprites makes this look really cool.
After this we quickly got the HUD working showing unit stats: hull strength, movement points, arament and owning player. John and I worked closely on this part of the project quickly iterating features until the game was playable.
At this point we could spawn whatever ship we wanted on our turn and use it to attack the other player. The weapons that John created were great: Tactical Nukes, Microwave Lasers and Auto Cannons.
What went right
1 Using ruby for prototyping
This was an awesome language for a project like this. We were able to use very clean object-oriented code to easily visualize the game. The keyboard handler took a hash of key ID to blocks of code which made adding new keyboard logic super simple. Since we weren't using source control it was great that ruby allows you to write new methods in a seperate file that are added to an existing class. John could iterate on his battle mechanics adding methods to the Unit class while I was cleaning up the Unit movement in game.rb. As an experienced programmer John was able to get productive in ruby under an hour.
2 My graphics extension to ruby 'RubyCube'
I had spent some time before the party closing the gap in terms of game programming for ruby by writing a very high-level graphics programming extension that hid all the low level details like movement, updating animations, render queue etc. This made it super-simple for me to write all the graphics code in a few hours in ruby.
3 Pair programming
John and I worked very closly in this and picked each others code apart. We were able to catch tons of little problems in the game logic just by sitting down for a few minutes and writing code together.
What went wrong
1. Wasted time on polish like the zoomer
I spent an hour working on this code without even ending up using it.
2. Using a non-compiled language
It was often very painful to know if some branch of your code would break because of a mis-named variable or other small error. This made testing each feature interactively and right after it was written very important. However, in a game things get complex quick and as more code started to interect we ran into more and more problems. We probably spent the majority of our time fixing little errors like this in the game logic. It would have been really nice to have a ruby lint type program to find all the little misspellings.
3. Only working on the game for 12 hours
If this was one of the 24-72 hour game competitions we could have gotten a lot more done like this. I think with more time this game could be even more fun.
Conclusion
It's a great feeling to have a finished game up and running in so short a time. Having a game prototype up and running that exercises the milestones of the game design something that I will continue to do in the future, even if the game will be re-implemented in C++. It's great to have free tools like ruby to do this. I'm looking forward to the next opportunity to do this type of rapid game programming.
You never catch up
Monday, March 13, 2006
On10 Covers KEXP
Quotix Software Updated their Lua IDE
Spore demo video from 2005 GDC
On Large Scale I/O
Something to try
2. Open the book to page 123.
3. Find the 5th sentence.
4. Post the text of the sentence in your journal...along with these instructions.
5. Don't search around for the "coolest" book you can find. Do what's actually next to you.
Neither the cashier nor the customer would be able to leave until the "trasaction" is completed.
From 'The Best Software Writing I'
Sunday, March 12, 2006
GameHack March 2006 comes to a close
1 combat shmup done in LuaSDL (LuaChiea) with Xbox 360 controllers
1 turn-based tactical space game done in Ruby with custom engine bindings (RubyCube)
Not too shabby :)
Wednesday, March 08, 2006
All your innovation are belong to us
Alternate universe: WoW as MUD
Could it be that MMOs are designed for noobs?
FFXII Scores 40/40 in Famitsu
Just don't forget to drink your potion.
10 Personas for Innovation
The Learning Personas
Individuals and organizations need to constantly gather new sources of information in order to expand their knowledge and grow, so the first three personas are learning roles. These personas are driven by the idea that no matter how successful a company currently is, no one can afford to be complacent. The world is changing at an accelerated pace, and today's great idea may be tomorrow's anachronism. The learning roles help keep your team from becoming too internally focused and remind the organization not to be so smug about what you know. People who adopt the learning roles are humble enough to question their own worldview, and in doing so, they remain open to new insights every day.
1. The Anthropologist brings new learning and insights into the organization by observing human behavior and developing a deep understanding of how people interact physically and emotionally with products, services, and spaces. When an Ideo human-factors person camps out in a hospital room for 48 hours with an elderly patient undergoing surgery, she is living the life of the anthropologist and helping to develop new health-care services.
2. The Experimenter prototypes new ideas continuously, learning by a process of enlightened trial and error. The Experimenter takes calculated risks to achieve success through a state of "experimentation as implementation." When BMW bypassed all its traditional advertising channels and created theater-quality short films for bmwfilms.com, no one knew whether the experiment would succeed. Its runaway success underscores the rewards that flow to Experimenters.
3. The Cross-Pollinator explores other industries and cultures, then translates those findings and revelations to fit the unique needs of your enterprise. An open-minded Japanese businesswoman was taken with the generic beer she found in a U.S. supermarket. She brought the idea home, and it eventually became the "no brand" Mujirushi Ryohin chain, a 300-store, billion-dollar retail empire. That's the leverage of a Cross-Pollinator.
The Organizing Personas
The next three personas are organizing roles, played by individuals who are savvy about the often counterintuitive process of how organizations move ideas forward. At Ideo, we used to believe that the ideas should speak for themselves. Now we understand what the Hurdler, the Collaborator, and the Director have known all along: that even the best ideas must continuously compete for time, attention, and resources. Those who adopt these organizing roles don't dismiss the process of budget and resource allocation as "politics" or "red tape." They recognize it as a complex game of chess, and they play to win.
4. The Hurdler knows that the path to innovation is strewn with obstacles and develops a knack for overcoming or outsmarting those roadblocks. When the 3M worker who invented masking tape decades ago had his idea initially rejected, he refused to give up. Staying within his $100 authorization limit, he signed a series of $99 purchase orders to pay for critical equipment needed to produce the first batch. His perseverance paid off, and 3M has reaped billions of dollars in cumulative profits because an energetic Hurdler was willing to bend the rules.
5. The Collaborator helps bring eclectic groups together, and often leads from the middle of the pack to create new combinations and multidisciplinary solutions. Not long ago, Kraft Foods and Safeway sat down to figure out how to knock down the traditional walls between supplier and retailer. One strategy--a way to streamline the transfer of goods from one to the other--didn't just save labor and carrying costs. The increased efficiency sent sales of Capri Sun juice drinks, for example, soaring by 167% during one promotion.
6. The Director not only gathers together a talented cast and crew but also helps to spark their creative talents. When a creative Mattel executive assembles an ad hoc team of designers and project leaders, sequesters them for 12 weeks, and ends up with a new $100 million girls'-toy platform in three months, she is a role model for Directors everywhere.
The Building Personas
The four remaining personas are building roles that apply insights from the learning roles and channel the empowerment from the organizing roles to make innovation happen. When people adopt the building personas, they stamp their mark on your organization. People in these roles are highly visible, so you'll often find them right at the heart of the action.
7. The Experience Architect designs compelling experiences that go beyond mere functionality to connect at a deeper level with customers' latent or expressed needs. When Cold Stone Creamery turns the preparation of a frozen dessert into a fun, dramatic performance, it is designing a successful new customer experience. The premium prices and marketing buzz that follow are rewards associated with playing the role of the Experience Architect.
8. The Set Designer creates a stage on which innovation team members can do their best work, transforming physical environments into powerful tools to influence behavior and attitude. Companies such as Pixar and Industrial Light & Magic recognize that the right office environments can help nourish and sustain a creative culture. When the Cleveland Indians discovered a renewed winning ability in a brand-new stadium, they demonstrated the value of the Set Designer. Organizations that tap into the power of the Set Designer sometimes discover remarkable performance improvements that make all the space changes worthwhile.
9. The Caregiver builds on the metaphor of a health-care professional to deliver customer care in a manner that goes beyond mere service. Good Caregivers anticipate customer needs and are ready to look after them. When you see a service that's really in demand, there's usually a Caregiver at the heart of it. Best Cellars, a retailer that takes the mystery and snobbery out of wine and makes it simple and fun, is demonstrating the Caregiver role--while earning a solid profit at the same time.
10. The Storyteller builds both internal morale and external awareness through compelling narra-tives that communicate a fundamental human value or reinforce a specific cultural trait. Companies from Dell to Starbucks have lots of corporate legends that support their brands and build camaraderie within their teams. Medtronic, celebrated for its product innovation and consistently high growth, reinforces its culture with straight-from-the-heart storytelling--patients' firsthand narratives of how the products changed or even saved their lives.
Tuesday, March 07, 2006
Does language influence thought patterns?
I have been learning a new language every year for awhile now. Even before I read the pragmatic programmer I had been doing this out of curiousity and just being a over-zealous hacker. I noticed that I would cross polinate a lot of ideas, objects in C, message systems in C++ after doing Objective-C, data driven design and the idea of ubiqitous associative arrayness from Lua. This year I have been fortunate enough to find Ruby.
Today I found this quote in a nice Ruby presentation:
Sapir-Whorf Hypothesis
The Sapir-Whorf Hypothesis theorizes that thoughts and behavior are determined (or are at least partially influenced) by language. […] To this day it has not been completely disputed or defended, but has continued to intrigue researchers around the world.
A language that doesn’t affect the way you think about programming is not worth knowing — Alan Perlis
The Takahashi Method
I first heard about the takahashi powerpoint presentation style at the last Seattle.rb meeting. I'm not much for powerpoint but this idea is entertaining to me in a deconstructionist-wordplay as art way. Takahashi Masayoshi wrote a book on this and is also involved with Ruby in Japan.
Here's some, more, info ..
I think this method works best in Japanese.. Latin characterset is just too bland.. perhaps wingdings would be more appropriate! Or perhaps the 'Lessig method'.
This method may suck for any kind of material that would be reviewed later unless accompanied by synchronous audio/video.
Interface mockup as design doc
Xara Xtreme
Friday, March 03, 2006
The wonder of Cell Dynamics
Wednesday, March 01, 2006
Feb 28th Seattle.rb meeting
There were some other interesting people there that I didn't get to spend much time talking with like Geoffrey Grosenbach.
Later on there was some interesting talk from people involved in ruby VM improvement and language design.
Anyways, a lot more community activity than I had envisioned!
Tuesday, February 28, 2006
GPLv3 weighs in on DRM and Software Patents
Interop with Digital Ristrictions Management
Using the GPL you must provide a way for a user to sign their own binaries to run on their machine. The license will ensure that if you get the source you can actually build it and run it on your machine.
Conferred Patent Licenses
Anytime you release something as GPL you are also giving whoever uses that code a license to use your patent. If you don't tell someone that it uses a patented idea that you know about you are responsible. The end user is now specifically indemnified from damage. Think SCO suing end users because of supposed patent infringement.
License Compatibility
Certain additional requirements are allowed that require citation of original author(s) credit as well as preventing the use of a company name to sell their derived product.
Overall I think these changes are good and fit with the original spirit of the GPL.
These was also a good presentation that RMS did on software patents for the CCC.
Friday, February 24, 2006
GameHack 2006 Annoucement
March 11th 2006 will be our next get together for our sporadic game hack-a-thons. We will be focusing on scripting and it's use in rapid prototyping from a game development perspective.
1. You must use an interpreted language.
We recommend you use an established toolkit
Perl::SDL
Lua Cheia
Ruby SDL
Your web browser and JavaScript
2. We’ll meet early Saturday morning/afternoon and go till Sunday. Feel free to participate anytime during the weekend.
If you can’t attend in person that’s okay I’m going to setup an IRC channel so everyone can communicate if you want to participate remotely
4. You can of course keep working on your project afterwards but we encourage anyone joining to try to complete it in a day.. this limits the scope and hopefully ensures that people get something done.
LOCATION: TBD
IRC CHANNEL: TBD
Stay tuned for more.
Please email jacobrepp at da gmail if you plan on attending.
Thursday, February 23, 2006
Straight out of the movies
Tuesday, February 21, 2006
Lunchtime conversation with Mass
I think this sez it well:
"The whitespace issue isn't a big deal (I use a good text editor), but I've spent too long debugging make files to be comfortable with invisible-yet-syntactically-significant characters. Python does have the advantage that it doesn't dictate how much whitespace to use, but I'm still leery of issues with copying and pasting code from a web browser or a newsreader."
And as Mike put it (paraphrased ;): "No programming language worth it's salt considers white-space important"
I've spent plenty of hours doing style based stuff with code but I actually enjoy it to an extent. I always invest a certain ammount of time in the physical structure and form of my code. Twisted? Yes, I think so.
Monday, February 20, 2006
Pimpls and RubyCLR
The first one is about the RubyCLR bridge by John Lam. This is pretty incredible. I'm interested in the performance of the bridge but it could be something that is useful for writing tools that have a nice windows interface. I have really gotten a lot out of WinForms over the past 2 years.
Second is related to a topic that I spend too many cycles on: logical build structures. Unfortunately the unfortunately named pimpl idiom requires more than altering logical build structure it has a runtime cost on your software too. I think programming to interfaces is good mojo but it really makes me miss the opaque data hiding you can get away with in C. I think I've already completely swallowed the precompiled header pill. Newer versions GCC have done a lot to validate this opinion for me.
Massimo says:
"and privates are best hidden (except in some Scandinavian countries with more liberal laws)."
Quake networking
Brian Hook explains the Q3 networking model
Some people trying to disect the packets Q1 -- this seems a bit shaky but provides more detail than Hooks explanation.
It would be good to back this up with reading the code since Q1-Q3 source is now open.
Sunday, February 19, 2006
The Periodic Table Table
Music Genome Project 'Pandora'
MAY LISP HELPS???
Check this out:
http://www.tfeb.org/lisp/mad-people.html
And how 'bout an actual post:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=3D55298A.1020303%40pontos.net
Maybe nonstop programming will eventually make you crazy.
As Mass suggested:
Massimo says:
that should be what you say when John or Lit ask you in a meeting how we can get better perf from presence...
Massimo says:
"May LISP helps?"
True that!
Later on.. Massimo finds Ilias' video:
http://www.molvania.com/video_medium_2.html
Friday, February 17, 2006
First run in the emulator

Finally, after a lot of effort I got the game up in the real emulator. I'm sure there are a lot of problems still left to sort out but I am really happy to have gotten this far. All the graphics core and game logic is compiled and running now. The renderer is using the pre-dithered 12bit image data and all config and graphics are being loaded from a unified pack file.
Update: If you ever plan on running on real symbian Symbian OS hardware, don't use globals... come to find out they're not allowed (unless they're const?). This utility called petran throws an error 0xfffffffe :P
So too much work to clean that up tonight.. I'm super tired from this week and I know that the kids will be up like clockwork at 7am to usher in another day. I have a faint memory of saturdays spent sleeping in. Nahh.. that couldn't be real.
Historical software
VisiCalc for DOS 1.0:
http://www.bricklin.com/history/vcexecutable.htm
Borlands first series of compilers:
http://community.borland.com/museum/
And my favorite, some of first C compiler sources:
http://www.cs.bell-labs.com/who/dmr/primevalC.html
So many good tidbits in this last article.
Thursday, February 16, 2006
First impressions of Ruby
And so begins some adventures with Ruby...
I downloaded the tarball to my WinXP laptop, unpacked it and tried building with the Visual Studio 2003 Toolkit (free C++ build environment) and the XP sp2 Platform SDK. I ended up with a link error __ftol2 was missing. It seems to be related to automatic integer to float conversion, you can turn it off with '/QIfist (Suppress _ftol)' in emBedded VC++ 3.0. I found another post in a msdn forum about watching out for different compiler/library combinations so I decided to go scrub my PATH. Sure enough I see that I have VC98 tools on my path as well as VC2003TK. I decided to clean build using the old MSVC6 compiler tools and my problem went away. I may try to rebuild using the newer compiler and libraries but it works well enough now for me.
After installing ruby and adding it to my PATH I started translating a UML sketch I had in my head from earlier into some ruby code. The idea is just a prototype for a virtual interaction model. Within an environment you generate a state for each unique interactable object. An object may be linked to multiple states to represent samples within a timeline with one state being the 'active' state for a given 'view' of the environment at any particular time.
The view window may be moved freely over the environment to select the current active 'state' for each object in the environment. Interaction in the environment is handled by a Proxy which holds both a command stream and a state stream and is wired to a client. The remote client sends commands to the proxy and reads states. The environment reads the commands from the proxy and updates states. Anyways it's a pretty generic idea but just something I wanted to do some 'sketching' with in a free form programming environment.
I had very little experience with ruby entering into this so I was looking up things like, how to define object attributes, write methods, iterate and specify control blocks as well as constructing objects. I got a skeleton system running in no time flat without even really knowing the language, color me impressed. Once the basic system was up and spewing stuff in a meaning full way to the console I set about filling in the details.
The next step was to build a UDP client and server class and tried to run them on different 'Threads' in the same process. This was a mistake. Ruby has an interesting threading model, one which I can appreciate the implications of having written my share of multithreaded. The ruby runtime is exclusively single threaded, it doesn't take advantage of native threads, instead it simulates threads within the virtual machine. From an implemenation standpoint this makes a lot of sense. The ruby runtime doesn't have to manually synchronize any of it's internal shared data structures to protect from multiple thread access. It's just plain easier and more reliable to implement things this way. If you know the sync/half-async pattern or understand how an OS kernel/scheduler is designed you can invision the ruby runtime this same way. The Ruby executable is the kernal on which you may have multiple environments (stack, instruction pointer, registry file and ??) running at the same time. Co-operative multi-tasking primitives are provided for your ruby code.
Well this is all fine and dandy for most applications but the abstraction is leaky. Anytime you call out to an OS procedure that blocks you freeze the entire ruby engine. So even if you create multiple threads to read and write data on a socket you're not going to realize the benefit of those threads because one thread that calls socket.recvfrom() is going to block the other thread from even calling send() or any other thread for that matter that wants to get some useful work done. So this sucks because it means to due significant server work you can no longer use the 'easy way'. I don't have a complete answer for this yet but here's what I think are my outs right now:
- Use non-blocking sockets. There is a module named IO-Reactor that sounds promising.
- Write an async extension module for ruby using win32 IOCP CreateIoCompletionPort(), GetQueuedCompletionStatus().
I'll try reactor first as it seems straight forward. The idea of using IOCP in an object oriented scripting language seems really cool however. While considering this I had some initial thoughts.
Would it be possible to use injection to put it into the IO module/class heirachy? IOCP is useful for monitoring sockets and files so why not expose this in the base IO library on windows.
For truly asynchrounous handling I imagine something like an internal event queue in the ruby runtime. An event dequeued by the runtime will cause the current thread to yield and passes control to a block that was registered with the IO operation and passed as an argument on the event.
The simpler approach is to just expose the blocking read from the completion port directly. You would multiplex your IO here but you still run into the problem then calling this read will freeze all your worker threads. You can always do a non-blocking read by passing timeout of 0 to the GetQueuedCompletionStatus() routine.
The hybrid approach is to service the port in an external thread and serialize these via a queue that the ruby runtime method reads but may never block on. One benefit of this approach is that you can take advantage of the optimization of servicing a single port on multiple CPUs. Another benefit is that you could provide a higher level message based API that essentially handles spooling multiple completions into a full message to cut down on the thunking cost of having to service every completion from ruby.
Dude where's my access violation
The Trac Project
This seems like a really useful project. It combines your keey seed infrastructure you would need if starting a small software company:
Source Control
Ticket Tracking
Documentation
It seems to have some really neat features like the ability to track your progress against a milestone.
All text looks to be wikified which is awesome. If haven't already experienced wiki in a dev org it is a really good thing.
Wednesday, February 15, 2006
Introduction to SDL_perl by Ars
And now for some related link soup:
The great computer language shootout
An empirical study of multiple languages for a string searching program
A cool site that came up when searching for performance comparisions
37 reasons why I love ruby
Addressing the issue of epoc emulator speed
Also in a forum post 'Nokia_Archive' said:
"Find the file called PHONET.DLL and rename it to PHONET.DLL.IGNORE. That cuts start-up time from 2 mins to 20 secs for me."



