Saturday, June 27, 2009

Ruby Line Noise

Ruby is a nice language but it shares many of the failings of Perl. One of these is with all the symbols it often reads like line noise to someone not fully familiar with the language. This is bad because for a script in the enterprise, pretty much every reader bar the author isn't going to be that familiar with the language. There's just too many choices of language and so the knowledge base is very fragmented.

The absolute worse decision along these lines was the symbolic operator overloading done in the container classes. Now, symbolic operating overloading may be fine as a general language feature to allow for well targeted use cases. You dont really want to be doing "new BigDecimal(5,6).plus(new BigDecimal(1,1))". But if you put shit like "|=" and "<<" in your basic Array class, it only encourages the dimwitted masses who follow to do similar. And because they are dimwitted, they won't pay enough attention to getting the semantics consistent with expectations, they probably won't even write a comment or a unit test, and you end up in a unreadable, unmaintainable mess. But hey, at least its a concise mess, right?

The simple rule here is: favor general readability over conciseness understood only by experts.

1 comment:

  1. It seems a bit inconsistent to be in favor of operators on strings but not on arrays. Sure one new to the language needs to lookup the difference between the operators for concat and append on an array, but is it really so onerous to require a maintainer to be passingly familiar with the array object in language she is maintaining?

    ReplyDelete