Monday, September 25, 2006

Programming aesthetics

I really should know better than to post this. Really. Please, don't start a big flame war. But, I peer over the fence from time to time skim through some tutorials and demos on Ruby and Ruby-on-Rails in particular, and one of the things that puts me off it (aside from the sunk cost of my Python knowledge and the fact that my favourite open source CMS project uses Python), is that ... it's so ... ugly.

I have an in-built aversion to blocks that end with an end keyword. Call it prejudice. I once learnt Visual Basic. Maybe that's it, but there are also lots of strange symbols flying about. $`? < for inherits-from? Functions without braces (oh, that's just crazy...).

If someone has seen the beauty in Ruby, please enlighten me. I genuinely believe that code asthetics are important in motivating programmers, ensuring consistency, catching mistakes and ultimately producing better software.

Of course this is totally subjective. But some good examplse of elegance and aesthetics would be nice.

3 comments:

Unknown said...

Lucky you, I'm not flaming... I agree completely.

Andreas Reuleaux said...

I generally agree (not to surprising that as a reader of a Plone blog I personally prefer Python, too).

Some more points though:

* http://www.poignantguide.net/ruby/index.html
is a very nice Ruby online book, some examples explain Ruby aesthetics by having the reader "Read aloud..."

* I see another aspect of Ruby:
"at least it's better than Perl"
- Perls enourmous success in past always surprised me, given that an unreadable language). If some of those Perl programmers are switching to Ruby now (because it somehow fits their brains - and I possibly have to read their code)
fine with me: I can say aloud to myself: "at least it's better than Perl".

(OT: don't know why my google acount identifies me (A. Reuleaux)
as "dictor" now - I will have to investigate further)

Wheat said...

I've put a
simple syntax comparison between Python, Ruby (and Perl) on Flickr.

When did RubyMate get all pretty? PyMate needs some more CSS lovin'

I much prefer Python over Ruby, but I would have to disagree about the ugly syntax. I quite like the feel of end for some reason, and the ability to leave off the () lets you write code that just looks clean and nice.

The < sign for object inheritance I'm not as keen on. And there are too many alternative syntaxes that do the same thing for any respectable pythonista to appreciate. Although the terse syntax and regexes does mean that Ruby scales down nicer than Python for one liners.

Jeffrey Shell also has some
apprecitive ramblings on Ruby syntax.