January 2006


Johan and Jeff have started a discussion on the relative merits of JSON/JSONP. I think it’s time I threw my two bits in.

There are a couple compelling features of JSON as a format to Javascript coders (I count myself in here). Johan talks about getting around the same-origin policy. I understand the frustration, but I feel uncomfortable opening the door for someone else to execute whatever code they deem fit on my visitors’ browsers. I know they’re not supposed to, but the can. It’s a lot of trust. It’s true that Javascript executes in a sandbox, but the code in question doesn’t have to be intentionally “bad” as Jeff implied. It could be accidentally bad code. Accidentally bad code happens a lot more often than intentionally bad code. It can be worse because it’s Accidental. Accidentally bad code can excersise memory leaks or any other bugs in a browser.

I’m not saying that I write better code than everyone else, just that I can debug more easily if it’s all served from my site. Mixing code and data makes things tougher. Not that we haven’t already gone pretty far down that road. After all, Javascript in a web page is executable code mixed in data.

That said, JSON is clearly a simpler format to process on the client side for JS engines that are not inherently XML-aware. This is changing with support for XPath showing up in browsers, so JSON might be a shortcut for now.

As a content-provider, it looks pretty simple to create a JSON feed from an existing XML feed, so I’ve got no issues with supporting it that way. Well not at first glance. Then again, the feed isn’t guaranteed to be valid Javascript syntax though if I don’t test every feed with a Javascript parser. If I’m doing that and the client also has to validate what I’ve sent them then suddenly we’re both doing a lot more work. What’s more, if users start throwing in references to their own scripts that the server producing the feed can’t see, then how can the server possibly guarantee a valid feed?

That’s the problem with formats that look easy. Most of the time they end up needing some kind of patching later that starts quickly to look like a kludge. JSON’s not the first place this has shown up, just the latest. I mean PHP has had plenty of growing pains and broken plenty of existing code in order to get more secure default behaviour in place. Things like register_globals and the ability to reference a variable without defining it first are places that PHP used the normal behaviour for a script, but that normal behaviour caused big security issues when the language was used to build huge applications. And don’t even get me started on the nightmare of escaping script embedded in text embedded in XML embedded in PHP. Each of those started as an idea to make things simpler and more readable.

When shorthand syntaxes like JSON crop up it indicates that developers feel that there’s too much overhead in dealing with the predominent formats: Atom and RSS XML feeds. Someone could have come up with an equivalent PHP syntax. There’s as much PHP code handling XML out there as there is Javascript handling XML. PHP has an eval() function analagous to Javascript. PHP supports associative arrays and objects. Why not feed my PHP script with PHP code?

I don’t know the answer for sure, but I’d guess that it has to do with the fact that PHP has an established method (well, many established methods) for handling XML. JSON just seems to be a request for data that’s easier to parse. My answer? I guess I believe in proxying on my own server and getting the data ready for my clients in some Javascript that’s easy to run.

As a follow-up to yesterday’s post on taking pictures with the Canon Digital Rebel, today I’ve got a couple notes on getting the CRW (Canon Raw format) files processed in Linux. I think that the tools I ended up with will work for other raw formats as well. I chose to install the Gimp and ImageMagick with Fedora Core 4 when I set up FC4, but neither of those applications supports raw files in the state they’re installed in.
Read the rest of “How to Handle CRW Format Pictures in FC4 Linux”…

Candace graciously loaned me her Digital Rebel for the day so I could get an idea what it’s like to shoot with a digital SLR. She suggested I should at least try it before I plunk down all that lettuce for the Rebel XT. I’m glad I did - her Rebel was really a pleasure to use. It really makes my point & shoot look like a toy. I know I don’t have any real ability with it after just one day, but there were a few things that really impressed me (as a novice) with this piece of equipment.

I played around with it at home for a little while early this morning. I figured that I should leave it on the automatic setting for a while. I’ve learned to appreciate automatic settings on a camera. See, I had a bad experience a few years back at E3 when I got my first digital camera. I didn’t realize how much different the picture on the LCD could look from the same image blown up on a 19 inch monitor. And I knew that indoors with low light, like most of the convention centre, I’d need a higher ISO setting. So I fiddled with the manual settings a bit… What a whole lot of awful pictures. Some were salvageable. Many were so blurry I actually used the word ‘blurry’ in the filename. I’m going to try not to think about that anymore right now.
Read the rest of “Some Digital SLR Notes for Amateurs”…

I bought some Apple the other day. Or rather, I bought some AAPL. I felt inspired and I noticed I had a little cash sitting in my RRSP. I’m not a big investor and I’m not a particularly good investor. I tend to be the “buy, hold and forget” type. The Apple thing just kind of came out of the blue. I find it doesn’t make much difference if I research a company or not. The ones that I read up on and convince myself are poised to do great things are just as likely to flop as the ones that I just guess look cool. So right now, Apple looks cool. A few years ago, I though AMD looked cool, and they’re my best performer now. Well, that is to say AMD has made some gains while I’ve been holding the stock. They’ve been up and down in the mean time though. I suppose if they do really well then I should… Sell the stock. Strange way to reward a company that’s done a good job with your investment - take the money away.
Read the rest of “Full Disclosure”…

From the what-worked-for-me file… two tips today. One on getting sound by turning up the volume and another on getting rid of applications that keep coming back after a reboot. Read the rest of “A Couple Quick Notes on KDE Sessions and FC4 Sound”…

Adrian Woods is giving a talk entitled The Make Art Button: Batches, Actions, and Scripts. I think he sums it up in the session description just perfectly:

Do something once, it’s creative. Do something twice, it’s repetitive. Do something three times, you can probably automate it.

I’ve said the same thing many times, but maybe I start to automate at twice.

This session will use comand-line tools, Photoshop automation, and MaxScript for 3DS Max. For myself, I’ve used plenty of command-line tools, a tiny bit of MaxScript and no Photoshop automation. I do find that a lot of Photoshop tools have counterparts in the Gimp however. Given the work he’s been involved in on Microsoft Flight Simulator, I’m looking forward to hearing what kinds of work he recommends automating and how much effort it’s worth. The question that I have about automation for art is about balance. Specifically how to balance the work needed to produce new tools for automating a very specific task against the work needed to complete these tasks manually. The way I approach this issue is by considering a few factors that are all around time savings, reuse, and repeatability.
Read the rest of “GDC 2006: Automating Artwork with Batches, Actions, and Scripts”…

Why is it that I can pay my bills over the web, I can go shopping online, I can run a business, pay my taxes, check my stocks and plan my vacation all over the web, but for some reason tonight I had to drive around the city, go into a gradeschool gymnasium and scratch some graphite on a scrap of paper to vote? Seems like a problem we should be able to solve…

Anyway, you can see the outcome here. If you’re into that sort of thing.

P.S. I have to admit some of my bitterness was definitely taken away when I saw the smooth AJAX refresh of the results on the page.

Next Page »