Why I'm Becomming a JavaScript Convert
benjamincoe.com
benjamincoe.com
It seems to me that with the advent of Node.js and document oriented databases that use JSON for their document description, such as MongoDB, Javascript will become the world's most used language. I think Javascript's momentum is unstoppable.
Time will tell.
Probably adding the necessary features to JavaScript to make it more appropriate for these tasks would ruin it for the things it's really very good at.
Just use closures. Thats less code than you would have in many other languages.
Python code bases scale easily, in my experience.
That said, I don't really think Javascript is all that special. Prototype OO sucks.
Prototype OO precludes introspection. You have "an object", and that's as much as you can ever know.
Although I completely agree with you about Prototype OO it doesn't necessarily preclude introspection. You can find out what kind of object it is (by looking at the constructor property) and you can iterate the methods and properties. Introspection is not a problem. But there are no guarantees -- if you find out that your object is a "bicycle" there is no guarantee it has a "pedal" method even if it had one on creation.
Maybe it will be perfected as new versions come along. We should push in that direction if we feel there are rough spots right now.
I've learned to love it. I wish there is JS hosting solutions as simple to run as php for newbies. Remember the first one giving such a service, appjet, was bought by google by millions. There is market for JS on the server.
There is market for JS on the mobile world too. APIs are wonderful, see all you can do with canvas, svg, websockets, etc. all managed thru JS and you can do wonders with them.
If the whole iPhone/iPad experience could be accessed using JS apis, it would grow the ecosystem by tenfold. I hate objective C, but I could easily build a thousand apps in javascript overnight. No kidding.
JS is here to stay, and I am happy for that.
Edit: "it took 10 years before people were able to even recognize them" isn't quite right. It would be better to say that it took 10 years for people to reassemble the pieces that were left, like a vase from antiquity or one of those fragmented biblical codices.
I had it downloaded about a year ago and made a few toy projects, but nothing serious enough to really give it a proper workout. (And I don't have a VPS to actually launch anything on...)
On a side note I recently wrote up a sliding puzzle in JS as a pre-loader for Cadmus. Might not be as complicated as the Tetris game but it was fun to write (and test).
http://blog.anomalyinnovations.com/2010/04/a-sliding-puzzle-...
i can't reassign a variable in an upper context. i can mutate the object it refers to, but i can't reassign the variable right there. instead it gets instantiated at the current level.
that's why javascript has "var". it has real lexical scoping.
IIRC python 3 has the "nonlocal" keyword to "fix" this mess, but i'm not pleased by that. i read the PEP and understand their reasoning. still, it's different behavior from what other languages do (notably scheme and js). they can't even make proper lambdas, but that's because they painted themselves into a corner with the syntax.
a freeform mode for python might solve the lambda issue... but then we'd have ruby or javascript, pretty much.
what tips the scales for me (i use python most) is libraries and environment. javascript doesn't yet have a real command line scripting experience. microsoft's windows scripting host and jscript come close, but all the library documentation is scattered throughout MSDN. i much prefer python's HTML documentation. it's terse and easy to browse.
Yes I'm probably ranting; I've spent a large portion of the last 12 hours writing a bunch of Javascript that I really shouldn't have had to.
See: http://ajaxian.com/archives/true-javascript-hash-table
Personally, I've never really regarded this as much of a problem.
Javascript's syntactic nicety is higher there, but on balance I think python's is far superior.
Both great languages, though.
I wonder if anyone has done an OS command line shell with JavaScript as the scripting language - having commands pipe JSON to each other could be rather cool.
Personally I work on Narwhal (http://narwhaljs.org/). All of Cappuccino's (http://cappuccino.org/) build tools are written in JavaScript (and Objective-J) using CommonJS APIs now too.
Also, Narwhal comes with a nifty "json" tool to convert Unixy formats to/from JSON: http://narwhaljs.org/json-tool.html
For a bit I was doing a fair bit of PowerShell scripting and bash scripting at the same time and I ended up concluding that I still preferred the Unix command line. Using JSON as the "standard" data format would seem to me the ideal compromise between delimited lines of text (Unix shells) and full blown objects (PowerShell).
After reading "JavaScript: The Good Parts" and with the arrival of things like Node.js I have come over from being a staunch "C as a first language" programmer to learning to not only accept JavaScript, but to embrace it, and the power that comes from becoming proficient in the only programming language understood by both the web browser and server.