all repos — h3rald @ e03ca4dcf9c10f799d88512c6cf8b80c0aea01a0

The sources of https://h3rald.com

content/articles/10-reasons-to-learn-ruby.textile

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
----- 
summary: "Ten possible reasons to learn the Ruby Programming Language. Mostly related to the language's syntax and most useful idioms."
popular: true
permalink: 10-reasons-to-learn-ruby
filters_pre: 
- erb
- redcloth
title: 10 Reasons to Learn Ruby
comments: 
- :date: 2007-09-05 17:33:43 +02:00
  :author: Joel Moss
  :url: http://joelmoss.info
  :id: 48
  :body: "Great article! It just explains perfectly why Ruby is starting to take over my life. And why Rails makes CakePHP look like a very weak wannabe. But I don't blame Cake (I use it every day); it's PHP's fault. "
- :date: 2007-09-05 22:55:39 +02:00
  :author: paddy3118
  :url: http://paddy3118.blogspot.com
  :id: 49
  :body: |-
    No mention of maintenance or testing?
    
    Now you have learnt Ruby, would you defend being able to write code where the indentation is contrary to the code structure?
    
    - Paddy.
- :date: 2007-09-06 01:07:22 +02:00
  :author: Fabio Cevasco
  :url: http://www.h3rald.com/
  :id: 50
  :body: "@Joel: Glad you discovered Ruby! Good luck!\n\n\
    @Paddy: You're right. I should have mentioned at least testing. I updated the article (Reason #1) to at least mention Test::Unit. And yes, as a matter of fact since I've been using Ruby my code indentation definitely makes more sense. You seem to be a Python enthusiast, from your site at least: sorry about the silly  remark about Python's indentation in my article... I just couldn't resist (but I did added an interesting note about Python's indentation in the notes too). "
- :date: 2007-09-06 07:57:41 +02:00
  :author: Chris
  :url: ""
  :id: 51
  :body: Thanks so much for this. I've been teaching myself to program for several months now with Ruby, and this very much helped me put things I've learned into context.
- :date: 2007-09-07 03:14:21 +02:00
  :author: Frank Spychalski
  :url: http://amazing-development.com
  :id: 53
  :body: |-
    Very nice writeup. I totally agree. 
    
    There's only one thing I really hate about Ruby: it made me realize how bad the other languages are and took a lot of fun out of the "normal" software development. 
    
    Right now I have to code PHP (BTW, Joel is 100% correct, CakePHP is a pretty good framework and makes working with PHP bearable) and more than a few times every day I would like to puke because the language sucks.
- :date: 2007-09-07 05:17:27 +02:00
  :author: Masklinn
  :url: ""
  :id: 54
  :body: "> Interactive Shell: the Interactive Ruby Shell can be used to test Ruby code instantly, similar to the Python console.\n\n\
    Similar, but much much worse. The Python consoles (both CLI launched by typing \"python\" and the IDLE environment) are more flexible, more practical and much less annoying than IRB (I suppose that's what you were talking about)\n\n\
    > Unfortunately this means that you won\xE2\x80\x99t be able to write your whole program in a single line of code, like the C++ folks\xE2\x80\xA6that\xE2\x80\x99s too bad, isn\xE2\x80\x99t it?\n\n\
    In reality, you can. The statement terminator (in both Ruby and Python) is either a newline or \";\".\n\n\
    So you can write your whole Ruby program on a single line, I think (you'd need to use parens to define functions, but it can be done.\n\n\
    > Everything is an object, as it should be\n\n\
    I think you should use examples with things that aren't objects in \"popular\" languages, such as integers or booleans, or even `nil`. Strings aren't object in PHP because PHP barely has objects, so it's not really fair.\n\n\
    > Everything has a value\n\n\
    You should emphasize that point by showing that e.g. if/else blocks return a value.\n\n\
    > the value of the last assignment will always be returned.\n\n\
    Didn't you mean \"the last value evaluated\" or \"the value of the last expression\"? Because you definitely aren't limited to assignments.\n\n\
    > You can do the same thing in PHP as well, but most people don\xE2\x80\x99t really use the function.\n\n\
    Because it's ugly, hackish, and since you create functions by providing strings there is no syntax checking before runtime itself."
