Visualization of the Grammars of Ruby, Java and Javascript
blog.nicksieger.com
blog.nicksieger.com
The author processed Ruby's YACC file into something that ANTLR would accept and I'm not sure that all of the relevant information made it through. For one, it looks like Ruby's operator precedence is not captured here at all. Between this, and the fact that Ruby doesn't have separate statement and expression concepts, everything that's left ends up in one large highly connected graph.
The Java and Javascript graphs, generated as they are from the EBNF-like ANTLR, strike me as much more true to the productions of their respective grammars. Since they were both generated in the same way, they're also more directly comparable to one another. The most eye-catching thing about these two are of probably the chains of expressions which encode the precedence rules of their operators. Java has a boatload of operators, which account for the top half of its graph. It then has two snarls at the bottom, one for statements on the left, one for declarations on the right. Most modern languages in the algol family will have statement syntax rather similar to Java's here; if you're interested in what sets Java apart syntactically you'd likely find it clustered about the bottom right corner of the graph.
Javascript's operators are only slightly simpler than Java's, and there are two variations, one that allows the 'in' operator, and one that does not. This creates the two chains running down the bottom-right hand side. One interesting thing to note is the lack of tight, complicated snarls in the javascript graph. Javascript's grammar is fairly simple, and ignoring the 'in' operator, quite straightforwards, so I suppose this shouldn't be too surprising.
Nick said ...
@Adam: check out http://www.flickr.com/photos/nicksieger/281055530/ and http://www.flickr.com/photos/nicksieger/281055485/. I can’t even imagine what a Perl grammar would look like
Since there's no BNF for Perl it would be hard to visualize its grammar.
http://www.python.org/doc/2.5.1/ref/grammar.txt
http://svn.pugscode.org/pugs/src/perl6/STD.pm
If you do a wc, perl6 is about 12-20 times the size of python (depending if you use lines or chars). It would be funny to see the per6 graph...
The Perl 6 grammar also includes comments and is itself written in Perl 6. A metacircular Python grammar would look different from the existing Python grammar.
Maybe we could theorise about what's easier for programmers to understand. I'd suggest in that case that the more hierarchical systems are the hardest as the brain has more difficulty remembering small numbers of connections than a larger contextual web. But that's just an idea I would have looking at the images, I expect anyone who understands these well enough to draw conclusions from them would already be quite familiar with them.
When contrasted with Python, C, or other languages that have more strict syntax you may realize that there's a cost to having so many features. The interactions between all those parts of the grammar get very complicated.