My Stuff
Love
Respect
Admiration
My Amps
Links
Archives


Add this feed to a running copy of BottomFeeder

Linux World 2006 Speaker

Saturday, November 20, 2004

 
Weak Typing and Bad Programmers

Alright, I went looking for Javascript info while I was writing my Life Simulation and I found two pages noteworthy: Javascript Rocks and it's nemesis, Javascript Sucks. Both pages have great points and things to ponder. There's a bit that I agree on both of them, but I'm firmly in the camp that thinks Javascript is a powerful lisp-like language encumbered with C syntax that's been messed up by the browser wars. But, enough of my incessant whining, one thing that caught my eye as an against of Javascript is that it is "weak typed". It's described in one the links outside of the Sucks page. It's also been talked about blogs, but I can't remember who's now. The example given is "3" + 1 returns "4". And this is bad. Well, if you think about how tolerant the browsers of HTML, why would javascript be any different? I'm not saying it's a good thing. In fact, I think it's a bad thing, but it's not something to blame the language for. It's the damn programmer who wrote that code in the first place that should be blamed! Javascript is typed (it knows to do the conversion and it will complain when I send it a message it doesn't understand. Basically, the auto-conversion is only on operators). I've never been bit by it because I make sure where I need numbers, I convert them to numbers! Same goes for strings. I don't mix the two and depend on automatic conversion (you should never rely on automatic conversion...SAY WHAT YOU MEAN AND SAY IT MEAN!) I think it's wrong to blame the language and it makes an easy scapegoat for bad programming. If you're surprised by something the language does or you don't like that it does it, then DON'T DO IT! In this case, make sure your objects are converted to the right types and be done with it. If you get surprises anywhere, it's because you didn't code it right. When I make a mistake, the last thing I do is blame the language or compiler. I blame myself. Take responsibility. Stop blaming the language. Languages are only amplifiers. Pick the one that amplifies your thoughts better and be done with it. OK, I'll get off my soapbox for now...=) Bottom line is that I don't want my language to control me...I want to take responsibility when I break my code. Remember, bad code is bad code not matter if the language is weakly, strongly, dynamically, and/or statically typed.

Comments




Metalheads Against Racism



This page is powered by Blogger. Isn't yours?