Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Give JavaScript a chance

Let me be the first one to admit taking way too much time to give in and embrace JavaScript. This language is arguably one of the most widely deployed and most misunderstood at the same time. There must be an award somewhere for this amazing feat.

I don't know what causes developers to avoid JavaScript in this day and age. I mean, back in 1995 when it was being introduced, I could understand the disdain. Back then it was a new language with a poorly chosen name (no, ECMAScript doesn't help either) and, probably the biggest problem, a lot of pain associated with the bug-laden and incompatible browser implementations of both JavaScript and the DOM.

Today, on the other hand, I don't see a really justifiable reason for a web developer avoid writing rich JavaScript. We have a very viable install base of browsers with decent implementations of JavaScript and the DOM (not perfect nor uniform, but doable,) we have better development tools, incredible browser extensions, debuggers, unit testing helpers, documentation generators, and, what in my opinion made JavaScript a true professional language: great libraries.

My hat goes off to Prototype.js, Scriptaculous, jQuery, Dojo, YUI, ASP.NET Ajax, etc. The folks behind these libraries really helped JavaScript adoption and boosted developer productivity. They pushed the language to its limits and amazed us with what could be accomplished with a language we used to simply copy, paste, adjust, and pray it worked.

I read this somewhere that I can't remember now, but it's a perfect analogy: You wouldn't write .Net code without the BCL, so why write JavaScript without good libraries?

I see a lot of effort being put into, once again, taking JavaScript away from the developer's code editor, and I honestly don't like that.

Things like GWT, Volta (me too, me too), Script#, and RJS (plus helpers) sound like too much work only to not let developers use JavaScript directly. Why do I need a to write code in one language just to produce code in another language that is perfectly usable? JavaScript is not Assembly, MSIL, or Java byte-code. We can actually write, document, test, debug, version, and deploy JavaScript.

I don't know what is your reason not to use JavaScript but maybe it falls into one of the following categories.

  • You think JavaScript is hard: It's not, I swear. Think about this for a second, JavaScript is considerably smaller than C#/Java/Ruby/VB. Maybe the problem you have is that you are being fooled by the curly braces and thinking JavaScript relates to C or Java or C#. JavaScript only has superficial similarities with those languages. The best advice I can give is to get yourself a good JavaScript book. There aren't many good books but I'll leave links for a couple at the end.
  • It's a lot of effort to get anything done: Just pick a JavaScript library and play with it. There's a wealth of solid solutions and widgets for all sorts of things.
  • I like to write all my code in C# (or VB, or Java, etc) I don't want to get into the debate about polyglot programming in this post but afraid you're setting yourself up for grief and failure. You don't want to ride your mountain-bike in the sand dunes or drive our sedan on the train tracks.
  • But my users can turn off JavaScript in their browsers: That never stopped people from writing VC++/MFC, Java, .Net, or even VB6 applications. You'll have the same problem if you're letting your JavaScript be generated on your behalf.

If you think you need to brush up you JavaScript but don't have a lot of time right now, I'd recommend at least watching the videos linked below.

Links

Libraries

Books

Tools

Videos


Posted 05-03-2008 1:37 AM by sergiopereira
Filed under: ,

[Advertisement]

Comments

Weekly Links 2 « Davy Brion’s Blog wrote Weekly Links 2 « Davy Brion’s Blog
on 05-03-2008 7:17 AM

Pingback from  Weekly Links 2 « Davy Brion’s Blog

gwenhwyfaer wrote re: Give JavaScript a chance
on 05-03-2008 1:16 PM

> I don't know what causes developers to avoid JavaScript in this day and age.

I don't like *using* sites that depend on JavaScript. If I were to *write* such a site, I'd be excluding myself as a target user, which would mean I have no empathy whatsoever with the user base. Which is never a recipe for good development.

However, if I write the site so that it *doesn't* depend on JavaScript, I have a site I can enjoy using, which will motivate me to develop it further.

Seems to me that "I'm not a hypocrite" is a good reason to avoid most things.

Michael C. Neel wrote re: Give JavaScript a chance
on 05-03-2008 1:56 PM

An internal only company app is one thing, but JavaScript on a public site is another.  There is still no guarantee the javascript code will execute the same on all browsers (even if it's enabled), which means I need to "double" my coding to support cases where javascript isn't supported or enabled.

Javascript is a good stop gap solution, but the future will be in RIAs built with things like Flex/Silverlight.  In fact, had Java applets not had such performance nightmares, or ActiveX limited in platform, we might have never see AJAX.

sergiopereira wrote re: Give JavaScript a chance
on 05-03-2008 3:03 PM

@Michael, I agree with you. JavaScript can be just a gateway to a better solution for RIAs. The problem is that the average Internet user takes ages to upgrade their browsers, not to mention install plugins and  accessories like Flash/Flex/Silverlight. Maybe this will take 5, 10 years. I would't be surprised if by then we have aberrations like Sliverlight#, WPF#, or Google Java2Flex Toolkit.

Bryan Kyle wrote re: Give JavaScript a chance
on 05-03-2008 3:40 PM

The biggest problem with Javascript is not the language, but the developers.  Generally, Javascript developers are either novice, or are so used to another language that they code in the style of what they're used to.  This has lead to a proliferation of bad books and poor examples to learn from.  Perhaps this is one of the reasons these projects to abstract away Javascript start.

I've started blogging about the features of the language, and how to make sense of the very different style that Javascript code really should take to help members of my team.

jdn wrote re: Give JavaScript a chance
on 05-05-2008 11:32 AM

Compile-time checking?  A lot of strings?

sergiopereira wrote re: Give JavaScript a chance
on 05-05-2008 11:46 AM

@jdn, you know I was waiting to hear from you, right? :)

Compile-time checking is nice but it's a trade-off. You lose the dynamism in JavaScript. See if the Ruby community misses that, they tend to rely on unit testing instead of compiler checks.  I'm not sure if I agree that there's a "string problem" here. Maybe you've been exposed to bad JS ? (which is kind of the majority of the JS out there, unfortunately)

jdn wrote re: Give JavaScript a chance
on 05-05-2008 12:05 PM

" they tend to rely on unit testing instead of compiler checks.  I'm not sure if I agree that there's a "string problem" here. Maybe you've been exposed to bad JS ? (which is kind of the majority of the JS out there, unfortunately)"

But that's the point.  Because you have to rely on unit testing instead of compiler checks, you have a gap that requires that you know how to write good unit tests that will test JS properly (which is a troublesome thought in itself).  Compile time checks aren't perfect (the most hideously designed code can compile), but it takes out that gap.

JS and testing are leaky abstractions.

Steve wrote re: Give JavaScript a chance
on 05-09-2008 9:25 PM

I use jQuery in conjunction with MS MVC and find it to be very powerful - 'unobtrusive javascript'

Now if I could just get my resharper to work with my jQuery like it does VS 2008 and I'll be set  :)

The Inquisitive Coder » Blog Archive » Weekly Links 2 wrote The Inquisitive Coder » Blog Archive » Weekly Links 2
on 05-24-2008 10:14 AM

Pingback from  The Inquisitive Coder  » Blog Archive   » Weekly Links 2

Sergio Pereira wrote JavaScript: Avoid the Evil eval
on 03-31-2009 6:27 PM

This post is part of a series called JavaScript Demystified . I'm pretty sure by now you have heard

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)