Skip to content

writing stuff in javascript

June 26, 2008

Four years ago, i wrote a bit of code that did directional navigation in the browser.  Basically, if you press an arrow key, we would move in that direction.

I wrote this first implementation in C++ and totaled about 2300 lines of code (about 100 lines were license headers).   Although lines of source code isn’t a great indicator of complexity, I hope you can trust me that the code is, hmm., not very easy to follow at times.

We want to have similar functionally in Fennec.  So, today I rewrote the code in Javascript.  It is only 360 lines — 15% of the size! (about 30 lines are license cruft.)  It isn’t a complete implementation, but does handle most of the cases.  Even if the Javascript code doubles, it will still be easier to understand.

Wait, there’s more –  it performance seems as good as the native implementation on most pages.  Four years ago, writing anything like this in Javascript would have not been an option.  Today, the opposite is almost the case.  Simply amazing stuff.

From → Uncategorized

2 Comments
  1. Well, if function calls in the C++ API were not so verbose, it wouln’t have been so huge… Fortunately, this is going to change in mozilla 2.

  2. Which is why some of us get anxious when major “programming-in-the-large” changes to the language are proposed.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.