# Rake versus Ruby?

**URL:** <https://www.ruby-forum.com/t/rake-versus-ruby/188607>\
**Category:** Ruby\
**Created:** [May 14, 2010, 6:21pm UTC](https://www.ruby-forum.com/t/rake-versus-ruby/188607 "2010-05-14T18:21:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [May 14, 2010, 6:21pm UTC](https://www.ruby-forum.com/t/rake-versus-ruby/188607/1 "2010-05-14T18:21:44Z")

</div>

I was thinking of this on my way home, but could not come up with a good  
answer… what is the extra bit that Rake gives me, which I don’t get  
from a Ruby script?  
I’m sorry it’s a bit of a naive question, but I was wondering when would  
it be more appropriate to use Rake compared to vanilla Ruby!

Thanks,  
Mohit.  
14/5/2010 | 11:33 PM.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [May 14, 2010, 7:32pm UTC](https://www.ruby-forum.com/t/rake-versus-ruby/188607/2 "2010-05-14T19:32:50Z")

</div>

On Fri, May 14, 2010 at 10:20 AM, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> extra bit that Rake gives me, which I don’t get from a Ruby script?  
> I’m sorry it’s a bit of a naive question, but I was wondering when would it  
> be more appropriate t

Rake allows you to create tasks that are dependent on one another,  
like Makefiles except with much nicer Ruby code. That’s why I like it  
anyway…

-Jonathan N.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [May 14, 2010, 7:45pm UTC](https://www.ruby-forum.com/t/rake-versus-ruby/188607/3 "2010-05-14T19:45:43Z")

</div>

Mohit S. wrote:

> I was thinking of this on my way home, but could not come up with a good  
> answer… what is the extra bit that Rake gives me, which I don’t get  
> from a Ruby script?  
> I’m sorry it’s a bit of a naive question, but I was wondering when would  
> it be more appropriate to use Rake compared to vanilla Ruby!

Off the top of my head:

- Dependency chain management
- Ability to re-use other people’s \*.rake files
- Handy means to get a list of commands

That last one is quite useful. I have a habit of knocking out helper  
scripts for little project tasks, and I end up with a set files whose  
actual purpose or behavior is not entirely clear. If I move the code  
into Rake tasks with a decent namespace then I can more easily see what  
helper code I have by running rake -T | grep my-cool-namespace

And I have a global helper script, rt, that calls rake -T and if you  
pass an argument it will grep the output to filter the results:

$ rt # Same as rake -T  
$ rt jimbo # Same as rake -T | grep jimbo

Since your rake files can have plain old Ruby methods in them there’s  
nothing you can do in vanilla Ruby you can’t do in Rake, though calling  
Rake can have some start-up overhead. Oh, and passing command-line  
arguments in Rake sucks ass. So there are trade-offs.

–  
James B.

[www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys  
[www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
[www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
[www.neurogami.com](http://www.neurogami.com) - Smart application development

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [May 14, 2010, 8:00pm UTC](https://www.ruby-forum.com/t/rake-versus-ruby/188607/4 "2010-05-14T20:00:21Z")

</div>

On May 14, 2010, at 10:44 AM, James B. wrote:

> [snip]…end up with a set files whose actual purpose or behavior is not entirely clear. If I move the code into Rake tasks with a decent namespace then I can more easily see what helper code I have by running rake -T | grep my-cool-namespace

FYI:

$ rake -T | grep collation  
rake db:collation # Retrieves the coll…

$ rake -T collation  
rake db:collation # Retrieves the coll…

The grep is unnecessary. -T will do it for you.

~ j.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [May 19, 2010, 3:54am UTC](https://www.ruby-forum.com/t/rake-versus-ruby/188607/5 "2010-05-19T03:54:14Z")

</div>

John B. wrote:

> The grep is unnecessary. -T will do it for you.

Interesting. Does not grep the description, though.

James
