Skip to content

Instantly share code, notes, and snippets.

@leonelgalan
Last active December 27, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonelgalan/7323784 to your computer and use it in GitHub Desktop.
Save leonelgalan/7323784 to your computer and use it in GitHub Desktop.
A future blog post titled "The Beauty of Ruby (Part 1)"

The Beauty of Ruby (Part 1)

If you read the title and thought I was going to talk about the gemstone, you are in the right place. This series is intended for non-developers to understand why some of us, developers, prefer Ruby over other languages.

"Ruby is simple in appearance, but is very complex inside, just like our human body" says Yukihiro "Matz" Matsumoto, its creator. After 7 years in school studying computer science, I didn't felt like doing "rocket science" the rest of my life. Not all computer scientists (let's say developers from know on) enjoy dealing with the underlying complexities of computers every day. While studying, my area of interest was to solve complex problems with simple technology and Ruby fitted like a glove.

This blog post started 8 months ago with this tweet. I have been coding for a while and every day I am pleasantly surprised about how pretty my code looks thanks to Ruby. The resulting code is readable, even for non-developers, but more importantly for other developers that will contribute in the project later on.

Examples

Let me know which one you understand the most and which one is the prettiest (they don't have to be two, see Richard Seymour: How beauty feels and how "Form is Function").

I'm stealing David Jacobs ridiculous Java class name to make my point, Java is not a scripting language so it requires some structure to get started. My PHP skills are rusty so I asked myself, colleagues and Google what is the easiest way of getting the next week in PHP (See Examples).

Ruby

1.week.from_now
#=> Tue, 12 Nov 2013 11:40:37 EST -05:00

PHP

<?php
echo date('Y-m-d', strtotime('+1 week'));
// 2 Warnings and ...
// 2013-11-12
?>

Java

import java.util.Calendar;
class ThisIsAClassIDontReallyWantToNameButJavaMakesMe {
  public static void main() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, 7);
    System.out.printf("%tF%n", calendar);
    // 2013-11-12
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment