« archives

January 2008
S M T W T F S
« Dec   Feb »
 12345
6789101112
13141516171819
20212223242526
2728293031  

recently

news from around the web

» view all

Archive for January 25th, 2008


Static vs. Dynamic Typing

Friday, January 25th, 2008

Every good programmer probably has to write about their opinion on this subject once in their lifetime, so here’s my take

As part of my consulting gig I work on “Enterprise Java” code. I just had to write this line after receiving two separate exceptions on the matter (types obfuscated to protect the guilty (and they are oh so guilty… I won’t get into that)):

String somenumber = (String) ((TypeAttribute) TypeCache.getTypeFromCache("Thingie") .getAttribute("someNumber")).getValue((Thingie) object);

You’re a freaking computer! Figure it out for me!

Also, xkcd, as always, says it the best.

It’s revealing to be a Java programmer every 2 weeks, and a Ruby and Flex developer the next 2 weeks, with PHP and JavaScript by night. I understand everything about why static typing is good and proper, but today, when computers (and compilers especially) are powerful and intelligent, I think the computer should do what a computer is great for, namely figuring out extremely complex yet orderly relationships between types of things, leaving the programmer to focus on much more important stuff.

When I’m coding in Java, it takes me 50 lines of rudimentary logic and typecasting muck in a new inline comparator class to do something as simple as sorting custom objects.

In Ruby it’s a one-liner. I don’t care how much less efficient that is for the computer (and it’s not), that is worth its weight in gold in programmer time and code elegance.

I enjoy dynamically typed languages, and any good programmer knows that it’s programmers having fun that makes good software, not programmers spending 50% of their time dealing with code that gets in their way. What kills me most is that computers are really good at automatically doing the stuff that’s not fun—that is in fact what they’re designed to do—and there are people who have fun making that stuff fast, so why don’t we just let them?