More Ramblings from a Los Angeles Programmer

January 9, 2008

Holidays and a New Year

Filed under: coding, daily life, technology, uk life — Tags: , , , , — Josh DeWald @ 5:52 pm

It’s been a while…

I’m ending a nice long 3-or-so week extended Christmas (just me, the wife, and pictures of gifts from family), New Year’s (very cool dinner on a ship permanently docked on the Thames. Those who know me won’t be surprised to know that I spilled red wine all over the table within about 2 minutes of sitting down. The 9 others at the table were quite nice about it) and 5-day Moroccan holiday in Marrakesh (مراكش). The last was quite cool (finally something different from Europe, you can only handle so many castles) but hectic and wearing at times (I can only handle so much haggling.. even though it’s satisfying to only pay 50% of the original price, I know I’m still paying way more than the price a local would pay). Again those who know me will not be surprised to know that I dropped (and shattered) the large tagine that we had purchased… was about 10 feet from our boarding gate at the airport.

And to really but an end to the holiday, my wife is now on a plane back to the States to get us going for our repatriation there. I will be following 3 weeks later, as my year-long stint here in the UK is ending. I have have had an awesome time here, both at work in out and about. Met some great people who I will definitely miss.

And now for something completely different..

To bring things back around to geeky stuff (I tend to skim over other people’s personal stuff, so I understand if you, Reader, have done the same) I have finally started working on my Super Nintendo (SNES) emulator. It is still using the same basic core as the C64 and NES emulators. Main difference is that the SNES using a 65816, a successor to the 6502 which can address 16MB of memory (24 bits) and implements all of the 256 op codes and adds some more addressing modes. When it initially starts up, it is actually in 6502 emulation mode (with bugs that the original 6502 had fixed, which I’m sure provided frustration to many developers who depended on undocumented instructions and bugs). I have gotten some basic graphics to work in the ‘test.smc’ demo included in Y0shi’s documentation, but it is nowhere near even able to get screenshots, but hopefully only a week or so (I’ve spent a feverish 3 or 4 days dedicated to SNES stuff, but probably spent another couple of weeks previously working toward getting an Apple IIGS emulator working, which uses the same processor) to get there.

I have started adding some JUnit tests of the actual instruction implementations, as even minor bugs can truly spiral out of control in the running of the system.

As usual, Zophar’s domain has proved invaluable for obtaining documentation, but I have also used Wikipedia for system overview (memory sizes and the like) and another site I stumbled on just called “Emu-Docs

I will make the code available via CVS or Subversion once it is in a usable state. Apparently my wife never really played the SNES, so we shall see if I can find anything to drive me like getting SMB3 working on the NES did.  I would love to get Super Mario Kart working.

I have been using ZSNES as my “reference” for what a working system should look like (I don’t know if it’s open source or not, but I am only using the executable in any case).

Shoutout goes to the many people who dedicated hours and hours dissecting and analyzing the SNES and writing emulators in C and Assembly which ran on old Pentiums. My Java emulator may one day run at a full speed on a 2 Gig machine 🙂

November 27, 2007

Architecture and Coding

Filed under: coding, technology — Tags: , , , — Josh DeWald @ 8:49 pm

I have the word “architect” in my title at work, which is cool cause it apparently means I know what I am doing but is bad because it means that people assume that I always know what I am doing.

I consider myself a pretty good software engineer, in that I can generally produce working software against the requirements given to me. I actually do not tend to be up on the latest trends in WS-* or frameworks, etc so most of my code is pretty straightforward (I hope). Thankfully others I work with (both at work and on hobby stuff) keep up with things like Hibernate, Spring, Quartz so it allows me to keep track of what people are actually using, versus what the hype is. I will shamelessly take the skeletons of how those systems are used by other co-workers and friends. However, I always try to figure out how to make using them easier if I find bits that are in any way non-intuitive.

I tend to write in an “agile” way. What this really means is that I think about the problem and do some drawings, pseudocode, sketches, pictures, whatever that I need to get something up and running that solves an immediate problem. Then I move on to other components. Realize that I missed a detail. Rinse. Repeat As I move onto other requirements I integrate them with my solution and always try to have a working system that does something.

Back to the point of my story… this is a horrible way to work if you are supposed to “architect” (in the sense of “here is the design, build it”) a system based on a set of requirements. It is very easy to draw some lines and boxes with cool names and leave the “details as an exercise for the programmer.” Bad idea. By the time it has made it to the programmer (unless they work intimately with you on your own team) many of the requirements have been lost, and they are left only with the design. So they implement, or try to implement, what has been given to them. And surprise, surprise, it meets the requirements but does not actually work.

