Sunday, May 20, 2007

Javascript, like C but without the rigour

I've been trying out some of the AJAX pieces and adding in some Google Maps functionality (of course) to the geo-ripping code base which has required a smallish bit of Javascript coding.

It really is like stepping back in time, and I've had my comments already about static v dynamic languages and these last few days of writing Javascript has brought back to me all of the reasons why I disliked C. I loathed C as a programming language (and note this is not through lack of use, I was an XWindows/Motif/PEX programmer for five+ years) it was bad enough hunting down obscure errors in my code at the best of times, but what I really hated was the "tick tick BOOM" problem of C. Code wouldn't fail with a nice exception like in Ada, it would just die with a great big core dump. This meant lots of "printf" statements or using a textual debugger (and I'm not talking using gcc and its tools here) which tended to introduce different behaviour because of the changes in memory allocation.

Then there was the code from the muppets the people who cut and paste code from one place to another and you got slammed because now you were calling THEIR function instead of your own when it gets deployed into system test.

Well Javascript is all that an so much more. I've been playing about with various different scripting libraries and finding oh-so interesting cases where names of functions clash, leading to the age old shouting at the monitoring say "It is exactly the same as in the F&@KING example", but of course how do you know WHICH script you are calling?

Then we get the slight syntax error breaking everything problem... nice, reminds me of the old "make" scripts.

I know there are libraries out there to take this stuff away, and I sure as hell will be using them next time, because quite frankly the idea of coding in Javascript makes XSLT coding seem almost benign in comparison.

I was against scripting being added by default into Java SE 6 and this brief experience with Javascript has just reaffirmed my reasons. Sure scripting can help occasionally, but it should be a long way from that to considering it as the default. The move towards treating Javascript as a compiler target is a good one IMO, and long may those tools continue to developer, otherwise Web 2.0 will be DOA as soon as it hits support.

Coding in Javascript is worse than coding in C... there are not many languages that can make that claim.

Technorati Tags: ,