## Visualization of Ruby's Grammar

From: "andrew cooke" <andrew@...>

Date: Fri, 24 Nov 2006 21:26:18 -0300 (CLST)

An interesting collection of plots:
http://blog.nicksieger.com/articles/2006/10/27/visualization-of-rubys-grammar

The readable images are:
http://www.flickr.com/photo_zoom.gne?id=280661836&size=o
http://www.flickr.com/photo_zoom.gne?id=280662707&size=o
http://www.flickr.com/photo_zoom.gne?id=280662871&size=o
(I wouldn't be surprised if Flickr do referrer checking on those, in which
case go through the first link).

I compared Java and Javascript first, because I don't know much about
Ruby.  Javascript's graph is pretty clean - it looks like the language was
designed by someone who was (1) going to have to write a parser for it and
(2) wanted to make their life simple.

Java's plot, in contrast, is rather more messy.  A little poking around
suggests two reasons.  First, it needs to handle type declarations, while
Javascript doesn't.  Second, annotations and generics have been bolted on.
So the extra complexity is understandable: it's doing more, and it's had
to evolve.  We all get uglier as we get older.

Ruby, however, doesn't have the same excuses.  As far as I know, it's
untyped and much younger than Java.  Peering around the graph it seems
that it's trying to do lots of clever things with fancy argument lists
etc.  Also, you get the impression that the parse was written by someone
without much experience writing parsers - there's none of the standard
patterns that make Javascript's graph so regular.

Which is more or less what you'd expect given the context in the text of
the original post.

Andrew