This is when I realize that what I really gave was a design for a “first pass” that would really be a prototype of the system. If I were implementing, it would be easy to turn around and enhance to go to the next level. But in this case, it has already gone down through two other levels of tech lead and off-shore architect. So not very easy to say “ok, so that we aren’t quite there yet, we actually have a million other details to work out”.

So lesson learned there is that however long you would normally give yourself to “design” the system, multiply it by 10 so that you can basically look at every single API and external system being called, and run through every use case you can think of to see if the design does in fact meet the requirements and produce a working system. It really is not enough to see that API X has a method that looks like Y and takes parameters A and B and probably does Z. What happens if you have 1 million sets of {A,B}?

My real point, I suppose, is that being fairly good at designing and implementing your own systems does not make you an architect. And if you are in that position, do not let someone tell you that you only need “maybe a day or 2” to design something if it is of any real complexity (where a good way to measure complexity is how many interfaces exist between various systems). Give yourself at least a couple of days per non-trivial interface.

I hate the feeling of thinking that if only I had had more time my architecture would have been perfect after the first implementation. I hate even more the feeling that it honestly probably would not have been. It is never right the first time.

Or maybe I just really suck as an architect.

In any case, I am currently getting to do the implementation on a quick-turnaround (aren’t they always in the corporate world?) implementation and I am absolutely loving it. Sure, the deadline is quickly approaching. But you know what, it is my project to succeed or fail at. I am using parts of the system that I “architected” and seeing parts where I totally did not think about the problem in low-level enough detail, and trying to fix those oversights. I am getting to play with systems that I have not worked on previously. And most importantly, I am getting to code! Maybe it is the design aspects of the coding I enjoy, but I think not. What I really, truly, absolutely, love is seeing something grow before my eyes into a working system. I love the list of “//TODO” items (and love even more removing them as they get done) and bits of stub code. I love when I get surprised that it works even better than I expected. I love making a database query 10,20,30 times faster through simple application of a decent index. I love keeping 10 things in my head as I move from file to file and implement my ever-growing APIs.

I have no doubt that my methods would scare many of the purists out there. At heart, I am a “just-in-time” developer. For my emulator, I did not implement an instruction until I ran into my “not yet implemented!” exception. Same goes often for other things that I implement. It is a bit of an extreme example of YAGNE, I suppose.

Update (11/30/2007): Added some words I have left out.

November 17, 2007

iPhone Native Look and Feel Wikipedia

Filed under: coding, daily life, iphone, technology — Tags: , , , , — Josh DeWald @ 4:28 pm

As I mentioned before, I used the “schools edition” of Wikipedia and stored it on my iPod Touch (will work on the iPhone as well) for some hot off-line Wikipedia action. What quickly became apparent is that the set of subject index pages that come with it are actually kind of hard to navigate (small text, etc). I figured that somebody had made some set of style sheets that made web apps look like native iPhone apps, and of course someone did.

So what I did was make a basic perl script would crawl through the subject index pages (looking for “categoryname” div tags) and generate an html file that had the same look and feel. Currently all of the index goes into a single page, which gets you the “wipe” effect, but it could just as easily be put into different files. I had to modify the javascript slightly to allow it to link into the actual content pages (the default javascript assumes that all the links are internal to the file… either that or I just couldn’t figure it out). Basically, if an “a” tag has a class of “external” then it’s… external.

So if you grab iphonenav.js from the link above, and modify the click eventListener like so:

addEventListener(“click”, function(event)

var link =;

if (link.className.indexOf(“external”) == -1){

while (link && link.localName.toLowerCase() != “a”)
link = link.parentNode;

if (link && link.hash)
var page = document.getElementById(link.hash.substr(1));
}, true);

You can download the perl script from my site. Just run it against “wikipedia/wp/index/subject.html”. Save the script with a .pl extension. My host seems to be trying to interpret the script, even if I have the extension be “.pl.txt”.

You can see what the end result looks like here. By the way… you should be able to just take that html file and drop it next to the main index page for the Wikipedia schools edition.

As usual with this type of thing, I’m sure people will look at the script and think “what are you doing!?” But it seems to do the job.

November 12, 2007

My very own Hitchhiker’s Guide

Filed under: daily life, technology, uk life — Tags: , , , , — Josh DeWald @ 9:32 am

So I recently bought one of the new iPod Touches (basically, an iPhone without the GSM radio, camera or mic).

It’s cool that it plays music and all, but that’s not what I bought it for. I really was impressed by the way the browser worked and that essentially full-fledged Cocoa applications could be installed onto it.

What I really got it for was so that I can have my dream of an internet-enabled hand-held encyclopedia. I want The Hitchhiker’s Guide to the Galaxy. And now I’m that much closer.

It turns out that there is a “school edition” of Wikipedia, which is a static dump of Wikipedia content that’s been slightly edited and chosen for entries that “appeal to children.” Don’t let that dissuade you, it has an entry on MKULTRA. In their words:

It is about the size of a fifteen volume encyclopaedia (24,000 images and 14 million words), and includes essentially all topics in Wikipedia rated “Good” or higher by Wikipedia itself at date of production. Volunteers at Wikipedia have also suggested more than a thousand other articles considered valuable and relevant to this project which SOS Children volunteers have checked and tidied up.

They have a 750MB download available at Once you de-compress it, you’re left with the exact same thing as what is at the Schools’ version site. Until we truly have ubiquitous, and free, Wi-Fi access (including during flights), this will be an awesome set of information to have on hand.

Unfortunately, Safari on the iPod/iPhone does not support viewing of local files directly with a “file:///” protocol. It reports “Cannot view the page because it is a local file.” It’s a good thing I had already “jailbroken” my iPod, so I just had to install the ‘lighttpd’ web server.

After copying the files to my iPod at /var/root/Sites using WinSCP (you can use any scp program though) into a ‘wikipedia’ directory, I was able to browse to http://localhost/wikipedia on my phone. And voila!

I assume this all works on the iPhone as well as the iPod, as most of the apps are actually meant for the iPhone.

I know this isn’t what Apple intended, yet (they are coming out with the official SDK in February), but if I wasn’t able to do something like this I would not be as pleased with my purchase. I don’t care if there are actually tons of other ways to have a hand-held encyclopedia, how many of them are also a music-playing, mail-synchronizing, calendaring web browser?

October 14, 2007

“Mechanical jokes”

Filed under: books, daily life — Tags: , , — Josh DeWald @ 10:43 am

I’ve decided to revive my ‘quotes’ file that I used to keep. I couldn’t resist posting the first entry into it, because it represents so much of why I love reading and also justifies my dislike of driving. One of the great things about Heinlein (and other authors) is that some of the best passages are really just them doing some exposition on some topic that they are passionate about. The passages tend to be only tangentially related to the plot at hand, but are nonetheless part of what makes the work great.

By the way, the majority of quotes are much, much smaller, but there was no real way to shorten this particular one.

“A reciprocating engine was a collection of miniature heat engines using (in a basically inefficient cycle) a small percentage of an exothermic chemical reaction, a reaction which was started and stopped every split second. Much of the heat was intentionally thrown away into a ‘water jacket’ or ‘cooling system’ then wasted into the atmosphere through a heat exchanger.

What little was left caused blocks of metal to thump foolishly back-and-forth (hence the name ‘reciprocating’) and thence through a linkage to cause a shaft and flywheel to spin around. The flywheel (believe it if you can) had no gyroscopic function; it was used to store kinetic energy in a futile attempt to cover up the sins of reciprocation. The shaft at long last caused wheels to turn and thereby propelled this pile of junk over the countryside.

The prime mover was used; control, only to accelerate and to overcome ‘friction’ — a concept then in much wider engineering use. To decelerate, stop, or turn the heroic human operator used his own muscle power, multiplied precariously through a series of levers.

Despite the name ‘automobile’ these vehicles had no automatic circuits; control, such as it was, was exercised second by second for hours on end by a human being peering out through a small pane of dirty silica glass, and judging unassisted and disastrously his own motion and those of other objects. In ed in his almost all cases the operator had no notion of the kinetic energy stored in his missile and could not have written the basic equation. Newton’s Laws of Motion were to him mysteries as profound as the meaning of the universe.

Nevertheless millions of these mechanical jokes swarmed over our home planet, dodging each other by inches or failing to dodge. None of them ever worked right; by their nature they could not work right; and they were constantly getting out of order. Their operators were usually mightily pleased when they worked at all. When they did not, which was every few hundred miles (hundred, not hundred thousand), they hired a member of a social class of arcane specialists to make inadequate and always expensive temporary repairs.

Despite their mad shortcomings, these ‘automobiles’ were the most characteristic form of wealth and the most cherished possessions of their time. Three whole generations were slaves to them.”

That’s from Robert Heinlein’s Space Family Stone (originally 1952, but this is from a 1971 paperback edition that I paid about $0.40 for, but it’s on Amazon for $29) . It’s one of his “space opera” style deals that, as far as I can tell, has no real purpose other than to tell a story about a family and some experiences of theirs. A quick summer read.

The whole section puts things in perspective, and especially justifies why somebody like me (who tends to be absent-minded while driving) really does not belong behind the wheel of one of these “mechanical jokes”.

Going to end this with a last quote from a friend and co-worker’s Wes’ blog which I had to read out loud to my wife because it was so profound in its statement of the limitless possibilities of reading and the fact that you can only be reading (and have read) so many books, but there is an endless set of books that you have not read and will never be able to get to:

But what can I say: a man only has so many books he can not finish at once.”


October 3, 2007

Design Smart, Code Stupid

Filed under: coding, technology — Tags: , — Josh DeWald @ 11:42 am

“Design Smart, Code Stupid” is just another way of saying “Don’t be clever” at the code level. Remember that as soon as you write some code, you are now its primary maintainer. If the code base is a hobby project, you may be the only maintainer, so you owe it to yourself to make your code easy to read. If its not a hobby project, it becomes even more important (if only to save face!); the last thing you want is other developer’s looking at your code and thinking “what does this line do?!” Instead, another developer should look at your code and think, “this makes total sense, anybody could write this!” A little self-test is to revisit your code a week or two after you wrote it. If it confuses you and produces a lot of “wtf?” then you need to simplify it.

Do you really need to use a ternary operator? Is it honestly easier to do a bit mask and a bit shift in the same statement? You may want to reconsider that nested a.getB().getC().getD().doSomething() you have going there.

So that’s the “code stupid” part… kinda starting backwards here.

So every line should be obvious, but each one should also go toward solving a problem (why else is it there anyhow). As you take the view higher and higher through the system, it should continue to make just as much sense. Each method should be well-named so that a person does not even need to look at it to know what the purpose is: the calling of a method should be as obvious as a built-in language construct. At the class or module level, it should be obvious what role it serves in the big picture. Multiple modules and classes should be “packaged” together as a cohesive unit that solves some problem.

Essentially, at whatever level a person looks, it should be obvious what what the system is doing, and why it is being done in the way chosen (even if there are alternative methods).

And you know what, another developer will look at the design and think “Man, that’s smart!” Because it is not easy to do for any non-trivial problem.

Because you know what, if you don’t have a good view of the big picture design of your system, then neither will anybody else. Instead, you will have a hodge podge of classes and methods that sort of work together. You need to know what it is you are building before you build it. Always think about the Use Cases!

I have no idea if Steve McCcconell uses the phrase in “Code Complete.” I would not be surprised, as entire book is really devoted to the idea of building a system that makes sense at every level. So I know that I am havingaa completely un-original thought, and I’ll freely admit it. I have no doubt read it so many times that its worked its way into me into some sort of meme. Nonetheless, I just thought I’d talk about it for a bit. I try to live it and know that I screw it up all the time.

Update: Fixed the sentence on Code Complete, realized that I had left out like 4 words 😉

September 19, 2007

This is how you methodically troubleshoot

Filed under: coding, daily life, technology — Josh DeWald @ 12:09 pm

I don’t think I could possibly give a better example of how to methodically diagnose (and fix!) an issue.

Scott Hanselman had an issue firing of Microsoft Live Meeting and documents how he found the root cause. Absolutely brilliant.

He really has it all:

  1. Reproduces the issue
  2. Isolates the issue
  3. Gathers data
  4. Makes a hypothesis
  5. Tests the hypothesis
  6. Forms a conclusion
  7. Has a working system

In case it’s not obvious, yes I think troubleshooting/debugging should be performed using the “Scientific Method” as the pattern. Perhaps you don’t always specifically spell out your “hypothesis”, but you need to have one. Don’t spend too much time randomly poking around… methodically poke around. Each time you try something, you need to know what the result of that test will mean for you, and get you further along.

Update: Modified link to be direct, rather than via FeedBurner

September 18, 2007

New Turing Omnibus Mentioned!

Filed under: books, coding, technology — Josh DeWald @ 1:08 pm

For the longest time I seemed to be the only person who loved this gem of a book (I even emailed the author recently and got a nice reply).

Jeff Atwood at Coding Horror just mentioned how great The New Turing Omnibus is (and even points how that he had never really heard of it). He points to an Everything2 article that has a the complete Table of Contents (there’s only 66 chapters)… which I actually put up there in 2002!

It would not be a stretch at all to say that this book is what started me on Computer Science. I was already starting to code in BASIC when I began it (somewhere around Junior High I think), but it opened up a whole new world using very accessible chapters. This was the first time I heard about the Mandelbrot Set, Neural Networks, Cellular Automata (Game of Life!),  and 63 other core Computer Science topics.

