Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

2008-02-11

Love Ruby, Hate Rails?

Fairly recently I read a post (and listened to a podcast) decrying the Ruby on Rails community. A couple weeks ago I was talking to th dev crew of a company a buddy works at, and they seemed to wince when I mentioned that I do nearly all of my scripting now in Ruby. It became obvious quickly that it was because they had some bad experience with Rails. They obviously, as I've learned many people do, think that Ruby is synonymous with Rails and I find that unfortunate. I don't think my point came across that I use Ruby the scripting language, not Rails the framework. I've played with Rails but not enough to truly hate it. I remember liking it actually but then again I'm not a web developer and don't know what to complain about. I have little doubts that Zed is correct in his criticisms of Rails itself, not to mention the Rails community.

Still, I'm a little disheartened that that by all accounts the fate of Ruby is tied to Rails. Rails certainly did put Ruby on the radar (similarly to how Lua seems popular because of WoW) and that is a good thing, but the backlash could make it a bad thing. My only hope is that all that is wrong with Rails gets fixed in time. Well, I care less about Rails since I don't use it; I'm more concerned with the thriving of Ruby which has its own problems that I hope get fixed. I'd be sad if I were really forced to fully go back to Python or Perl.

2006-08-22

Rails rocks

I hadn't done much in the way of web stuff since the days I maintained some personal static research logs at my lab way back when. I wouldn't even count that as web stuff. Had a cursory knowledge of HTML by inspection, never learned Java, nor PHP, nor pretty much anything else. wget was my friend when I wanted or needed to do anything fancy. I did some digging, looked at some complicated-looking scripts, dabbled with a cgi script or two but not a lot. I'd always wanted to play around with it but never put much effort.

That sort of changed recently when I finally had some cause to investigate it for work related reasons. I'd been a scripting fiend for a decade and fell smitten with Ruby over a year ago. I'd been hearing about Rails (who hasn't) but only read enough to get an idea of what it was. Well, now I have dug a bit deeper, had time to play, and I have to say that it is way cool. Even without any formal or informal experience with other types of webdev platforms, I can already feel that I'd rather learn this than those others (save maybe Java but for different reasons). I was set up very quickly, ran though a neat tutorial, and marvelled at the relative ease and quickness with which I was able to get something working. I felt the excitement. I hadn't actually looked forward to getting home to play on my Linux box to play for a long time.

It didn't stop there, either. Before I knew it, I had Typo and Instiki installed in a snap. Those systems are just insanely cool, especially to a webdev n00b like me. I love that they come with their own servers ready to go via Webrick or tapping into Lighttpd. Instiki is now going to be a part of my work logs; it's just convenient to have a wiki where I can collect tips and results. As for home use, I don't really have much in the way of a web application or set of them, it's just to play around with. Next step, find out how to access my home Linux servers from outside. For some reason the port forwarding isn't doing the trick. I suspect my ISP is blocking those ports but I won't rule out my doing something wrong.

2005-11-30

A Ruby in the rough

I've noticed in the past few months more articles in the nerd channels about Ruby (mostly in regards to RAILS which I don't use). I'm sure it's simply selective attention on my part because I really love Ruby, more fervently than I did Perl when I first started using it some 10 years ago.

Ruby is a scripting language and I've been using it nigh unto a year now. It is currently my favorite scripting language and it was so practically from the first day I started playing with it. You can find plenty of advocacy, zealotry, demogoguery, and fanatacism in the usual places online; I'm sure even more if you can read and understand Japanese. Fortunately for me I did not see or read any of that online bantering about how "my scripting language can beat up yours" when I decided to play with it, only enough about it to give it a try.

Two things sold me on it immediately:
  • Nice data structures
  • The presense of "=~"
I'd been a Perl die-hard for years, was forced to use Python for work reasons, learned to really appreciate Python for what it was, and then cursed both for not having what I liked and needed to have in each. Perl makes for great quick-and-dirty guerrilla-warfare scripting but became clumsy for larger projects. Python was systematic, clean, and good for such larger projects, mostly due to its data structures, but it really dropped the ball when it chose not to add that little simple piece of syntactic sugar ("=~") to handle regular expressions. I deal with lots of text data but even if I didn't I do consider regular expression tools a basic necessity to life on the command line. And using regular expressions in Python just blows! There are other annoyances in each but those are currently of primary importance to me and my trade.

Enter Ruby, which upon first encounter appears to have the best of both worlds. Oh joy! I got busy with it immediately. It also had an interactive mode like Python, something Perl really needed. With a bit more experience, I discovered and began to appreciate some of its other and even novel features:
  • Truly object oriented in presentation (even the number 1 acts like an object) which adds a kind of consistency.
  • Interesting use of code blocks (I didn't like lambda's in Python, does anyone?).
  • Ease with which to extend even basic classes and objects.
With more use I found myself rethinking my former ways of coding a task (e.g. I found myself considering even simple things more often in terms of iterators). There are also things I find truly elegent (e.g. using code blocks for initializing).

The unfortunate aspects:
  • It's still rather new (outside Japan) and so the community and support is rather smaller than Perl and Python.
  • The syntax and keyword naming is a mite unfortunate and takes some getting used to. But at least it doesn't strongly rely on syntactically significant white spaces like Python.
  • It has automatic variables. You don't have to use them, and I don't mind them, but it freaks some people out. It does mean you can run cool stuff on the command line like Perl though.
  • It's yet another scripting language, and there will be some inertia to overcome, especially in the staunch work environment.
  • I miss Python's use of named and initialized arguments. This is almost a deal-breaker. Grrr... nothing's perfect it seems. Fortunately, that might change in the future for Ruby, and there are hacks to simulate it now but they are just hacks. I don't like the hacks though.
  • At present there only a relative few books on Ruby in English. Fortunately the first one out is a great one, on par with the Camel book in my opinion.

Currently I'm the only one at my office that uses Ruby. It will probably stay that way due to the inertia problem. But I decided to continue writing and infesting the company research code with it until someday they all seccumb to my will and see the light.

2005-11-16

YAML

YAML once meant "Yet Another Markup Language" and now means "YAML Aint Markup Language" but I would prefer it to mean "What do you get when you breed a Yack and a Camel". It's a data serialization format that (and this is the important part) is human readable text. It was brought to my attention a year ago by a coworker and I had since hacked it in to our system to better handle log file parsing. I completely agreed it to be the right idea. It has made my log file parsing much less stressful and more consistent. It just sucks that the online community for it is still... lacking. Some of the main YAML sites seem grossly out of date and nearly empty.

My recent frustration is dealing with incomplete implementations in the different scripting languages. I'm currently parsing Python generated YAML streams with Ruby. They seem to conform to different versions of the specification; most notoriously for me right now is how they each treat boolean values. My Python implementation wants to turn "+" and "-" into true/false (I had since hacked that out). Ruby wants to turn strings like "true/false", "yes/no", "Y/N", and even "on/off" into boolean true/false. This is causing all sorts of minor annoyances since I'm dealing with text that will have this as literal strings and not as code for boolean values. I in fact think that having the YAML spec interpreting strings as booleans is just a bad idea with perhaps some exception. Auto-interpretation of data is a touchy subject and you're bound to upset someone no matter which way you go. I'd prefer the "everything's a string" method, since that would at least guarantee consistency. But for now I just hack in fixes for my own purposes. I may submit a patch someday. I'd feel safer using the format if I had a sense of more active development however.

Ruby seems to be the only safe-haven for YAML at the moment. They seem to be trying to turn it into a Pickling or Marshalling replacement though. That's not really what I want out of YAML. It's just a really good way to display nested list and hash structures in a clean, pleasant, and consistent way. Anything more may make it too complicated to be portable and general purpose. I'd still rather use it than write my own though, since I don't really have the time.