Ruby Simplified Part 2: Major language features

Some features of the Ruby programming language, comparing them with C#,

1. Ruby is a dynamically typed programming language.
    C# got dynamic extensions to the language in C# 4.0

2. Ruby is open source. Not only is it free of charge, but also free to use, copy, modify, and distribute.
    C# is not open source, for an open source implementation of the ECMA standards for C#, see the Mono Project.

3. Ruby was designed as an interpreted language. The first Ruby interpreter (MRI) was written in C and was a single pass interpreter. The current official interpreter (YARV), however, compiles Ruby into something called ‘YARV Instruction Sequence’, which is then compiled just-in-time (JIT) to assembly language. There are several other implementations of Ruby (ex., JRuby, IronRuby, and MacRuby) which also compile the Ruby code in a two step process to machine language.
    C# also has a two-step process, it’s first compiled into an intermediate language (IL) by the C# compiler and then JIT compiled to machine language by the CLR.

4. Ruby is a pure object oriented language. In Ruby everything is an object. You can append .class to anything to get the class name. Type puts 1.class (you’ll get ‘Fixnum’).
    In C#, not everything is a object (numbers, structs, etc.)

5. Ruby has automatic memory management.
    C# also has a full fledged garbage collector.

6. Ruby supports single inheritance only. Although we’ll see how to implement multiple inheritance using modules/mixins.
    C# also supports single inheritance only. Multiple inheritance in C# is implemented using interfaces.

7. Ruby has modern exception handling features (using begin-rescue-ensure).
    C# equivalent of this is the try-catch-finally blocks.

Advertisements

About soumya chattopadhyay
I live and work in Seattle, WA. I work with Microsoft technologies, and I'm especially interested in C#.

One Response to Ruby Simplified Part 2: Major language features

  1. Pingback: Ruby Simplified Series | I.Net

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: