News for hackers. Stuff that matters.
Re:CaterwaulJS "Nobody in their right mind would use this la... by LukeShu on Saturday December 10, 2011 @07:59AM (#3337507)
I've always held that if you name your methods and variables right, many lines of code can be read as sentences.

When describing the fetchmail config syntax, ESR commented that you should be weary of making something too much like natural language and too complex, but that he added certain optional tokens that get filtered out to make the syntax more readable.

Like the `wtf' command (from BSD?). It tells you what something means. The syntax is "wtf [is] <acronym>". To a unixhead, the is isn't necessary, but it makes the command read like a sentence.

If I'm willing to add in those little words, I find the best lines of code will read like a sentence

  if (foo.equals(bar)) { /* then */
    ...
or

  mv file [to] newname
Re:CaterwaulJS "Nobody in their right mind would use this la... by michaelcampbell on Saturday December 10, 2011 @10:54AM (#3337748)
I do that sometimes with java code. My support guys have given me some "thanks, your code is easy to read" type emails occasionally. Good naming helps, although some consider it overly verbose. To wit:

    public static final BigDecimal BY_100 = new BigDecimal("100.00");
    ...
    BigDecimal amountInDollars = amountInCents.divide(BY_100);
Sometimes I do it just for my own amusement, too.