Sunday, November 21, 2010

Ruby: Whitespace significant?

Many people claim that they do not like Python because of the significance of whitespace. Well, whitespace is also significant in Ruby. E.g.
>> def say
>>  puts 'hi'
>> end
=> nil
>> say
hi
=> nil
>> def say puts 'hi' end
SyntaxError: (irb):5: syntax error, unexpected tSTRING_BEG, expecting ';' or '\n'
def say puts 'hi' end
              ^
(irb):5: syntax error, unexpected keyword_end, expecting $end
        from /Users/cdunn2001/bin/irb:12:in `
' >> def say; puts 'hi'; end => nil >> say hi => nil
See? The newline is a substitute for the semicolon, not equivalent to a space or tab. This is not pedantry. To me, the main value of whitespace-independence is that you can insert the code into something else -- e.g. an HTML template -- without breaking it.

I wouldn't mind if I could use curly brackets instead of 'end', but that works only for blocks, not function definitions. So I wish that Ruby fans would quit bragging that their language is whitespace-independent. There are such languages, e.g. Perl, where whitespace merely delimits tokens and can be removed completed by relying on parentheses and other delimiters. Ruby is not one of them.

I do understand the objection to Python's syntax. It's not the enforced indentation; it's the lack of an 'end' delimiter. The result is that copy-and-paste operations can introduce mistakes. I get that.

I'm just sayin' ...

Monday, November 15, 2010

StartupWeekend - We won! (Judge's prize)

My team won the judge's prize at StartupWeekend Seattle, Nov. 14 2010. It's more than just a software event, but software was a large part of it. Here is a good summary of our experience, from one of our team members. Including the votes from other teams, we came in 2nd overall. I guess that's like winning the coaches' poll but losing the BCS.

Friday, November 12, 2010

Git: Why?

Here is a funny and informative blog on problems with git, and why the benefits outweigh them. I liked this part the best:
... by far the best justification I’ve ever seen for git rebase (or git lie, as I prefer to call it).
Anyway, the comments are where the real information can be found.

Wednesday, November 10, 2010

Lots of ideas on NULL

There was quite a discussion on this at StackOverflow. The arguments are often language-specific, but basically folks like a Null option as long as it's part of the type system.

Friday, November 5, 2010

Objective-C: Slow?

Here is an interesting discussion of speed problems in Objective-C. I guess the bottom line is that it's generally only a little slow, not too bad, but some standard libraries are terrible. I assume that applies to iPhone apps.