So, here's the thing. If you go into working with JavaScript thinking "wow, it will be like Java, only scripty" you are in for a world of disappointment. I think this is the reason people's immediate reaction to the comment "I'm learning JavaScript" is to shake their head sadly and respond with "I'm sorry. Broken language."
This is a mistake. First off, I know broken languages. Hell, I've invented one. JavaScript, has its problems, but the largest one is due to the rocket scientists who decided to name it, well, JavaScript. It was, of course, originally known as LiveScript, but for marketing reasons the name was changed.
And hilarity ensued.
Instead, try this mental shift: think of the language as cScript. You know, c, only scripty. I know, you're thinking this is crazy, but work with me for a moment.
The syntax is very c-like, down to the ?: ternary operator, braces, and naming conventions. Now, unlike c, it isn't typed, but that's what makes it scripty. Plus, everything we do to work around c's typed nature -- void *, memcpy, function pointers, etc - just causes memory leaks, architecture dependence, and pain, so isn't it nice to have a language that does that for you? Even the method of extending JavaScript objects -- by creating functions and adding parameters in -- looks a lot like what happens when you apply OOP principles to c.
Now, it is dog slow -- hello, why the hell isn't it JIT-ed? -- and shows quirks from having evolved amidst the browser wars. But with the canvas tag and other sexiness looming on the horizon -- not to mention the uber-fast ActionScript engine in Flash -- I'm having a blast. This weekend I get to start working on my first test app, which will be fun.
For JavaScript, I worked through O'Reilly's "Learning JavaScript." The reviews are correct -- there are a lot of typos -- but thanks to Firebug I turned most of those into learning experiences. I also am most of the way through "Learning PHP and MySQL." Same problem -- lots of typos -- but I thought it did a pretty good job of filling in gaps. However, in comparing how it used PHP to the "Head Rush Ajax," I thought the Head Rush book's approach of writing simple HTML, using AJAX to fill in the dynamic data, and applying PHP as the server language to generate JSON and XML data fits my brain better than the Learning PHP book, which is all about using PHP to generate HTML directly. That way seemed really awkward, required Smarty templates, and just looked like a lot of work.
Current plan of record, for those following at home, is to do first pass of test app in PHP, then recreate it in Rails. I figure the compare and contrast should be enjoyable.
Thursday, January 17, 2008
"JavaScript".replace(/Java/, "c");
Thursday, January 03, 2008
getting rolling
It is awfully strange to be sitting in San Francisco but not in the Linden offices. I'll get to my 2008 predictions later today, but thought it worth noting what technology I've started using to craft my new, post-Linden identity and work flow. The most obvious piece is this blog, which a few people seem to be reading already. I'm used to writing longer form works -- and regularly blogged internally at Linden -- but I expect it will take a while to find the right voice, frequency, and topics for this. There are enough other places to read virtual world and technology news, so I'll try not to just echo what you are already RSS-ing elsewhere.
The next pieces are communication. My Yahoo Mail account gathered dust during my time at Linden, so rather than resurrecting it, I moved to Gmail. So far, I've been quite happy with it, especially with its new support for IMAP and helpful advice on how to properly configure it. The new Google apps for iPhone also work well for me, so I am also using Google Calendar and Reader on both my desktop and phone.
For a computer, I grabbed a MacBook -- although it the rumored thinner versions appear next week I will upgrade -- since the lighter weight and incredible battery life was more important to me than the horsepower of the Pro. Great little machine so far, plus I think a pretty good development platform for various experiments -- if something runs nicely on a MacBook today, it should run on most computers a year from now. I let iCal pull from Google Calendar so my phone is mostly up-to-date, but have not bothered with more complicated solutions to try and sync between iCal and Google Calendar yet.
I'm currently bouncing between Google Docs, iWork, and soon plan to experiment with Scrivener as writing and brainstorming tools. The Google Docs to Blogger posting almost works, but I haven't found how to have it automagically set the title, which is a shame, since the Docs editor handles Mac short cuts far better than the Blogger one.
So that's it for initial technology. Having built Ubuntu laptops for testing SL, I considered going that route, but being a Mac household -- more on my cloud of Mac Minis for television viewing in a later post -- I decided it was easier to stay with Mac.