Skip to main content

Onload

I've spent a lot of the past decade writing Javascript. The language was rough at first--just like the browsers that implemented it--but over time it's evolved into an incredible environment. I particularly like the way it filched features from Perl, another language that I happen to like.

If I had to reduce my Javascript programming philosophy to three words, I'd choose the title of Paul Graham's essay, "Succinctness is Power". Every profession--medical, legal, engineering, programming--has shorthand incantations that save time and reduce ambiguity. As outsiders, we look at another profession's shorthand with disdain and confusion. Some of the methods I advocate here will probably trigger objections along the lines of "That's not clear enough, it's better to spell it out so everyone understands what you're doing." I say that it's worth learning the shorthand of Javascript, it will serve you well in the long run.

Mainly, I've created this blog as a fun outlet for little tidbits about programming in Javascript. In particular, it will discuss my favorite features of Javascript, ones I think deserve more attention. Javascript isn't just in browsers, either; you can write programs for Windows Scripting Host (WSH) and Active Server Pages (ASP) in Javascript too. I have a few tidbits for Javascript in those environments as well.

Comments

Popular posts from this blog

Tragedy of the WebKit Commons

With Opera announcing that their future products will be based on WebKit, the Internet is abuzz with discussion about what that means and whether it's a good thing. Looking at it as a jQuery developer, it's a good thing if it gets WebKit participants to fix bugs and update older implementations. I can't be optimistic without some evidence that things are really going to change. We don't know how many of Opera's core developers will move to WebKit development, but the press release isn't encouraging:  "The shift to WebKit means more of our resources can be dedicated to developing new features and the user-friendly solutions."  I suspect they want some cost savings by eliminating Presto technical staff, or -- in the most optimistic case for their employees -- refocusing existing staff on the parts outside WebKit core that make browsers different. Opera did  land their first WebKit patch  so they wanted to make a statement that they weren't gettin

Please Stop the jsPerf.com Abuse!

According to many of the tests on jsperf.com , jQuery is slow. Really slow. The jQuery team gets bug reports from web citizens who've discovered these egregious flaws via jsperf and want them fixed. Now, jsperf.com can be a great tool when used knowledgeably, but its results can also be misinterpreted and abused. For example: Why doesn't jQuery use DOM classList for methods like .addClass()? There are at least three good reasons. It doesn't make any practical performance difference given its frequency of use. It complicates code paths, since classList isn't supported everywhere. It makes jQuery bigger, which makes it load slower for everyone, every time. But this jsperf shows classList is much faster! How can you say that? Well it's possible that test is running afoul of microbenchmark issues , and not measuring what it is supposed to measure due to the increased sophistication of today's JavaScript compilers. This is a big problem with a lot of t

You Might Not Need Babel

Babel is great, and by all means use it if it makes it easier to develop your application. If you're developing a library on the other hand, please take a moment to consider whether you actually need Babel. Maybe you can write a few more lines of utility code and forego the need to pre-process. If you're only targeting some platforms, you may not need anything more than plain old ES6. At the very least, make sure you know what Babel is doing for you, and what it's not. Some developers believe that Babel is protecting us from a great demon of code complexity when, in truth, browsers and node are pretty easy to deal with on their own. Let's take a look at some of the strategies for not needing Babel. ES5 is pretty okay: In the days when we used tables for layout and the debugger was named alert() , we would have been so grateful if JavaScript had the features that ES5 has today. If you truly need Babel you are not only a weak programmer, but also an ingrate. Face