Javascript blues

This is a rant. I’ve been working on a rails web app and wanted to implement some sexy-axajy-cool-stuff. After adding jQuery to my repository and copying some examples from the documentation I had a somewhat working prototype. After working with it a bit more and trying to change a few things I realized I had to bite the bullet and actually properly learn Javascript.

I went on vacation without a network connection but with a Kindle book about the language and some downloaded jQuery API docs. My conclusion was that I really don’t much care for Javascript. In fact I resent it, because if I want to get this done I have to use it. One of the things I have always liked about web programming is the freedom to use whatever environment you want since the code runs server-side. The modern Web is increasingly less like that.

It’s just sad that it came to pass that this single language is the de-facto standard for the web and so many developer hours are spent coming up with fast interpreters and JITs. Why not just put JVM/Dalvik/CLR in every browser and let developers ship bytecode for it? Surely it must be easier to specify and test a bytecode and DOM API as compliant across browsers than all of Javascript’s shenanigans.

I’m a blub programmer and want to be able to program my client-side frontend in Ruby just like everything else in my apps. I don’t do enough regular programming to be able to be proficient in very many languages. Over the last few years Ruby has allowed me to code everything from webapps to sysadmin scripts without too much hassle and yet I’m still far from an expert. If I have to learn a whole new set of (horrible) syntax and semantics, as well as a bunch of new frameworks, the productivity of what little time I do have to program will be just too low.

But enough about me, here are a few examples of what having a bytecode instead of language target on the client would bring:

  • Write a single codebase for form validations and use them both for server side and client side with no changes
  • Fallback automatically with no extra code to full server round-trips when client-side execution isn’t available.
  • Test all backend and frontend code with the same tools without having to do somersaults to instrument the browser and actually have faith that all browsers execute things the same way.
  • Write thick and thin clients based on the same codebase, potentially switching between the two in-browser (think offline Gmail based on the same code as the server side one)

Right now I’m facing a steep learning curve of new syntax, libraries, testing frameworks, etc, to gain nothing but access to the platform. I’m not getting any functionality Ruby couldn’t give me and I’m losing a bunch of integration possibilities with the existing server code. A few projects exist to run Ruby over Javascript but none are stable enough to be usable.

I’m just going to have to go back to pulling my hair over Javascript.