Monday, June 25, 2007

Pull my Strings

My favorite Joel Spolsky article is The Law of Leaky Abstractions. It may not be the wittiest or the most controversial, but makes up for it in shear importance. Joel's site is down right now (something that doesn't happen frequently), but wikipedia says that the Law was worded as:

"All non-trivial abstractions, to some degree, are leaky."

Well, some pretty trivial abstractions are leaky too. What is the type you use most in your programs? Probably int, but after that? For me it is String (currently java.lang.String or scala.String to be annoyingly more precise).

That is a pretty shitty* abstraction, don't you think? String is supposed to be short for StringOfCharacters. Leaving aside the fact that shorthanding is a bad practice, the name may not be wrong, per se, but it does nothing to characterize the meaning of the type in our programs. Why not Text? It is semantically more accurate and actually shorter than "String".

* To retain the plumbing analogy.


Unknown said...

You can break text (the concept) into paragraphs, segments, phrases, sentences, and finally characters. Really, it's only making the whole thing worse :)

Rodrigo Lopes said...

Yet, there're people using String like a reason to use metaphor principle in XP: 'Hey. Java guys did use string metaphor, remember!? Why can we not use xyz for our metaphor' _ where xyz is another stupid metaphor too.