Anyhow, Jeff’s article is really where you should head to read about it. Then you should then head to Amazon (or wherever) to buy it.

September 15, 2007

Stepping to the Dark Side

Filed under: coding, technology — Josh DeWald @ 12:43 pm

So I’m working on a hobby side project with a friend and his preference is to use the Eclipse IDE for the Java development. Eclipse makes things so “easy” that an Ant build script wasn’t included in the source repository. My entire Java development history (4 years or so) has been emacs for editing (and sometimes compiling, I like emacs jump-to-error stuff), and command line (using Cygwin) for the building and source control. So naturally I was a bit “put off” by not having an easy way to build, test and deploy the code (which my friend readily acknowledged).

I spent some time creating a basic Ant script which allowed to build the app. Then the JUnit tests didn’t work, because Ant doesn’t yet have support for JUnit 4. I google’d around for the solution, which was to add a suite() method which makes use of a JUnit4TestAdapter. Most of the tests ran but the ones that depended on external libraries still didn’t work, despite the fact that my classpath was set up properly as far as I could tell.

More and more in my life I prefer to not spend time fighting with my environment, so I gave in and decided that I’d give Eclipse a spin… go to the Dark Side. My friend said I should get the “Web Platform” version, which has integration with the JEE and web framework stuff.

Once I got that installed, it also grabbed the SVN Plugin and pulled the source repository down.

I’m still a bit ashamed to admit it, but I think I like Eclipse for the most part.  Everything you can do it in can be done in emacs (or from the command line) with the right modules and whatnot, but really just not as easily.

It’s nice to right click on a class and say “Create webservice” and also generate client stubs. It’ll warn you if the class isn’t compatible with standard WS-I formatting so that you can make sure to create compliant ones (i.e. no method overloading, objects must be easily serializable and public).

It’s nice to add a new method to an interface and be able to “Quick Fix” the concrete implementations to have a default implementation of the method.

Having standard Refactoring patterns available is awesome… having the option to change a method name and have that result in all usages changing is great.

CTRL+Shift+M to add an Import, very nice.

I’m digging on “create setters/getters”. As an aside, I’m going to admit, publicly, that I honestly see no real problem with exposing *properties* as public variables. I don’t actually do it (except for internal classes which I’m treating as structs for keeping some values together) but I honestly find that it is completely unnecessary 95% of the time to actually do get/set vs just allowing access to the method. I’ve also had times when I’m glad that I *did* have the getter, when I needed to delegate it or do some sort of change notification, etc. I’m just saying, that’s usually not needed…

Constant recompiling and the “intellisense” (or whatever Eclipse calls it) for choosing a method is awesome. I worry that those will change my coding style such that I’ll start forgetting how an API looks and will always wait for it to give me the options. I think the auto recompilation could have the effect of ruining my “flow” if I’m consantly trying to fix the all the “red” that shows up during a high speed laying down of an algorithm.

Also, one of the things that has kept me away from feature-rich IDEs is the fear that I’ll “lose touch” with the code. I really like knowing where each and every file is in and how it affects the system. When everything is accessible via a context menu or through auto-generation, I worry that my understanding of how the system really looks will become disjoint. But I’m finding that that fear seems unjustified. Eclipse absolutely doesn’t hide these things from you. When you generate a Webservice, it clearly creates WSDL and service description files. The package structure is readily apparent, you don’t just have a big list of classes with no rhyme or reason (unless you created it yourself, Eclipse certainly isn’t going to).

I’ve been experiencing a lot of lockups, which I think might be related to not giving enough memory (but 256MB should be enough!). I’ll do something trivial like want to create getters/setters and it’ll just stop responding. This happens to me at least once a session. My friend says that this has never happened to him before.

I’m still evaluating and at work I’m still an emacs guy (not that I get to code all that often any more), but if I continue to feel productivity gains from not worrying about the “little things” and can focus on the core algorithms and component interaction, then I think I could become a convert.

… especially once I find the “generate Ant build script” plugin or option.

Remember the ‘nerd test’ from back in the day?

Filed under: daily life, humor, technology — Josh DeWald @ 12:17 pm

There’s a “2.0” one now (it references the iPhone). You even get a cool graphic: says I'm an Uber Cool High Nerd

No, I have no idea what “Uber Cool High Nerd” means. I expected to be given a more “Computer Nerd” title, but such is life.

« Newer PostsOlder Posts »

Create a free website or blog at