my face
About Me

Published Posts

All Posts

New Post


View by Tag:

interviewing, code, testing, philosophy, blog, wantmyjob, virtualization, railsmud, heroku, ruby, published, neoarchaeology, railsgame, rails, juggernaut, astrino, cheaptoad, shannaspizza, mongodb, refactorit, devise


FeedBurner picture


Online Portfolio

Resume

Profile on LinkedIn

Recommend Me

A Quick Look Under the Rails

Posted: 2 years ago (2007-11-03 19:56:25 UTC ) / Updated: 15 months ago (2009-04-23 14:28:37 UTC )

Imported from WordPress

Originally posted on 2007-11-03 19:56:25

I come to Ruby from a somewhat uncommon direction -- I'm not a web coder looking to put my site on Rails, but a systems programmer looking for a cleaner scripting language than Perl.  I want better higher-order function support than Python, and maybe some of what Paul Graham likes about LISP.

Ruby is some of each of these things, and mostly I like how well it flows.  It takes a lot of the best from a lot of other languages I've known...  And I've learned many previous languages. I've used CommonLISP, Dylan, C, C++, SML/NJ, three or four different assembly languages, bash, Perl, Python and many other languages, and done at least one significant project in every language I just listed. The flip side, though, is that I really don't know whether it would be an easy language for somebody new to pick up -- I've learned it only after using many others. It feels easy to me...

Ruby feels like a cleaner, more uniform Perl. Ruby keeps most of the regular expression syntax that you either loved or hated in Perl and it has a very similar concept of what hash tables and lists look like. It fixes things like structures to be less awful, and it doesn't have any similar concept of references -- it just comes out pretty much transparent, or as a data field packaged up in a class. So it cleans up the stuff I really didn't like about Perl, but it manages to remain a good glue language, interfacing cheerfully with all the usual Unixy command-line stuff.

Of course, its class and module system is more than a little weird, especially about some inheritance stuff. Not any weirder than Java with its classes and namespaces, but not any less weird, either. Ruby, like Perl, wants some additional data structures built up before it feels quite right. And Ruby, like, Perl, exposes enough of its seamy underlayers that you can build such things. Whether you consider that good or bad is up to you, but I like it.

And finally, to explain my gratuitous Paul Graham reference up above, I should mention Metaprogramming.  What made Rails happen, and what Ruby does really well in several fun cases, is the ability to toss together new classes at runtime in response to data.  The lack of this drove me crazy in C++, because nobody sane should ever have to recompile their app to get new categories of data.  Which means C++ can't use that vaunted class behavior for its data, only for the unchanging bits of the code.  Ruby fixes this nicely with a wide variety of limited eval() statements (and unlimited eval() as well, though it's slower).  Which makes it easy to build up your data objects to suit your interfaces and your data.

Each of these topics could be explored in enormously more detail.  With luck, I will in the coming days.  Welcome to my weblog.

Previous: And then... / Next: Starting Ruby, and the Little Details

Edit | Destroy | See All Posts

blog comments powered by Disqus