February 22, 2006

Getting smart about languages and libraries

Developers spend too much time untangling programming languages and their related code collections

The ever-quotable Sean McGrath penned another of his trademark aphorisms this week: “The library IS the language.” By “library” he means the great edifices of reusable code that are, in their modern form, delivered as the core Java and .Net class libraries. Mastering them is a challenge that can take years, McGrath wrote. Mastering programming languages, he suggested, is comparatively trivial.

In principle that’s true. In practice we are not quite there yet. Recently, for example, I’ve done a lot of programming in a pair of languages I know fairly well by now: Python and JavaScript. I’m using them in tandem because Python is great for general-purpose service delivery and Java­Script is the magic wand that waves AJAXian features into existence.

Combining the two languages is a useful strategy as clients and servers become more equal partners. But it’s a challenge to keep track of the subtleties of these languages, and an even bigger challenge to corral each into its own mental compartment.

This interwoven use is complicated by the fact that each language has its own virtual machine and its own libraries. That isn’t necessarily a given. For example, both of these languages have been implemented on the .Net Common Language Runtime. Andrew Clinick led Microsoft’s development of JScript .Net (back when that was a live project). Jim Hugunin leads Microsoft’s development of IronPython now. Clearly it’s possible for both languages to share common .Net -- or indeed Mono -- services.

Such an arrangement would make some things a lot easier, especially if the shared engine were ubiquitously deployed both server-side and client-side. At the end of the day I don’t care whose string, XML, database, communication, and graphics libraries are the sexiest. I want to learn one set of them that I can count on to be virtually everywhere and that I can rely on to do most of what I need.

My latest project, the InfoWorld explorer, uses Python and JavaScript along with a pair of common sublanguages: XPath and regular expressions. The first incarnation was heavily AJAXian. Then I ported it to a more conventional, server-based Web architecture. Porting isn’t quite the right metaphor, though, because both versions use the same four languages. It was more like a shift of emphasis from client to server.

To the extent that data manipulation was encapsulated in XPath queries and regular expressions, I was able to reuse it. Because Python and Java­Script wrap different APIs around these subsystems, though, I had to do some common things in different ways. Common services that are similar, but not the same, can be a blessing and a curse.

All programming languages present subtleties that I must constantly relearn. To minimize friction, I standardize on common idioms where possible. So for example, I added map and filter functions to JavaScript in order to emulate Python’s built-ins. It can be amusing to create these kinds of illusions, but there are better uses of brain cells. The fact that JavaScript’s library lives inside the browser, and Python’s lives outside, is merely a historical accident. If I could erase that distinction tomorrow, I would.

Today the ratio of languages and libraries is still roughly 1-to-1. But the numerator will grow faster than the denominator. We don’t need more of the same old ways to say the same old things, but we do need new ways to say new things.

Close

On Twitter now

Application development

Powered by Twitter

White Paper

D2D Virtual Tape Library Replication Primer

This whitepaper explains the terminology and concepts behind Data Replication technologies and establishes some sizing rules through worked examples. Learn the new paradigm in disaster tolerance—protect data anywhere.

Download now »

White Paper

An Alternative to Virtualization for Datacenter Cost Savings

Server virtualization is a popular option for dealing with mounting datacenter costs. Another equally promising approach is the use of an Application Delivery Controller. Citrix NetScaler provides a low-cost way for organizations to reduce their server count and accrue cost savings from a reduction in space, cooling, power and personnel.

Download now »

White Paper

Why Your Firewall, VPN, and IEEE 802.11i Aren't Enough to Protect Your Network

The emergence of WLANs has created a new breed of security threats to enterprise networks.

Included in HP ProCurve WLAN solutions is security technology that alleviates threats from WLANs through:
* Monitoring wireless activity inside and out of the enterprise
* Classifying WLAN transmissions into harmful and harmless
* Preventing transmissions that pose a security threat to the enterprise network
* Locating participating devices for physical remediation

Download now »

White Paper

Bringing the Edge to the Data Center

Effectively address data protection challenges, implementing solutions that help store and protect business–critical data while cutting costs and improving efficiency and reliability.

Download now »

Sign up to receive InfoWorld Resource Alerts

Subscribe to the Developer World Newsletter

Receive a weekly roundup about the art and science of software development.

©1994-2009 Infoworld, Inc.