Sunday, August 23, 2009

I'm taking JavaScript seriously

Well after reading an article by Larry O'Brien @ SD Times magazine (sorry no link, I read the physical copy) about how people aren't taking JavaScript (JS from now on) seriously, I decided to do blog about it.

So what's JS? It's a programming language mostly used @ client-side programming, it is the key to all those awesome effects you see or experience in your favorites websites, one of the crucial components in AJAX (which itself is only a technique), but as I called it: "The technique which built the Web 2.0", so AJAX is something important, we all know it, but JS is important too.

So JS allow us to add some nifty effects like changing the value of some of the HTML elements of a page, ok nothing out of this world, but if we add all the jQuery (include your preferred library here) DOM effects and AJAX-powered page dynamics and you got the current web, not only the current but the web we'll probably be building for the next 5 years (10 if the adoption of the semantic web or web 3.0 as Tim O'Reilly likes to call it takes longer). Again, you maybe asking yourself that I'm not saying anything you didn't know, but guess again you 're wrong.

JS is a programming language and as all languages have bad scripts and good scripts, I bet most of you don't optimize your JS code, probably if Firebug doesn't show an error, you are done working on that script, what about optimization? there's always room for that (yeah we the dinosaurs who know C++ are optimization freaks), JS is becoming more important on the web with each passing day, so is obvious that the future bottlenecks on websites will be because of bad JS code. So if you start know taking JS seriously, you probably will avoid these network traffic problems in the future, so the question remains what can you do?

The first thing to do is to learn that JS is an incredible dynamic and object oriented language and that the fault for the slow JS is in ourselves. Second you can start using tools such as YSlow and debugging, performance and benchmarking tools to see where your JS code is taking the hit. Finally we are all afraid to change our code, "it worked yesterday, now I made a couple of changes and bang it doesn't work. Darn it, let me clone the repo again.", yeah that's why programmers began using TDD and BDD (mostly TDD for this scenario) because with a full test suite you can change your code without fear (hell you can be Daredevil, the man without fear or Dan Dragon as that comic book is called in Spain), bottom line test your scripts.

Finally, I want to add that I can't make better JS code for you, you will always have to sit in that chair and code it yourself, good night.

No comments:

Post a Comment