Consistency vs Convenience

We have a decision to make in the Hecl project that highlights how much computer programming is really an art, rather than a science. Namely, how to name a series of string handling commands. Tcl has a series of string commands like

string first string1 string2 ?startIndex?
string equal ?-nocase? ?-length int? string1 string2
string index string charIndex

which are mostly consistent. At times, they’re also just a bit more unwieldy than I might like. For instance;

set somechar [string index "the nth char is" 4]

is just not as quick to write as

somechar = "the nth char is"[4]

For something that you need to use frequently like ‘string equals’, a shorter, quicker version is really a must – infact, Tcl’s expressions recognize the ‘eq’ operator. Hecl has ‘eq’ and ‘ne’ as commands, which makes things a bit less consistent, sure, but a lot more convenient.

The decision we need to make, though, is where to draw the line? String equality is so common that it doesn’t take much thought to opt for convenience. How about string index? string length? The artistry involved is to make something that’s appealing to people, but also practical. Elegant, but not so much that it remains unsullied by use in real work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s