TechRepublic : A ZDNet Tech Community

Programming and Development

Host: Justin James
Contact

Justin James asks: Why clog a programming language spec with minutiae that don’t offer any technical benefits? While he isn’t calling for an “anti-minutiae revolution,” he would like to hear what other programmers think about the subject.

—————————————————————————————-

I am slowly but surely working my way through learning Ruby in-depth. The book that I am reading (The Ruby Programming Language) does a very good job at describing the various nuances of the language. Along the way, I noticed that Ruby is filled with minutiae — those little parts of a programming language that few people use on a regular basis, and many developers can go years without seeing. Ruby is hardly alone in this; in fact, I think that its level of these details is relatively low (the king is probably Perl). But I am curious if it would be beneficial to streamline languages by removing these items, and simply have the developer write more verbose code on occasion.

My favorite example of these types of minutiae is the ternary operator. Many developers are not familiar with it (or maybe have never heard it called that), so let’s take a look at it. In most C-style languages, there are unary operators (such as ++) that only take one argument: the variable they are working on. Most operators are binary: They require two items to be effective (+ and - to name two). Because most languages only have one operator that requires three arguments, it is known as the ternary operator, although in theory there could be more. This is a conditional expression in which if the first argument evaluates to true, the second operator is executed; otherwise, the third argument is executed. Typically, it looks like this:
                (condition) ? truestatement : falsestatement;

In a nutshell, the ternary operator is a one-line if-then-else construct. I am not a big fan of the ternary operator for a few reasons. Every time I use it, I find myself returning to the line a few minutes later and turning it into an if-then-else construct so that I can add additional statements to one of the blocks. Secondly, I feel that it reduces readability; some could argue that by reducing needless clutter, it increases readability. It’s purely a matter of personal opinion and cannot be measured.

Ruby has a lot of methods that are aliased to different names. In some ways, this makes sense. After all, maybe the method foobar does the same thing as fizzbuzz, but foobar is a better description of the operation than fizzbuzz in some circumstances. That has a certain logic to it; at the same time, it is highly dependent upon appropriately chosen names. In many cases, I would much rather know that an expression seems out of place but is functionally correct than have to remember that there are multiple names for the same operation, and which name I use depends on the context. Again, this is purely a matter of personal preference; please do not think that I am knocking Ruby for having this approach. If you don’t like the aliases, you do not need to know them unless you are looking at someone else’s code.

All of that being said, is it necessary to clog the language spec and add one more item to the “features to learn” list, particularly for something that does not offer any technical benefits? The ternary operator is hardly the only example of this, and I don’t mean to turn this into a debate regarding its merits. But this is exactly the point: Most languages are filled with these kinds of items. Many are leftovers from their philosophical roots in C or some other language that was created in another day and age. Others are just cruft that developed along the way. These minutiae are rarely removed from languages once they are in there, since it would break backwards compatibility for just enough people to cause complaint, and a few folks would insist that these items make them more efficient programmers in one way or another.

Do language minutiae harm a language? Not usually. Since you rarely see anyone using them, they are not a terribly big deal. In addition, they rarely perform major tasks, so it is not like you are missing out on major functionality by not using them. And yet, I find it very distracting to learn a language and to be tied up in these things. Maybe it is a documentation issue, because these minutiae are mixed in with really important things, and it is difficult to identify what is something you need to know and what is simply nice to know.

My personal take on this is that, if I were designing a new language from the ground up, I would not include the minutiae. I just don’t think that these items add much value, and they can cause a distraction. But for existing languages, I do not think we need any kind of “anti-minutiae revolution” or anything along those lines, but perhaps a slow phasing out of these items may be in order. What are your thoughts?

J.Ja

Disclosure of Justin’s industry affiliations: Justin James has a working arrangement with Microsoft to write an article for MSDN Magazine. He also has a contract with Spiceworks to write product buying guides.

—————————————————————————————

Get weekly development tips in your inbox
Keep your developer skills sharp by signing up for TechRepublic’s free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!

Justin JamesJustin James is an employee of Levit & James, Inc. in a multidisciplinary role that combines programming, network management, and systems administration. He has been blogging at TechRepublic since 2005. Read his full bio and profile.

Print/View all Posts Comments on this blog

