In fiddling with ruby, I noticed that the method names can be really interesting - rails (maybe others too, dunno) has some methods that look like:
which is typically used to return a boolean indicating wether or not “stop” is true. Ok, cool. Another interesting method call is
which appears to be identical to
. That part really confused me, and I’m still not sure I have it completely clear.
In python
and
are two very different things. The first is a reference to the instance method close - which you can pass around. The second is a specific invocation to the instance method. In ruby the parentheses appear to be optional if there are no arguments getting passed in to the function.
Update:
Dave Slorah pointed out that the parantheses option thing extends beyond just the no-argument methods - it applies all over the place!
irb(main):010:0> def foo(bar,baz)
irb(main):011:1> puts bar
irb(main):012:1> puts baz
irb(main):013:1> end
=> nil
irb(main):014:0> foo "hello", "world"
hello
world
My first thought it “Wow - that’s almost Objective-C like…”
As a generalist in the technology space, I’m constantly on the lookup for “Secret Weapons”. I’m not even sure when I first started using that euphemism, but that’s often how I think about a lot of technology. Ubuntu and/or Debian linux is an example. For running a service, it’s inexpensive, effective, and it has my one of favorite secret weapons:
apt-get update
apt-get dist-upgrade
That’s in my arsenal of secret weapons to “keep stuff running”. There are also secret weapons for getting applications written. Cocoa is one - specific for Mac based applications, I’d even say that for Windows applications, Visual Studio and .NET is another. For web applications, Django.
One of the interesting things about secret weapons is that they’re not point and click. They don’t even necessarily have an incredibly high “ease of use” quotient. What makes them secret weapons is that they’re incredibly long levels. You might have to do a little learning to use that lever, but once you have that learning under your belt - you can move mountains.
I’ve been learning (or trying to learn) Ruby on Rails for the past week or so. Yeah, that’s not much time. I’ve had a lot of reasonably smart people describe it’s effectiveness as what I’d normally called a secret weapon for myself. I think that makes it all the more frustrating that I happened to start learning just after Rails released 2.0 of their code base, with a lot of deprecations and some lack of backward compatibility. The real bitch is that a whole bunch of written detail has just gotten significantly less valuable. It’s frustrating is all. The hard part is really not just saying to hell with it and going back to using Django because I know I can get stuff done quickly with it.
I’ve got to say though, that the Rails community could do quite a bit to learn from the Django community on it’s level of documentation. Having a tutorial to get you walking on the project web site would be incredibly valuable. Then there’s the online Django Book for getting more in depth. I’ve got a copy of the PickAxe book and Pragmatic’s Agile Web Development with Ruby on Rails (First Edition). From what I can find online, even the latest versions of these guys aren’t going to have me quite up to date with Rails 2.0.
I’ve spent most of the afternoon re-aquainting myself with Mac programming idioms, and generally getting myself into a veritable froth of possibilityand over-imagination about the CoreAnimation technologies.
Outside of that, I finally backtracked into the world of Ruby on Rails to figure out why all the examples in the books were completely screwed up for me. It turns out that a basic stepping stone in most of those tutorials is the “dynamic scaffolding” bit. In the world of the Django frameworks, this is sort of a cross between the Admin functionality that’s implied from all models there and a “insta-crud” framework that’s for a general user’s benefit.
Regardless, when I got to that point in the rails world, the demos just all broke and went to hell - and as a rank newbie, I hadn’t a freakin’ clue of what was going on and how to fix it.Today I finally pinned it down. Taking some time away from it gave me a little perspective (as in I wasn’t muttering about how this rails thing sucks) and I got the skinny on the ruby forums. In a nutshell, dynamic scaffolding doesn’t exist in Rails 2.x - but you can generate a static scaffolding with rails generator code.
I’m certainly not quite used to “script/generate …” which seems to frequent the rails world of newbie examples. It does get a hell of a lot done for you, but I sort of feel like I’m missing the boat on what’s actually happening and what the defaults/conventions of rails are. Just working through it, I guess, is the best way to learn.
I think I picked a poor time to dive into and start learning Ruby on Rails. I’ve been reading and going through exercises from a fresh install and the plethora of great examples aren’t matching the new environment. It’s pretty close, but that little off from “right on the money” can be a real pain.
I’ve been primarily learning from Ruby on Rails: Up and Running, which is a pretty good text for getting started. The only downside is that it apparently just missed the Rails 2.0 thing with a couple of examples.
I picked up my copy of the Pickaxe book four years ago - it’s even signed by Dave Thomas. I started to learn and poke at it a couple of times, but didn’t make any serious forays into it. The past couple of days is changing that. After a deep dark struggle with myself, I decided that I needed to learn and know a lot more about Ruby and Ruby on Rails. I’m not abandoning Django at all - but I suspect that knowing another framework with a similar mindset and a different language will do nothing but good for me. Shoot - I’ve got outstanding work to get done in the Django world on our Django Queue Service… can’t back out now.
The dark seed behind the whole ruby thing is - I suspect more people would be willing to learn it than Django. It’s got more hype, more books, more caché. I’m not even going to claim one is superior to the other - both do some rockin’ good stuff - but Rails has the word. For myself, and for projects that I’ll be supporting either alone or not intending to hand off - Django is the thing. It’s my secret web-app weapon. Not unlike cocoa for most mac programmers. It’s amazing what a single person can get done with the right tools. There are some projects coming up, however, where I’m going to have to convince some others to pick up and learn. Maybe even support. I think at least being able to knock out webapps in Ruby with Rails will be a benefit there.
The oddest thing for me right now is the syntactic sugar that ruby uses for blocks, iterators and closures. It’s neat and darned concise - I’ll give it that, but it sure doesn’t feel natural. The other thing that I think will take a little getting used to is the library set. It’s a great, beautiful library if API’s to get things done, but the capitalization is causing me to stumble all over the damn place. The language, although a little foreign on my tongue right now, is pretty cool. I think Matz did a fine job of coming up with his Babel-17.
I think it’ll be a while before I’m able to sling code with like other ruby natives, but I’m guessing not that long at all really. The biggest stumbling block for the whole “convention over configuration” thing is just learning the damn conventions. And there’s a nice pile of books available to help with that.