Monday, April 16, 2012

the Javascript Gentleman introduction

This is something I've been thinking about for a while. A javascript programmer is often referred to as a ninja or rockstar. They sound exciting, but what makes someone a ninja, and why would they want to be one? Programming is unlike a lot of other fields, we are actively encouraged to work in groups and share our code yet we're seen as loners at the same time as we sit in front of a screen for hours on end.

What I would like to see is a more mature community where js professionals write their code as it doesn't belong to them. The code we write will be picked up and viewed by other people and it is for them we really should be writing, not ourselves.

I believe there is a set of rules that can be followed and a great start has already been put down with Javscript: The Good Parts. If anything I believe the book doesn't go far enough. The book is a great read and essential for anyone who wants to work on javascript but only deals with specific parts of the language, what it misses are things like code style, naming conventions and just how to organize your code.

As a start everyone should at least read Google's style guide which is a good way to start thinking about code style. I won't tell you how you should style your code - it is something that should be agreed upon by a team but I will go in to what I do to try and make my code more accessible to future programmers.

That is the major point - we should code for others. This is one of the reasons I wrote the JQuery-like interface for the closure library. I know that there is not that much exposure to the closure library so I want future programmers to work with something they feel comfortable with.

I'm going to make some future posts that lays down rules for the Javascript Gentleman which I hope will help anyone who wants to work in a team or write a library for others to use, but for now I'll leave you with this thought - a javascript ninja tries to do cool things by bending the language to his whim, a javascript gentleman however knows how to get the same result by playing within the intended spirit of the language, and in that is the difference. It's not cool to be a gentleman but in the end you'll be respected more and have a greater impact.

No comments:

Post a Comment