Do we really need minor language details? Justin James | 04/07/09
Expressive is in the eye of the beholder Tony Hopkinson | 04/08/09
Like conditional, I avoid With... mattohare@... | 04/15/09
Nested and compound with Tony Hopkinson | 04/15/09
LOL...Save Typing Bad Boys Drive Audi | 04/20/09
With has its place Mr. E | 09/30/09
That's hardly surprising it was Tony Hopkinson | 10/03/09
Yes, we need them all, but only some are used each time michaels.perry@... | 04/14/09
Funny Example gormark | 04/14/09
Timeout Cybrduck | 04/14/09
I use it all the time. jk2001 | 04/14/09
Question, where do you put the little red dot Tony Hopkinson | 04/14/09
Ternary abuser! SnoopDougEDoug | 04/14/09
Ha! Bad Boys Drive Audi | 04/14/09
Code has to be readable jsbeam | 04/17/09
You should meet my professor Bad Boys Drive Audi | 04/20/09
Yes. Claiming something as minor indicates a lack of understanding znewt | 04/14/09
Totally Agree - Trash and Treasure Mad-H | 04/16/09
Minor Language Details == "Syntactic Sugar"? stephenlposey@... | 04/14/09
Minor language details are not always syntactic sugar Justin James | 04/15/09
Ternary Operators Bad Boys Drive Audi | 04/14/09
Yes, we do.... mattohare@... | 04/15/09
Minor Details Ed Woychowsky | 04/15/09
Hard To Define gbentley@... | 09/30/09
Other aspects of language are more annoying for me jslarochelle | 04/07/09
Java and minutia Justin James | 04/08/09
Generics in Java are usable however... jslarochelle | 04/08/09
RE: Are programming language minutiae necessary? subpixel | 04/07/09
There are situations where the ternary operator Tony Hopkinson | 04/08/09
Ahum, Tony rob mekel | 04/08/09
I've no idea :D Tony Hopkinson | 04/08/09
Didn't I say... Justin James | 04/08/09
Addendum / step back from debate subpixel | 04/08/09
It is more a documentation thing Justin. Jaqui | 04/07/09
Documentation is *definitely* a big part of it! Justin James | 04/08/09
Everything is "need to know" gak@... | 04/14/09
That's rather unrealistic Justin James | 04/14/09
Depends on how you define optimal Tony Hopkinson | 04/14/09
Brevit of typing Justin James | 04/15/09
I tend to be irritatingly verbose Tony Hopkinson | 04/15/09
Almost everything certainly, but not at the beginning! webmaster@... | 04/14/09
Yes, provided not learning while working gak@... | 10/03/09
So we need to set up a wiki with digg voting? mattohare@... | 04/15/09
That would be pretty neat Justin James | 04/15/09
It's never to late. mattohare@... | 04/21/09
Feature creep in languages Mark Miller | 04/07/09
Yes, lots of feature creep Justin James | 04/08/09
~throwing a spanner into the works on "feature" addition~ Jaqui | 04/09/09
Use C with a C++ compiler? Mark Miller | 04/09/09
yes and no Jaqui | 04/09/09
adulterated C Mark Miller | 04/10/09
stdio.h vs iostream Jaqui | 04/12/09
Closures in C# Mark Miller | 04/09/09
Closures and lambdas Justin James | 04/12/09
Lambdas and Microsoft Mark Miller | 04/16/09
Closures in Perl mdhealy@... | 04/14/09
Microsoft is trying too hard to lure developper to C# jslarochelle | 04/10/09
The changes to C# Justin James | 04/12/09
I guess an "entry level" language would be good... jslarochelle | 04/13/09
You've hit on something here chris@... | 04/14/09
Making languages simple Mark Miller | 04/16/09
My brain is probably damaged beyond repair from... jslarochelle | 04/16/09
Learning Smalltalk Mark Miller | 04/16/09
Thanks Mark! jslarochelle | 04/16/09
Are programming language minutiae necessary? ; YES rob mekel | 04/08/09
I agree ict.aarongusman@... | 04/14/09
Lotta stuff in Perl that I never use mdhealy@... | 04/10/09
The magic of Perl... Justin James | 04/10/09
Yep, my Perl code is a lot more verbose than many mdhealy@... | 04/14/09
Seriously? rberman | 04/14/09
RE: Are programming language minutiae necessary? semi-adult | 04/14/09
RE: Are programming language minutiae necessary? sunsesh@... | 04/14/09
Good analogy, but not optimised Shaunny Boy | 04/14/09
Close but not quite chris@... | 04/14/09
RE: Are programming language minutiae necessary? chris_thamm@... | 04/14/09
It can save you a lot of time. ByteBin | 04/14/09
Yes, but chris@... | 04/14/09
Not Exactly ByteBin | 04/14/09
That's the thing though. Tony Hopkinson | 04/14/09
Are you really typing that much? Justin James | 04/15/09
A good IDE makes a bigger difference than a few exotic language features jslarochelle | 04/16/09
It is beneficial to NOT use the minutiae jreddy@... | 04/14/09
Totally agree simon@... | 04/14/09
Nonsense znewt | 04/14/09
I really doubt chris@... | 04/14/09
Yeah I agree tim.yen@... | 04/14/09
Professional programmers need to get the job done Tony Hopkinson | 04/14/09
"Ternary" Operator Not Really An Operator ... doug.cronshaw@... | 04/16/09
Yes It Is gbentley@... | 09/29/09

What do you think?

White Papers, Webcasts, and Downloads

Recent Entries

TR on Twitter

Archives

TechRepublic Blogs



500 Things Every Technology Professional Needs to Know
Did you know Microsoft's RegClean does not work with XP but you can use shareware to clean your registry? Did you know most wireless access points don't have encryption enabled by default? Did you know there are 500 tidbits of information contained in TechRepublic's 500 Things Every Technology Professional Needs to Know that will help you become a successful IT professional.
Buy Now
IT Professional's Guide to Policies and Procedures, Third Ed
Whether you're creating policies for management, training, personnel, support, privacy, Internet/e-mail usage, security, or inventory, you'll meet the needs of your entire enterprise with this one download!
Buy Now

SmartPlanet

Click Here