Pages

February 26, 2006

Javascript Applications, pt 1

Updated: Continued in Part 2.

Languages (and language studies) are an interesting phenomenon. As we know from anthropology (and middle school social studies), Eskimoes have 20 different words for various kinds of "snow", whereas we have just the one: "snow".

Now, it turns out this is just one more in a long line of urban myths that we've repeated into "truthiness" - and that's also interesting (but a whole 'nother discussion).

We look at language as deeply revealing reflections of underlying culture and structure. And while I don't deny the power that language has and the values that it can imply, I don't believe that it fundamentally enables new capabilities for a society. Is there a language that lacks poetry? Or laws? Or stories? Or religion? And I'm not sure a particular language, in and of itself, has any particular evolutionary advantage - though clearly a particular language's economy of communication is likely a reflection of a culture's evolutionary challenges.

For computer languages, this seems even more apparent. I mean, its pretty much the same CPU underneath, so the language is just a question of vanity and preference, no? It really doesn't matter what language you use, so long as you use it well?

Turns out, not so much
.

Although I think there is a fundamental provability to the notion that good programming is language invariant, the grammar and semantics of a particular language can be measured along a number of axes:


My point here is that language features are not about CAPABILITY: you can (literally) do MORE in Assembly than any other language (although, you know what they say: you can't spell "Assembly" without "Ass"). But languages developed - some evolved, some were designed (intelligently and otherwise) - because there was a need to enable significantly greater complexity and abstraction on top of vastly increasing linear computing power.

Bottom Line? The abstractions various languages provide ultimately matter because they enable significant flexibility, at the cost of some performance. Its all just a question of the value of the tradeoffs.

Pretty long way to go to say that I think while Javascript is great, it also sucks.

I'll explore what features have been valuable and where we've suffered using it to build
desktop applications in my next posts on this topic - along with some specific recommendations (for developers USING Javascript, as well as suggestions for the language itself).

As I've
mentioned before, I think we're among the bold few attempting to use Javascript for Programming in the Large for desktop applications, at scale. Though AJAX is all the rage (*cough* DHTML), the discussions tend to center around "Bitless applications" - stuff in the browser.

A lot of the problems are essentially of the same type (but exaggerated for desktop apps), so I think most of the discussion applies to both, but, obviously, there are some interesting differences as well.

10 comments:

Anonymous said...

Your post brought back memories of an Automata class where we had to use a bare bones programming language (with only assignment, increment, decrement operators and a control loop structure) to compute Turing-compatible functions (shudder)

I think portability is more important than you give it credit for. How easy is it to turn around AOL Explorer for the Mac using Boxley-JScript. Maybe it is easy - I'm not sure but seems like we have some OS layer dependencies...but that will almost always be the case except for the virtual machine pattern a la Java and Swing. But then again, as you say, its a tradeoff -- even though Java UI toolkits have come a long way since the dreaded AWT, they're still painfully slow!

Anonymous said...

p.s. Of course there is no more IE for Mac but you get my drift...

Anonymous said...

You mean, language is actually just a tool? Man how come I never thought of that...

Sree Kotay said...

trekker: I think that's a fair point about portability, and as you say, FAR more essential for web apps and the like.

anonymous: Bite me :)

Anonymous said...

I feel your pain with JavaScript.
We're using it extensively here to build one of our app, which involves a lot of different features and in particular a whole photo sharing application. As we were developing it and facing more and more challenges with JavaScript I started to question if it was a good idea in the end. The problem I saw using JavaScript is that it is too flexible. And programmers tend to abuse this flexibility... As the application grows, it becomes very hard to maintain and debug. One of the solutions to this problem was to enforce the same rules than we have in C++. Meaning, every object should have an interface, no global variable, minimize attaching new members on the fly, etc. Also we added the notion of namespace in JavaScript to prevent code collisions (since every file is being merged into a big one).

It helped us a lot but I am still scared for the future. We have a very modular application (modules being written in JavaScript and communication together with JavaScript) and I am not entirely sure yet how easy it will be to update some modules and not others.

Anonymous said...

A bit more food about JavaScript:
An important thing I forgot to mention is compilation. The strength of JavaScript is its flexibility. But because of its flexibility there are very few things the compiler can assume and detect... Sometimes it is a programmer error, sometimes it is a pure typo. (which you may say, is also a programmer error)
For example, calling a function that does not exist or passing wrong parameters is not detected at compilation time. It will be detected when the program is running and potentially bring the whole application to a halt :( A lot of these mistakes would have been detected in a less flexible language like C++ during compilation.
I've noted that because of this, we're probably spending 30% more time debugging a JavaScript application than a C++ one of same size.
so yes, for computing, language matters.

Anonymous said...

BTW,
I thought you would love to look at:
esoteric languages.
look at the one called "Weird".

Sree Kotay said...

Hey nicolas! How hoes it? :)

"Wierd" is pretty frikkin' funny, but my favorite is still "Whitespace" (on that page, too) - That's how I feel when I program in Python :P

Any you're exactly right about flexibility: give people a hammer, and the first they do is put out their eyes :)

Sree Kotay said...

Incidentally, nicolas, I do think that all of the dynamic language folks are now recognizing the value of strong types - it reminds me of how the trend moved (dramatically) from permissive HTML parsing being all the rage (and ALLLL the problem we now live with) to strict XHTML/standards compliance.

Turns out *strictness* is a positive in language grammars and syntax - and I think that extends to design patterns as well. My favorite designed language, in this context, is postscript - very clean and consistent. Though I *hate* that its a stack machine - the attributes I like about it don't necessarily require that.

Charmingirl said...

Wholesale lingerie directly from China?
As a famous brand and specialized manufacturer of sexy clothing in China. Charmingirl supply the international market with fashionable sexy lingerie and sexy costume since 2002. With advanced technology,all our products are of high quality. Now we have clients all around the world. Lingerie Wholesale and OEM are welcomed!
As a Lingerie Manufacturer, Charmingirl has standard workshop and production line, professional designers and experienced workers.
We do Wholesale Underwear,
Lingerie Wholesale, including corset and bustier,
Sexy Lingerie Wholesale, including bikini, underwear
Lingerie Wholesale, and Babydolls, Sexy Lingerie Wholesale, and
Sexy Lingerie Wholesale including sleepwear,clubwear.
Lingerie Wholesale from China: Lingerie China, you will find the
Leather Lingerie and PVC Lingerie, also you can buy
Christmas Costume and Xmas Lingerie
for your Christmas Lingerie Christmas day.
Our Wholesale center: Sexy Lingerie Wholesale can do Lingerie Wholesale online.
Halloween Costume,
also wholesale Adult Costume with fashion Babydoll Babydoll, and bra and panties Bra and Panties, Sexy Uniform Sexy Uniform is also our major products.