Do I really need to learn Javascript?

Javascript has gone from a mechanism for adding tweaks to web-pages to a key implementation technology for building web applications, and even server back-ends via technology such as node.js.

Javascript still divides the programming community. Many C++, Java, & C# programmers find it a very uncomfortable experience: lack of type safety, a single numeric type (floating point), no real classes (it has a different inheritance model). There a various tricks to make things look like real classes, but they don’t feel natural.

Traditional programmers look with horror as experts like Douglas Crockford explain why

 return

 {

 status: true

 };

is not the same as:

 return {

 status: true

 };

 

The new generation don’t seem to have a problem with it though. But aren’t they just creating a mountain of unmaintainable code that will get quickly thrown away and re-written?

Experts around the world acknowledge Javascript has many short-comings, yet still it blunders on, unstoppable…

So what does Javascript have going for it?

Firstly, it’s the most cross-platform language – and it’s always platforms that drive languages: the mainframe drove Cobol, Unix drove C, the iPhone drives Objective-C. As devices get more powerful, more can be done locally on the device. Code that was previously on the server might now be on the device. How many languages can we genuinely get code re-use from across such diversity?

There’s a low barrier to entry – you just need a browser and a text editor. It’s also fun. Within minutes you can be playing with map controls and other cool stuff. Almost everything has a JS library.

The language is also well suited to it’s environment: e.g. manipulating the HTML DOM, and asynchronous call backs, especially for REST services returning JSON

There are ways to tame Javascript. JSLint catches many errors. Google’s JSDoc annotations, and Microsoft’s Typescript augment some type safety. Typescript is more compact, and Visual Studio has good Intellisense support, but as a product of the “evil empire” I suspect adoption may be artificially limited. Frameworks like JQuery and EXT-JS try to standardize browser behaviour.

The only way to be sure is to run it.

However, fundamentally Javascript is a run-time language. Everything is dynamic. Further, its run-time environment is a browser, or an application containing a browser, and these can behave differently. The only way you’ll know for sure if something works is to run it, and run it on lots of different browsers & devices, and keep running it even when you code doesn’t change, because something else might.

Which means the burden on testing changes completely. It cannot be an after-thought. This is where tools like Silk are extremely useful.

Atlas provides a very fluid UI. It’s a Javascript application, interoperating with the server via REST services. We test it using Silk’s State Driven Testing feature, which means we can build the tests are we build the Javascript, and then test it automatically on Chrome, IE and Firefox (various different versions).

So do you need to learn Javascript?

Yes, I think you need to take a look at it, and flawed as it is, you may get hooked. Refreshing to see that Doug Crockford has grey hair, and seems to be coping just fine.

But be prepared to get a lot more serious about testing as well…

Mark Conway
Share this post:
Tweet about this on TwitterShare on FacebookShare on LinkedInGoogle+

Leave a Reply

Your email address will not be published. Required fields are marked *