Archive for December, 2007

So

Monday, December 31st, 2007

I am at the office, alone. I somehow thought we had work today, I mean, it is not even a bank holiday. But everyone else seems to have known, because I am the only one here. So I drove down to Santa Clara just for thrills. What do people do down here? Right now I am considering making the geek pilgrimage to 1 Infinite Loop to look at the sign, which is sadly something I have always wanted to do. 

Bye bye mybloglog

Friday, December 28th, 2007

I took off the widget for now, I don’t have the time to make delayed loading work right. Might try again later.

Wonderful

Friday, December 21st, 2007

The mybloglog widget takes 2 seconds to load. I am going to delay it.

Sloooow

Friday, December 21st, 2007

Performance on this blog sucks. Right now I am caching the home page to disk, which is quite fast. I got really ambitious and was planning on using apc user cache to keep the homepage in memory, but dreamhost makes me run my custom compiled php as fastcgi…which means no shared memory space and no apc user cache.

Oh well, at least the disk cache homepage is nice. For the tiny amount of traffic I get disk cache should do the job. Cache refresh is really hacky, and comment posting remains slow. (also the stylesheet is busted for the comments page…) But I have a day job…

New Stylesheet

Friday, December 21st, 2007

So I made a new style sheet for this blog, so now it doesn’t look like every other wordpress blog on earth. Enjoy!

Wrong

Wednesday, December 12th, 2007

I stumbled across this widely linked post about arrays in javascript. The author, who I believe is generally well respected in the webdev world, goes on about how you shouldn’t use arrays in JS as hash tables, because an array in JS is just an extension of object. Now, clearly, the Array() constructor is generally to be avoided for the reasons noted in the article.

However, if you use var myHash = [] in any world other than prototype, you will be able to happily use it as a hash table, because it is an object and in javascript objects ARE hash tables. So sure, creating a var as an array doesn’t strictly mean anything if you are using it as a hash table, but I think it is actually good practice, because when a developer sees a variable declared as [] they generally expect it to be an array or a hash of key=>value pairs. I just don’t really see the problem here.

Maybe on his team the author would rather use object literals for hash tables. Fine, but that doesn’t make it harmful to declare an object as an array and populate it as a hash. Further, in the comments several people seem to complain about for…in, which is totally insane because it is the only form of object reflection available in javascript! Its completely essential. I suppose people just need to be careful about “considered harmful” articles, because in a flexible, dynamic language you can do whatever you want. Some things might be slower, something might be worse practice in most cases, but its a flexible language, use it how you like.