Weblog Navigation
First Previous Index Next Last
Finally, A New Job (Thursday, August 28th, 2003)

OK, so, I've got a job working for a company in Kelso Washington (60 miles north of here). For the moment I'm just building a new web site for them, as a contractor working from home, which is great because I don't have to commute for an hour each direction - also, I already have all the tools I need at home: a good editor, a pile of books (plus access to Google), a web server, an SQL server, and about two dozen browsers on five operating systems.

I'm learning some new stuff for this project: although I was already familiar with JavaScript and CSS, I'm learning more about both, and I'm finally learning PHP. I borrowed O'Reilly's JavaScript: The Definitive Guide from my new boss. Wow. This book is awesome. There's a lot more to JavaScript than I was really aware of, and it's great to finally have a resource like this available. Brings back memories of high school, when I'd bring home 2″-thick programming books from the library and read them pretty much cover to cover. This should have been one of them.

PHP is about what I expected. It's mostly like Perl, but a bit simpler, which has both advantages and disadvantages. The way PHP can loop through an associative array and get both the key and value in their own variables (instead of just the key as in Perl) is a neat shortcut (in Perl you'd have to add one extra line to do that, or just use $hash{$key} every time you want the value). However, I wanted to sort an associative array containing associative arrays by a value in the child arrays, and I don't think PHP has a way to do that (in Perl you can write a quick expression with $a<=>$b and sort by any criteria you can think of). It was easy to work around it in this case by writing another loop that built another associative arrays which I could then sort, although I wound up rewriting it all to use SQL and having the SQL server do the sorting for me.

One of the things that's really awkward to get used to is, in both PHP and JavaScript, variables are scoped to the function, not to the block. It's a step up from BASIC where everything's global, and now that I think about it HyperCard variables worked the same way, but I've gotten used to block-scoping in Perl (C and Java are the same). In JavaScript:

if(2+2==4) { var foo="bar"; } document.write(foo);

That works fine in JavaScript and the equivalent would work in PHP, but in Perl:

if(2+2==4) { my $foo="bar"; } print($foo);

Because I used my, the variable $foo is created inside the conditional block, and destroyed when the block ends, so this will print nothing or, with the strict pragma, fail to compile. To get the previous behavior in Perl without using global variables, I would have to declare my $foo; before the beginning on the conditional block.

The most annoying part about this project, of course, is that browser compatibility is just as big a problem now as it was five years ago. You'd think that since everyone is using at least a 4.0 browser or equivalent now, and the World Wide Web Consortium's specifications have been standardized for so long, that it should be simple to just build a page that conforms to the W3C's specs, and everything should be fine. It doesn't work that way at all. Read my rant on Slashdot that I posted last night.

Weblog Navigation
First Previous Index Next Last