On 6/3/06, James B. email@example.com wrote:
in grokking the code.
There may be analogies to furniture making, where a piece may not strike
Does masterful code get less and less the more you advance?
“I often work by avoidance.”
Obviously, the adjective “masterful” is not well defined; I should
clarify what I meant.
“Masterful code” is a solution for a problem you wouldn’t be able to
solve by yourself, although it only requires knowledge you possess.
Such quality is easily idetifieable by the “aha!” moment you
experience upon encountering it. That “aha!” quality would be
intensified by first attempting to solve the problem yourself. Success
in this stage would also be accompanied by an “aha!” moment.
For example: check if integer i is a power of 2, with an expression no
more than 13 characters long.
Solution: (i & (i - 1))
Note that this solution is not only very concise, but also (on any
reasonable implementation) very fast. Masterful code has a tendency to
be “correct” in many ways.
In a sense I agree with your music analogy, though I believe masterful
code should be more prevalent than inspiring music. Chess would form a
closer analogy, and if no combination surprises you then your name
must be Bobby Fischer (but even he would manage to find opponents to
surprise him by searching the top circles).
You may argue that “masterful code” as such is independent of
langauge. You would be correct to conclude that. The above example
works, with little or no change, in many languages. I was asking for
masterful code in Ruby not because I’m using it, but because of the
reason which lead me to use it:
Ruby seems to encourage masterful code. It allows ideas to be
expressed directly. The other langauge I’d consider to encourage
masterful code is Scheme. But Ruby manages to offer many more tools
than Scheme. An elegant Ruby solution may rely on classes or regular
expressions. In fact Ruby seems to aspire to equip the programmer with
as many tools as possible. Which is a Good Thing. It thus may be the
best language (that I know) for the masterful progrmmer.
Out of the many suggestions raised in this thread, it seems that
following the Ruby Q. would be most appropriate. By such
participation much improvement might be gained. In such competitions,
the winning solutions are frequently required to be “masterful code”
according to the above definition.
Also it seems one should look into Ruby F.s, not merely because it
appears to be a gathering point for Ruby masters but also because it
looks damn useful.
And I should read the source of projects widely considered masterful,
written by programmers widely considered to be masters. Rails seems a
fitting candidate in that respect, being recommended on both accounts.