Monday, October 5, 2009

Perl and JavaScript

I made a comment in my last post that I thought deserved more comment: "here, as usual, doing it right means doing it like Perl". I do like Perl a lot, but I came to it quite late in the game. In the beginning it wasn't much better suited to writing large programs than bash.

For a long time, C required that all variable declarations go at the top of a block. PHP, well, PHP is still a ridiculous mess, but it's getting better. To quote Pat V., "It's painful to watch PHP make all the same mistakes Perl made 10 years ago." C++ compilers still have some compatibility issues, but even a young guy like me remembers a time when it was even worse, where many compilers barfed on simple template code and the STL was slow and unreliable in many installations. And I can only imagine those poor early Lisp programmers that had to use S-expressions for everything... OK, scratch that last one.

All these languages had the freedom to get better. The programmer that wanted better features could get a new compiler or interpreter; the one that wanted his old code to work could stick with the old version. The language developers could break compatibility and improve the language because programmers had this power. The programmer didn't have control of processor or library bugs on user machines, but those things are usually taken pretty seriously. Adoption of better web standards can take a lot longer, and as long as old browsers are still around they have to be recognized and coded to. About all you can do is add. It wouldn't be hard to give JavaScript variables block-level scope and extent, but it would be really hard to get that adopted.

No comments: