Learn at Least One New Language Every Year


I am sure almost all of you heard the now classic advice from the Pragmatic Programmer: Learn at Least One New Language Every Year! Since it is a beginning of a new year, I have seen a lot of bog posts by various people acting upon the advice and choosing to learn a language – this year I decided to follow suit, and learn … Javascript.

I can almost feel the disappointment mounting: What the #&$%^*&#*@ why not Erlang? Or Clojure? Haskell? Scala, Lua… ? Why Javascript? That’s so 1990s…

Why Javascript?

The answer is easy: right now I am a Rails web developer (not a distributed system architect, monad detective, human parenthesis parser etc), and though I know enough Javascript to get by in majority of the cases, I’d like to take it to the next level.

Don’t get me wrong: I understand that the rationale behind learning a new programming language is not (necessarily) the ability to put the newly acquired knowledge to use tomorrow, but rather to discover new patterns / schemes (no pun intended). Thankfully, Javascript means the best of both worlds: you will find a lot of new stuff in there (unless you happen to know some other esoteric languages – Javascript is a dialect of ECMAScript based on Self and Scheme) – for example, unlike most of the mainstream OOP languages (which are class-based), Javascript is prototype-based – while at the same time you get a powerful tool enabling you to create more effective web applications.

Using a Motorized Wheelchair Because you’re too Lazy to Walk

Why do you, as a Rails developer need Javascript? There is Prototype. And script.aculo.us. And RJS. And jQuery. And Dojo. And MooTools. And…

I really have to agree with Adrian Holovaty (of Django fame): “(Relying on server-side frameworks to generate JavaScript) is like using a motorized wheelchair because you’re too lazy to walk”.

So true. I am tired of seeing people doing stuff like:

  • Simulating even the most trivial things like $(‘element’).toggle(); with RJS
  • Using oberve_field for everything. The problem is that observe_field in it’s vanilla form sends a request to the server every time you hit a key. It’s easy to replace it with a bit of Javascript knowledge and stop hogging the bandwidth.
  • Instead using Javascript functions like setInterval / setTimeout they are simulating the desired behavior with Prototype / RJS
  • Trying to create great AJAX sites without much clue about Javascript (and just minimal knowledge about Prototype/RJS – spending a week or so on #rubyonrails was enough to experience this in it’s full glory ‘hey plz help bro cuz Im new to AJAX’)
  • Doing all of the above obtrusively – who cares about the totally littered HTML, just get it done somehow

And I am talking about trivial/mundane tasks above – what if you’d like to create your own custom widgets? Optimize your code? Rely on the browser for various things not supported by rails out of the box (e.g. in-browser caching)? Manipulate the DOM? Prototype/RJS won’t do everything instead of you.

(Don’t get me wrong, I am a big fan of jQuery, and application development would be painful and slow without it – I am talking about the fact that in some cases falling back to Javascript is unavoidable and/or ineffective)

Ok, I’ll Still Stick with RJS and I Like it Obtrusive!

Ok, you have been warned. Suddenly It seems not I am the one stuck in the 1990s… but whatever. Ignore JS in your Rails apps at your own peril.

However, Javascript is usable in many other settings too. It’s a general purpose programming language, roughly comparable to Python or Ruby, so it’s a misconception to believe that JS is just some obscure mini-language only good for some browser hacking (similarly as Ruby is believed to be a scripting language, or a language invented to power Rails). So you can do just about anything with Javascript that you would do with, say Ruby.

If you want some interesting specialized usage: building Firefox extensions. Judging by the current trends, browsers are becoming more and more important, according to some people to the point of taking over the place of an operating system. While currently I find that theory a bit far-fetched, it is sure that as a Web developer, you can’t ignore building Firefox extensions. You need a lot of Javascript to do that.

Then there is DOM scripting. You would be amazed to know how powerful DOM manipulation can be once you learn the ropes.

Obviously, you are using a Javascript framework (Prototype, jQuery, mooTools…). Though you can get by quite well with any of them without knowing too much Javascript per se, your effectiveness will go up with the amount of JS knowledge. It’s like learning Rails and ignoring Ruby. You can do it, but sooner or later you’ll hit a wall.

Let’s Hit the Waves

Douglas Crockford’s site looks like a good starting point.
On the book front, I am planning to get these titles (I am not using any referral crap, those below are plain amazon links):

If you have any suggestions, comments, ideas on how to do this thing better, please leave a comment.

Oh, and be prepared for some Javascripts posts in the future 🙂

14 thoughts on “Learn at Least One New Language Every Year

  1. Interesting you mention Firefox extensions because I’ve recently been getting more and more into Javascript coding and found building plugins to be one of the best ways of creating something different/interesting and useful at the same time. I work on sites all day everyday but a nice plugin for say Google Desktop Search is just different enough to get me hooked.

    I took one look at the Firefox extension API and thought I’d try my hand at something a bit simpler first. :p GDS and Netvibes widgets both filled that gap.

    Other interesting projects are:
    * The Konfabulator/Yahoo Widgets.
    * Google Maps API + Local Ajax Search mashups.

    I thought the videos at Yahoo’s YUI Theatre were good. Doug Crockford did a series of lectures there but also the YUI team did a series of interesting vids.

  2. As a ruby developer I can tell you that the first thing I got rid of were the JS conventions. Yes, they can make it easier for you to add some basic JS goodness to your content, but if you really want to control the user experience, you just have to author it yourself.

    I prefer MooTools for many of the reasons I like Ruby. I know Prototype is close to Ruby’s heart, but MooTools was/is inspired by Prototype and it shows.

    Here’s a great full blown tutorial on the library that’s worth looking at:

    http://www.mootorial.com (the tutorial actually begins here: http://www.mootorial.com/wiki/)

    Of special interest is how MooTools makes use of classes as a core part of it’s API:

    http://www.mootorial.com/wiki/mootorial/09-howtowriteamootoolsclass

    Great article.

  3. Great idea to learn a language that will compliment your existing knowledge base.

    This will also allow you the flexibility in of learning other languages and plugging your new Javascript knowledge straight into new frameworks in the future.

  4. While I agree that learning javascript is a good thing (if not a necessity), I think some of your points are flawed.

    *  Simulating even the most trivial things like $(’element’).toggle(); with RJS
    

    In rjs it’s easier to test, easier to read, and less code to maintain.

    * Using oberve_field for everything. The problem is that observe_field in it’s vanilla form sends a request to the server every time you hit a key. It’s easy to replace it with a bit of Javascript knowledge and stop hogging the bandwidth.
    

    This one I mostly agree with, except premature optimisation is the root of all evil, so do it last. Why not submit a rails patch?

    * Instead using Javascript functions like setInterval / setTimeout they are simulating the desired behavior with Prototype / RJS
    

    Again, harder to test.

    * Trying to create great AJAX sites without much clue about Javascript (and just minimal knowledge about Prototype/RJS - spending a week or so on #rubyonrails was enough to experience this in it’s full glory ‘hey plz help bro cuz Im new to AJAX’)
    * Doing all of the above obtrusively - who cares about the totally littered HTML, just get it done somehow
    

    Of course this isn’t a good idea. I think the generally better idea is to submit rails patches if you have more efficient ways of doing things.

  5. I’d highly recommend Douglas Crockfords book, “JavaScript the Good Parts”. It’s a tight read, but packed with good stuff (as the title indicates).

    I did a round-up on JavaScript litterature before christmas, unfortunately it’s in norwegian, but maybe google translate can help. Anyway, you could check out the links there.

  6. Kevin,

    So you are saying using jQuery and unobtrusive JS = ‘my legs are not working?’ Can’t really agree with that 😉

  7. Pingback: Simulating Browsers in Ruby

  8. This blog aided me somewhat in narrowing down some issues with the latest version, Why do they always leave out vital documentation when they release a new version? It may be minor to them but not to me. I’m sure we’re not alone.

  9. Your blog has helped, many thanks. I have come across it maybe once or twice now and will very likely take a note of it. You actually may well really want to update wordpress as there is a completely new release obtainable now!

  10. Your blog has helped, appreciate it. I’ve discovered it once or twice today and will very likely bookmark it. You actually may possibly really want to upgrade wordpress as there is certainly a fresh release available at this moment!

  11. Gelece?in yat?r?m? olarak de?erlendirilen konut ve arsalar emlakdream güvencesi ile istedi?iniz tarzda ve istedi?iniz konumda sizlerle .

    Kartal Konut Projeleri ile ?stanbul Anadolu yakas?n?n en çok de?er kazanabilecek konutlar?n? sizlere sunmaktay?z. Sizler için yap?lan ara?t?rmalar neticesinde web sitemizde yer alan iskanl? konutlar? incelemenizi tavsiye ediyoruz. Bilgilendirmeler için 7 gün 24 saat ça?r? merkezimizde sizlerin ça?r?lar?n? beklemekteyiz.

    Sevdikleriniz için ya?am?n önemini iyi biliyoruz bu yüzden en kaliteli mekanlarda en gözde mekanlar? sizler için derledik.

    http://www.emlakdream.com/etiket/kartal-konut-projeleri/

  12. Hello admin, i must say you have high quality posts here.

    Your website should go viral. You need initial traffic only.
    How to get it? Search for: Mertiso’s tips go viral

Leave a Reply

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