- :date: 2007-09-07 05:44:24 +02:00
  :author: Fabio Cevasco
  :url: http://www.h3rald.com
  :id: 55
  :body: "@Masklinn: Thanks a lot for your comment. I updated the article where necessary!"
- :date: 2007-09-08 01:33:10 +02:00
  :author: Kookoolen
  :url: ""
  :id: 56
  :body: |-
    Nice article.
    
    For feature #4, you should add that even nil is an object. Try nil.to_i for example.
    
    Moreover you can open NilClass and add your own methods ! Rails does so to add debugging information when you called a method on nil.
- :date: 2007-09-08 01:39:37 +02:00
  :author: IronRuby
  :url: http://ironruby.blogspot.com
  :id: 57
  :body: |-
    
    Hi,
    
    Nice and happy to see your 10 Reasons added to "10 another advantages":http://ironruby.blogspot.com/2007/09/many-reasons-to-fall-in-love-with.html on a blog that is based on IronRuby.
    
    The Author claims 10 + 10 Advantages as 100 rather tan 20. 
    
    Happy Reading there.
- :date: 2007-09-08 10:35:28 +02:00
  :author: FlySwat
  :url: ""
  :id: 60
  :body: |
    So ruby has all of the features that C# has, except that its slower.
    
    Cool!

- :date: 2007-09-10 01:28:59 +02:00
  :author: Shantanu
  :url: ""
  :id: 61
  :body: Have you taken a look at Scala, or Erlang?
- :date: 2007-09-11 13:06:50 +02:00
  :author: Steffen
  :url: http://www.ruzee.com
  :id: 62
  :body: |-
    Correction for #8:
    
    The syntax for hash initializers is
    
    { :key1 => value1, :key2 => value2, ... }
    
    ('=>' instead of just '=')
    
    ...
- :date: 2007-09-11 15:19:16 +02:00
  :author: Fabio Cevasco
  :url: http://www.h3rald.com
  :id: 63
  :body: |+
    @Shantanu: I am now, they sound interesting actually.
    
    @Steffen: You're 100% right. This was due to the fact that I accidentally stripped all the > symbols out of the article when I converted it from BBCode to Textile. Thanks!
    
- :date: 2007-09-11 16:13:25 +02:00
  :author: Erik Ordway
  :url: ""
  :id: 64
  :body: |-
    The thing that everyone always seems to forget about XML is that it was never meant to be read/written buy humans.  It was and is meant to be a cross language/platform transport methodology.  It is easy process on each end without having to dealt with things like big and small endingness , line feed and carriage returns in files, and crap like that.  The core of it is that if you personally are reading or writing XML then you are doing something wrong.  Ant on java being a classic exampl, it was not even valid xml.  
    All that said I love Ruby too.
- :date: 2007-09-11 23:47:36 +02:00
  :author: !binary |
    5pel

  :url: ""
  :id: 66
  :body: !binary |
    5pel77yM5oiR6YO955yL5LiN5oeC

- :date: 2007-09-12 04:19:26 +02:00
  :author: jim
  :url: ""
  :id: 67
  :body: And make sure to read through resources such as http://snippets.dzone.com/tag/ruby as well. A real time saver from time to time!
- :date: 2007-09-12 20:11:38 +02:00
  :author: wayne
  :url: ""
  :id: 68
  :body: !binary |
    5oiR5LqG6KejcnViee+8jOS9huaYr+eci+WujOWQjuaIkeWGs+WumuW8gOWn
    i+WtpuS5oHJ1Ynk=

- :date: 2007-09-14 07:24:57 +02:00
  :author: Josh S.
  :url: http://www.fireandknowledge.org
  :id: 70
  :body: |-
    Very interesting -- makes me more interested in Ruby than I've ever been.
    
    BTW, your PHP number example is missing semicolons.
- :date: 2007-09-14 09:21:16 +02:00
  :author: wefwefwef
  :url: ""
  :id: 72
  :body: |-
    10 reasons to NOT learn ruby:
    
    1. It's Shit
    2. It's Shit
    3. It's Shit
    4. It's Shit
    5. It's Shit
    6. It's Shit
    7. It's Shit
    8. It's Shit
    9. It's Shit
    10. It's Shit
- :date: 2007-09-14 12:15:41 +02:00
  :author: Anders Persson
  :url: ""
  :id: 73
  :body: |
    Still Java and C# have nice built-in GUI handling, and i don't have to download a lot of package like TCL/TK.
    Ok Ruby like other language is nice, but for people like me that have to develop GUI-apps from time to time Java and C# still is my choice.
    
    I was looking into Ruby, and it is nice but...
    Maby the language expands in the future.

- :date: 2007-09-15 01:06:37 +02:00
  :author: Anon
  :url: ""
  :id: 74
  :body: |+
    Do I smell Blub programmers in the previous two comments?
    
- :date: 2007-09-16 12:23:53 +02:00
  :author: Anders Persson
  :url: ""
  :id: 83
  :body: |
    Hmm start to get old, i don't know what a Blub is, 
    But i guess it some one don't like eg Ruby.
    I can't talk for others, just for me.
    I like the syntax, and the language
    I have written a script to build my company software on Windows, looked a Perl as i have worked with before but thout that i could be nice to test Ruby, and it did a great jobb, easy to read etc.
    But to start using it as regular no 1 language i still missing easy GUI stuff like in Java.
    Maby you thing i am a "Blub" if so okej a put it on my card *smile*
    // Anders

- :date: 2007-09-17 15:13:43 +02:00
  :author: Fielding Feng
  :url: ""
  :id: 84
  :body: 10 reasons that describe in this article are either already exist in Java, or not very useful to me.  Except the unless  condition.
- :date: 2007-09-24 20:28:57 +02:00
  :author: toby
  :url: ""
  :id: 89
  :body: |-
    Python, en, i like it.
    Ruby, nothing
- :date: 2007-10-07 13:32:09 +02:00
  :author: riffraff
  :url: http://www.goto10.it
  :id: 100
  :body: |
    good list, but a detail: lambda is a method, not a keyword :) 
    >> Kernel.method :lambda
    => #<Method: Kernel.lambda>

- :date: 2007-10-23 13:04:15 +02:00
  :author: el_vartauy
  :url: ""
  :id: 105
  :body: |-
    good list, but... why if you don't like the python indentation problems, you prefer yaml over xml?
    i think a handy built in method is not enough?
    good luck!
- :date: 2008-04-07 08:44:15 +02:00
  :author: http://prayas.blogvis.com/
  :url: ""
  :id: 228
  :body: |-
    liked your article and visitors arguments.
    Ruby rockssssss.
- :date: 
  :author: kraig
  :url: ""
  :id: 453
  :body: ruby is so cool, i love it as well!
- :date: 
  :author: "Arya A. "
  :url: http://asemanfar.com
  :id: 455
  :body: |-
    To those bashing Ruby without giving real reasons: you're not really accomplishing anything by posting.
    
    @el_vartauy YAML is especially good for configuration files because it makes it really easy to edit/read. As for using XML or YAML for data transfer, you're actually probably better off using JSON because XML tends to be larger in byte size and YAML isn't as supported as JSON or XML. And you should note that even Google, software engineer giant, decided XML wasn't right for their usage and developed Protocol Buffers (and recently open sourced it).
    
    @Masklinn More of a question than anything: What are the annoyances of IRB that Python interactive console lacks?
- :date: 
  :author: alan
  :url: ""
  :id: 456
  :body: |-
    @flyswat: so C# has all the features of C++, except that its slower. Since you're probably a microsharft fan, try ironruby and get essentially the same speed.
    
    @fabio: you can do ruby deployment as easily as php deployment with phusion passenger.
- :date: 
  :author: postmodern
  :url: http://houseofpostmodern.wordpress.com/
  :id: 479
  :body: |-
    Nice article, it summarizes many of the things that I use in everyday work.
    
    I'd suggest covering the Range class and the methods in Enumerable (such as each/map/select/inject/find/sort). Maybe talk about the other cool things you can do with blocks (aka closures). These tools have made solving projecteuler.net problems a cake walk.
    
    5.times { puts "oooh yeah" }
    
    5.downto(0) { |i|
      puts "t - #{i} minutes, until launch"
      sleep 60
    }
    
    (1..10).to_a
    => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    
    (1..10).map { |i| i * i }
    => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
    
    (1..10).select { |i| i % 2 == 0 }
    => [2, 4, 6, 8, 10]
    
    (1..100).inject { |sum,i| sum + i }
    => 5050
    
    (1..1000).to_a.reverse.find { |i| i % 11 == 0}
    => 990
    
    Also, might want to give a shout-out to Ruby 1.9.1, which is due to be released in 1.5 months. I'm currently using Ruby 1.9.1-preview1 for projecteuler.net stuff, it's byte-code VM is quite fast.
    
    As for the other comments that I noticed, it appears that other languages have some angry trolls. Not a language/community feature I'm really interested in.
date: 2007-09-05 12:40:00 +02:00
tags: 
- ruby
type: article
toc: true
-----
h3. Preamble

I discovered Ruby fairly recently, through the excellent Ruby on Rails framework[1]. Although I don't consider myself a Ruby expert by any means, I read the PickAxe[2], I've coded a few utilities for my personal use in Ruby and I'm currently developing with Rails during my free time. 

Ruby is currently my programming language of choice; I started off with Turbo Pascal in high school, discovered C and C++ at university, did my thesis in Java and learned PHP from scratch because I wanted to learn how to make websites quickly and easily. I guess I feel compelled to code sometimes, more as a form of entertainment than anything else.  Rather dissatisfied with what I tried language-wise, I was determined to start learning either Python or Ruby. I chose the latter because I didn't want incorrect indentation to break my code[3], and here I am, heaping praise upon it.

There are plenty[4] of introductions, tutorials, articles and essays of different sorts which aim to guide the novice and advise the guru on how to get the most out of Ruby. This article, however, is not one of them.
 
It's more of a modest, humble, and incomplete list of a few reasons which may (or may not) entice you to use Ruby or at least play with it a bit. A word of caution: if you are using another programming language for work or whatever, don't complain to me if you don't want to use it anymore - that's exactly what happened to me, but luckily, it didn't matter.  Ruby is a very beautiful and elegant language, but like all things of this sort, it may well poison your mind and corrupt your soul...

You have been warned.
h3. Why learn Ruby?

h4. #1 - You get all the treats without the tricks

Ruby borrows from all the best programming languages out there, from smalltalk to Java, Perl to Python[5]. Basically, here's the features and functionalities Ruby gives you which you may have seen elsewhere:

* _Exceptions:_ Believe it or not, exceptions are one of the most important things to master when developing any kind of application. PHP4 programmers probably won't know anything about them and they'll tell you to just print stuff on the screen or use their "extremely advanced" class for error handling. Please, ignore them. Fortunately for all of us, Ruby comes with try/catch (or better, begin/rescue) blocks and a series of predefined, extensible Exceptions to handle errors properly.
* _Namespaces:_ Ruby modules make excellent and easy-to-use namespaces, for the joy of Java and C++ enthusiasts.
* _Built-in Regular Expressions:_ For all the Perl monkeys, you can put something between slashes and it will become a regular expression, ready to be matched with a =~ operator.
* _Overloadable operators:_ Ruby lets you define operators like +, -, etc., for any of your classes.
* _Packages:_ Called "gems", they really are solid and precious indeed...and they work! Packages support dependencies, and they can be either cross-platform or platform-dependent.
* _Interactive Shell:_ the Interactive Ruby Shell can be used to test Ruby code instantly, similar to the Python console.
* _Unit Testing_: The @Test::Unit@ module makes things so easy that you really don't have any excuse not to test your code.


h4. #2 - You'll love the little things

Ruby is elegant. Why's that? Because it doesn't focus on making code _concise_ so much as _readable and usable_. Here are some tips to help you out:

*  You can use both _if_ and _unless_ in condition statements. Of course you can just use _if_ and negate the condition, but _unless_ can be less error-prone at times. Furthermore, you can use both operators as conditional modifiers, after a statement rather than before: _order.new unless order.exists_.
*  You can use question marks and exclamation marks at the end of your methods. Although no convention is enforced, ? is added if the method should return true or false, while ! is used to clarify that the method does something forcefully, like destroying a database record, chopping off the last character of a string, etc.
*  You can use the _alias_ directives to create an alias for a method already defined. In this way you can have an _exist_ and an _exists_ method at no additional cost or repetition.
*  You can use the _attr_reader_, _attr_writer_ or _attr_accessor_ directives to automatically generate getter and setter methods for specified class members.
*  Some naming conventions are enforced for your own sanity: constants, classes and modules are capitalized, methods and members must start with a lowercase letter; global variables are prepended by a $, instance variables by <code>@</code> and class variables by <code>@@</code>; etc.
*  Parentheses are optional in method calls.  You can therefore write _File.open("/home/h3rald/test.txt")_ or simply _File.open "/home/h3rald/test.txt"_, which is particularly handy with methods that don't take parameters.


h4. #3 - You won't ever use a semicolon again

You want to add another instruction? Just go on the next line. Hit <return> and you're done. In Ruby, like in Python, newlines matter and you don't have to remember to end your instructions with a semicolon. Unfortunately this means that you won't be able to write your whole program in a single line of code, like the C++ folks... that's too bad, isn't it?

*UPDATE:* Indeed you CAN use semicolons as line delimiters in Ruby as well, the point, however, is that you don't have to.

h4. #4 - Everything is an object, as it should be

When I studied Java they taught me that everything is an object. 

_- "So 14 and 374346.678 are objects then?"_
_- "No, silly, they are numbers!"_

In Ruby, numbers, strings, Boolean values _et al_ are objects. Really. This means you'll write things like:

<% highlight :ruby do %>
"YOU SHOULDN'T ALWAYS USE CAPITALS".downcase #=> outputs "you shouldn't always use capitals"
-12.abs #=> outputs 12
<% end %>

instead of something like:

<% highlight :ruby do %>
# PHP Code

strtolower("YOU SHOULDN'T ALWAYS USE CAPITALS");
abs(-12);
<% end %>

You save time, you save brackets, and it just makes more sense. 

h4. #5 - Everything has a value

Or "you'll hardly ever use return to return values". In a nutshell, all Ruby instructions return a value, even variable assignments, so you don't really need to use the "return" keyword at the end of a method; the value of the last assignment or _any_ other expression will always be returned.

h4. #6 - You can alter your environment in any way you like

The first time I saw this, it really freaked me out. Imagine a typical programming situation: you start using a system class or a class written by someone else and you notice that you'd like to have an additional method. At this point you have a few ways to handle this in ordinary programming languages:
s
* You modify the developer's source code, if you have access to it. This is normally not a good idea, and you shouldn't do it.
* You derive a new class from the original one, and you implement the new method there. This is a good idea, but it could be overkill for just one method, and you may have to update some of your other code accordingly.
* You give up, and you just create the method outside the class, somewhere else. This can be done, but it is not very elegant and goes against Object Oriented Programming.

In Ruby, you can simply add the method to the original class, without having to hack the original source code, and even for system classes! You want to have a method to automatically convert a measurement from meters to feet? You can simply extend the Numeric class as follows:

<% highlight :ruby do %>
class Numeric
  def feet
	self*3.2808399
  end
end
<% end %>

From now on, all your numbers will have a _feet_ method, which can be used just like any other method that was originally defined for the class:

<% highlight :ruby do %>
5.feet #=> Returns 16.4041995
<% end %>

Basically, Ruby classes are never closed and can be modified at any time from anywhere. Use with care, of course.

h4. #7 You won't get unicorns from birds and horses, but you'll still get donkeys if you want

I distinctly remember my C++ professor at university using animals to illustrate key object-oriented concepts like classes and inheritance. Weird things came in when she tried to explain multiple inheritance to inherit a class Pegasus from a class Bird and a class Horse. It had methods like "fly" and "neigh"... crazy stuff, anyhow, Ruby does not offer multiple inheritance. 
This seems to be the trend, after all, and of course it's up to tastes. I don't quite fancy multiple inheritances, as they may lead to unpredictable things. Nevertheless, it is possible to create "mix-ins" using Ruby modules, so that members and methods defined in a module will be added to a particular class if the module is included in it. 

h4. #8 You don't really need XML

XML is a nice, general-purpose markup language which can be processed by every programming language and used everywhere. Unfortunately, it can also be quite verbose to write, very difficult to parse, and let's be honest, it's not really readable at first glance in many cases, unlike the following code snippet:

<% highlight :yaml do %>
regexp: !ruby/regexp /a-zA-Z/
number: 4.7
string: a string
<% end %>

This is definitely easier and more readable than XML, isn't it? Welcome to YAML, Ruby's favorite markup (but not really[6]) language, which can be used to represent any Ruby object in a simple, clear and yet complete way. 
Ruby _can_ parse XML, but YAML's simplicity convinced a lot of developers to use it as an alternative to XML for configuration files, for example (Rails does this).
The code snipped presented before was obtained by executing the following line of Ruby code:

<% highlight :ruby do %>
{"string" => "a string", "number" => 4.7, "regexp" => /a-zA-Z/}.to_yaml
<% end %>

The _to_yaml_ method is defined for the Object class, which is the father of all of the other classes, and thus it is available in all Ruby objects. This means that you can convert anything into YAML _and_ re-convert anything back into Ruby objects, with total transparency for the developer. So much for parsing, huh?

h4. #9 Lambda is much more than a Greek letter

Ruby borrows some magic from Lisp and Perl with Proc objects and blocks. Procs are _"blocks of code that have been bound to a set of local variables. Once bound, the code may be called in different contexts and still access those variables." _[7] Consider the following:

<% highlight :ruby do %>
   def gen_times(factor)
	 return Proc.new {|n| n*factor }
   end

   times3 = gen_times(3)
   times5 = gen_times(5)

   times3.call(12)               #=> 36
   times5.call(5)                #=> 25
   times3.call(times5.call(4))   #=> 60
<% end %>

I could have used the _lambda_ method instead of _Proc.new_ and gotten the same result. This should ring a bell for people who know Perl and Python (or Lisp)[8].  You can do the same thing in PHP as well, but most people don't really use the function.[9]

Additionally, Ruby makes extensive use of blocks, sort of "unborn Procs"[10], for example, to iterate the contents of an object and execute some code, like the _each_ method available for the Array class:

<% highlight :ruby do %>
[1, 2, 4, 6, 8].each {|c| puts c*2} #=> outputs each element multiplied by 2 in a new line. 
<% end %>

Should the code in the block exceed one line, you're advised (but not required) to include the block within _do ... end_ instead of using braces. Ruby folks don't like braces much, really.

h4. #10 - You can go on Rails

Last but not least, you can always use Ruby on Rails for developing web applications. Deployment may not be as easy as it is with PHP, but Rails was built in Ruby because Ruby has features no other language can offer.

h3. Conclusion

Time's up. You've probably made up your mind about Ruby already, and you are either playing with it already, or you're totally ignoring it.  However, the next time you're frustrated because your code looks ugly and you think you could have done the same thing with half the code you got, don't blame me!

h3. Notes

fn1. "Ruby on Rails":http://www.rubyonrails.org, MVC Web Development Framework.

fn2. "Programming Ruby (2nd Ed.)":http://www.pragmaticprogrammer.com/title/ruby/index.html, by Dave Thomas & others, Pragmatic Programmers, 2004

fn3. Not entirely correct, but sort of. For more information on Python's indentation rules and myths, read "Python: Myths about Indentation":http://www.secnetix.de/~olli/Python/block_indentation.hawk.

fn4. For a list of Ruby tutorials, refer to the "Documentation":http://www.ruby-lang.org/en/documentation/ section of the Official Ruby Website.

fn5. For more information on Ruby, and in particular on the similarities and differences with other languages, refer to "Ruby from Other Languages":http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/.

fn6. YAML is Not a Markup Language.

fn7. Definition and example taken from the official Ruby documentation for class "Proc":http://www.ruby-doc.org/core/classes/Proc.html.

fn8. For some example on lambda functions in Python, see "Python: Lambda Functions":http://www.secnetix.de/~olli/Python/lambda_functions.hawk.

fn9. For examples of "lambda functions" in PHP using create_function(), see "this":http://www.webmasterworld.com/forum88/7414.htm.

fn10. For more detailed information on Ruby's Procs, blocks etc. refer to "Understanding Ruby blocks, Procs and methods":http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods.