Tech

Guides
 

Are language minutiae necessary?

By Justin James, Special to ZDNet Asia
Friday, May 15, 2009 11:19 AM
Why clog a programming language spec with minutiae that don't offer any technical benefits? On the other hand, is an "anti-minutiae revolution" really necessary?

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.

Justin James is an employee of Levit & James, Inc. in a multi-disciplinary role that combines programming, network management, and systems administration. He has been blogging at TechRepublic since 2005.



WORTHWHILE?

-1

1 votes
Blog

Talkback 2 comments

Are language minutiae necessary?
I think the ternary operator is absolutely useful! There are many cases where you'd want to execute a short statement based on the truth of an expression. Personally, I use it often, especially in assignment operations. I agree that it took awhile for it to sink in though. You have to be careful when labeling certain characteristics of programming languages as unnecessary. Take the ++ or -- operators for example. Novice programmers would find it absolutely confusing and thus unnecessary, but move along a little and we all realise it's almost indispensable!

There are also some practical reasons for certain peculiarities. While this doesn't apply to all such operations, certain peculiar operations could provide better translation into more efficient intermediate language structures or even optimise the output machine code. This could be because the context that they can be used is limited, and would thus help reduce compile-time optimisation complexity.

Yup, I completely agree a lot of the minutiae are confusing, but with a good reference manual and a clear head of what you want to accomplish, you can generally skip to the core and ignore the other, more useless info...for now. =)
Posted by Bryan Chen on Friday, May 15 2009 02:08 PM

Are language minutiae necessary?
There are languages like that. Try Logo or maybe move up to Basic.

The more I think about your suggestion the more angry I get. Seriously any Java (or C) programmer who doesn't know what the ternary operator is should not be called a programmer but a "Novice programmer" as they obviously haven't put in any effort to learn their tools. Grrrrr.

[And they should have "Novice" tattooed on their forehead so I don't have to waste any time interviewing them when looking for skilled developers! ;-)]
Posted by Steve Holmes on Monday, May 18 2009 11:37 AM


Guest user

Guest user

Level: 
Joined: —
Already a member? Log in »



 

Loading...

Whitepapers/Case Studies

Downloads

Web Development News



Tech Jobs Now!

Tags

  1. business applications
  2. c#
  3. developer
  4. html
  5. industry
  6. java
  7. justin james
  8. microsoft .net
  9. microsoft corp.
  10. microsoft visual studio
  11. programming
  12. protocols and platforms
  13. server
  14. soa
  15. software engineering / development
  16. tool
  17. web
  18. web browser
  19. web services
  20. web sites