Brevity vs Maintainability

Programming languages have come a long way in terms of the expressiveness of their syntax and semantics. Early on, just being able to give memory locations human-readable names was a huge step and boosted productivity. (If you’ve never programmed assembly language you should learn about it just to be grateful you’ve never had to program in it…)

And it seems that every new programming language delights in packing  more and more semantics into the sausage that is a line of code. But is this always a good thing? Is there some point at which you’ve packed so much into the sausage-skin that it splits when barbecued or spits grease when poked? Alright, so that metaphor was pushed a little too far, but you get the question…

Case in point: Perl. I haven’t used Perl a lot, and mostly just for utility scripting. For that purpose I like it a lot because it has all sorts of built-in stuff to make those sorts of tasks easy — leading to code that is very concise. But note that “concise” doesn’t equate to “simple” or “easy to understand”. Concise just means short. I don’t think many would argue that Perl is a simple or easily-understood language.

Counter-example: LINQ. I’ve used LINQ a bit, and am still withholding final judgement. Code written with LINQ is concise, but because it uses the familiar tropes of SQL queries it is both expressive and reasonably easy to understand.

But it’s not necessarily easy to debug — if you want to debug a LINQ statement you’ve got to break it into its component pieces, either by editing the code or figuring out how to coerce your debugger to break in the middle of a statement. I tend to presume that each and every statement or line of code will need to be debugged, so this is actually a serious concern for me. If you will need to break a LINQ statement apart to debug it effectively, how is it better than writing your own for loop that already gives you the exploded schematic view?

I don’t personally have an answer for this, but I think it is worth considering where that sweet spot between brevity and readability (or more broadly, maintainability) lies…

 

Advertisements

About jeffkotula

Software engineer, musician, and so on...
This entry was posted in Coding, Programming languages, Software and tagged , , . Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s