Sunday, October 09, 2005

BNF for Ruby

BNF stands for Backus-Naur Form, and is a very convenient way to describe a programming language. At a glance one can quickly see what the language does, and what its interpreter or compiler expects the grammar to be like.

I got tired of working on homework, and have been hearing a lot about the programming language Ruby, and a variant called Ruby on Rails lately. I decided that I would spare myself a few minutes and learn a little bit about the language. Looking for a nice technical description, I first found this user guide. While it was an interesting, quick read, I wished for a more simple way to be able to see what it was that the language represented, besides the claim of being a great interpreted object oriented language. On the whole, the guide was nice, but I really wanted to see the language described in terms of BNF. And for some odd reason, I kept expecting to find the language described in BNF terms.

At any rate I decided to do a google for Ruby BNF and came up with this great synopsis in "pseudo BNF" form. Even from the actual Ruby people. I was so pleased. I guess that the stuff I am learning in school isn't as out-dated as I had thought. It is cool to be able to put classroom learning to real world practice.

The take home message of the night is that BNF really is a great way to convey a lot of information about a language to another computer scientist in a concise and compact way. If you do much in languages, it is certainly worth learning.

No comments: