Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JavaScript has a certain elegance to the minimalism, though, much like Scheme:

- You can emulate keyword parameters by passing an 'options' dict, and you can emulate defaults by 'var myOpt = options.myOpt || default". You can also define a function, like $.extend, to do this for you.

- You can catch exceptions of a specified type by checking the type and rethrowing if it's not appropriate. And you can define a function to do this for you:

  function try_catch_if(exc_type, body, exc_handler) {
    try {
      body();
    } catch (e) {
      if (e instanceof exc_type) {
        exc_handler();
      } else {
        throw e;
      }
    }
  }
- You can define your own standard library a la JQuery or YUI, or even modify the built-in one a la Prototype (though I don't recommend this). And the built-in data structures aren't all that bad.

- You can build whatever OOP system you want on top of prototypes, and many libraries do just that. (In this respect, it's quite similar to Scheme, where every programmer starts by defining his own incompatible object system).

Most of the sucky parts of JavaScript come from it introducing things that weren't really thought through, eg. the 'this' keyword nonsense is ridiculous, as is the lack of argument-checking by default.



You can build your own keyword-argument passing style, exception handling, standard library, and OOP system with assembly as well. Most of would rather start with a language that got these features right in the first place, rather than defending languages that didn't.


Totally agree.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: