Just finished reading ‘Javascript – The Good Parts’. Here is what I learnt:

  • I knew jack shit about JavaScript. I was able to get along so far simply because I knew jQuery and understood how closures work.
  • Holy shit that’s one fucked up language. Quite schizophrenic, saved by almost limitless extensibility/monkey-patchability/watcha-gonna-do-write-a-java-applet-hahaha .
  • If you’re going to write Javascript, you’ll have to subset. Subsetting/augmenting has its own share of problems – primarily that map in your code might not be the same as map in someone else’s code, even if they seem to be working on the same ‘type’
  • jQuery is incredible. I guess it is sort of like a ‘Standard Library’ of sorts, atleast on the client side. I’m sure there exists something similar on the server side as well (underscore.js, perhaps?)
  • I haven’t written any sufficiently large Javascript program yet. Need to fix that.

Defensive Programming

When you’re writing PHP, you program defensively. The language is out to get you. Make one wrong step and it’ll fuck you over. Never assume anything, make sure you always check the documentation. You can’t trust the language. It’s not stupid, it’s schizophrenic.

I think I should start treating JavaScript also that way.