Computerworld

Bridging the static-dynamic divide

Some are getting the best of both worlds, says Jon Udell
  • Jon Udell (Unknown Publication)
  • 22 January, 2006 22:00

There is a perpetual debate in programming circles about the pros and cons of static verus dynamic typing. I've always favoured dynamically typed languages such as Lisp, Perl and Python because my own coding efforts tend to focus on application prototyping, content wrangling, data analysis and system automation.

So I sometimes struggle to explain to developers who use only statically typed languages how and why dynamic typing can simplify and accelerate these exploratory kinds of tasks. Those developers in turn sometimes struggle to explain to me how and why statically typed languages, such as C++, Java and C# can facilitate large-scale development and integration.

Perhaps these styles will turn out more complementary than we suspect. If so, the ECMAScript family of languages, which includes the various Java­Script dialects and Macromedia's ActionScript, will be one lab in which the hypothesis is tested.

The AJAX (Asynchronous JavaScript and XML) juggernaut is one driver of the trend, having conferred new respect on JavaScript. Then there's Macromedia's Flex platform. To meet the needs of Java-oriented enterprise developers, the company's ActionScript dialect has evolved in the direction of ECMAScript Edition 4 — an envisioned (but stalled) future standard that was sketched out by Netscape in a June 2003 straw-man proposal. Versions 2 and 3 of ActionScript add Java-like class and interface definitions to the language and provide optional static typing.

Among other benefits, declared types enable Flex Builder 2 — the Flex IDE that is now wholly reconstituted as an Eclipse plug-in — to support interactive statement completion. This is the killer feature that Microsoft trademarked as IntelliSense. Java and C# programmers couldn't live without it and aficionados of dynamically typed languages get by without it, but secretly envy how the other half lives.

When I returned from the Microsoft Professional Developers Conference this year, I was ready to openly proclaim that envy. In session after session, presenters were IntelliSensing their way through live coding exercises. The most impressive example came from Microsoft's Anders Hejlsberg, who showed how the type-aware implementation of LINQ (language-integrated query) exposed XML and SQL data structures to the power of IntelliSense.

But then a funny thing happened. Charles Petzold, the legendary programmer who introduced the newborn Windows platform to its first generation of developers, published a talk he'd given to the New York .Net Developer's Group. In his title he asked the provocative question, "Does Visual Studio Rot the Mind?"

Assistive technologies shouldn't govern creative thought, Petzold argued, but that's just what happens when, in order to get IntelliSense to work, you must predefine every class, method, property, field, parameter and variable before you can refer to it.

"Of course I could always just turn it off," Petzold said. But then, acknowledging his love/hate relationship with IntelliSense, he added: "And go cold turkey? I think not."

With ActionScript 3.0, you can have it both ways, as Macromedia Flex evangelist Christophe Coenraets recently pointed out when showing me Flex Builder 2. When you already know what your types should be, he said, declare them. When you don't, don't. One language, two styles, complementary benefits. Good idea!