API
Manifesto
Why?
Examples
Editor

A word or two about javaScript

by Justin Kempton 11-15-2014

The way many people end up writing javascript is messy and confusing

Web developers who find themselves writing javaScript tend to write it as a quick means to an end. The thinking goes like this... what is the fastest way I can get in and then get out of this process so that I can get back to 'X' which I'd much rather be doing. Thinking like this leads to faulty code, often copied from other sources that does not match the structure needed for the task at hand. Of all things, this is the source of messy and confusing code.

Code is information and process gathered into a structure

When you are writing code, you are organizing information. The structure of that organization needs to be apparent to yourself and to others. Ideally, it should follow a consistent pattern which greatly adds readability and fluidity to the whole project. But it should fit the task, nothing spells confusion like orphaned logic devoid of meaning. Once you get into the rhythm of writing code it becomes as expressive an art form as any medium. When you feel that rhythm, you have found the sweet spot, where the code nearly writes itself.

Good structure makes work a pleasure instead of a task

The human mind like any logic processor yearns for good organization. When you enter a clean kitchen, with good separation of utensils, consistent and easily accessible access to pans, oil, eggs, towels, the task of cooking becomes a pleasure. Instead of struggling over the layout of the kitchen, you focus on the quality of the food.

Frustration leads to resistence to learn better ways

Imagine always having to face that grueling task of a messy kitchen. Would you be excited to cook, or more excited to order out? Developers who face the code equivalent of the messy kitchen can develop a visceral dislike of the javascript language due to their experience with poorly organized and overly complicated code. But it is not the language to blame, it is the poorly organized code.

JavaScript is a good and versitile language, and it's here to stay

javaScript has all three mechanisms of a powerful language. Primitive Expressions, Means of Combination, and Means of Abstraction. Many of the hottest languages borrow ideas that became popularized in javaScript. Though there is an easy argument that it doesn't deserve to be, English is the dominant human language on earth. As a language goes it's not all bad. One might argue that spelling of words is kinda crazy, but that is because of how highly adaptable English is for new words. English is clearly here to stay. Javascript is the most widely used computer language on earth; running natively on more devices than any other. If you write code for websites then you need to learn how to write good javascript.

JavaScript is the easiest language to learn

Because it runs on more devices than any other language, and because it does not need to be compiled first, it is a trivial matter to test code in a web browser. Anyone with a browser can learn javaScript. Further, there are more resources for learning javaScript online than for other languages. Making it the easiest language to learn.

Lots of libraries already written, the good and bad of it

Because the language is so easy to learn and duplicate, modify, and test, the amount of awesome code out there is staggering. If you are building a website and need a specialized widget, chances are there is already 3 or 4 versions of it. Often the best approach is to copy and paste and be quickly done with it. Let me offer an alternative way of looking at this problem. It can be extremely tempting to avoid spending time learning the language when all you are doing is copying little bits of code from here and there, tweaking it, and pushing it out to production. This is a great way for the noob to start with programming but don't make a career out of it. You need to learn how the language works. Instead of struggling for hours trying to get some crappy widget to load the way you want, imagine being able to write a whole new one in 15 minutes from scratch. Sounds crazy you say? How easy is it for you to formulate a grammatically correct paragraph on your favorite subject? You see, if you know the language, then it is quite easy. And consider this... which approach will be better for you in the long run?

Easy to learn, easy to write, but that does not make everyone Shakespeare

Not everyone can be as prolific as Shakespeare. Sometimes the hardest thing to do is organize your thoughts into a conveyable form. Good writers know that it can take many drafts of working a problem to arrive at a solution that is worth anything. It is the process of editing that improves the writing for the next time. You'll never get better staring at a blank screen. And the best way to learn is by doing.