Introduction to Ruby
- Amruta Bhaskar
- Dec 5, 2019
- 0 comment(s)
Ruby is an object-oriented a programming language developed by Yukihiro Matsumoto. Ruby is a dynamic programming language with a complex but at the same time expressive grammar. Ruby also has a core class library with a rich and powerful API.
Ruby is inspired by other low level and object-oriented programming languages like Lisp, Smalltalk, and Perl and uses syntax that is easy for C and Java programmers to learn.
Ruby, a dynamic and open-source programming language with a focus on simplicity and productivity has an elegant syntax that is natural to read and easy to write.
Although it's easy to program in Ruby, it is not a simple language.
Features of Ruby
1. Object-Oriented: Every value in Ruby is an object, even the most primitive things like strings, numbers and even true and false. So, Ruby is a pure Object-Oriented Language. Every object has a class and every class has one superclass.
2. Dynamic: Ruby is a very dynamic programming language. Ruby programs aren't compiled like C or Java programs. All things in a program are built by the code when it is run. A program can also modify its own definitions while running.
3. Singleton Classes: Every object in Ruby has two classes: a regular class and a singleton class. An object's singleton class is nameless class whose only instances is that object. Singleton classes are created automatically and make Ruby simple and elegant.
4. Metaprogramming: Everything in Ruby are objects. You can use them to learn about them or even modify them, while your program is running. This technique is called metaprogramming.
5. Flexibility: Methods can be added to existing classes without sub-classing, operators can be overloaded, and even the behaviour of the standard library can be redefined at runtime.
- Exceptions for handling errors.
- Garbage Collector.
- OS- independent threading, which allows you to write multi-threaded applications even on operating systems such as DOS.
- You can write extensions to Ruby in C.
The Advantages of Ruby
Model-View-Controller (MVC) architecture: In this architecture, a web application has three interconnected layers. The model houses codes that work on the application data. It centralizes the business logic of the application and the rules to manipulate the data.
Conventions over configurations paradigm: This principle helps the developers save time and effort. Because the framework ‘assumes’ what they want to do and how to do it, they don’t have to keep in mind the details about configuration files.
Don’t Repeat Yourself (DRY): DRY encourages reducing the repetition of information within a system. This facilitates making modifications and minimizes errors in the software development cycle.
Simplicity: RoR leverages the advantages of the Ruby programming language. Its use of English-like syntax and the common language feels so native and logical that some parts of the code read like English declarations.
Faster development: Ruby on Rails minimizes the website development time by 25-50% as compared to other popular web frameworks. Sometimes it’s possible to have an MVP ready to go online within hours.
The Disadvantages of Ruby
Communities and Support
Languages like PHP and C#, two of the most popular coding languages, have extensive online support communities and published books. On the other hand, Ruby's support community is not as large as PHP support communities.
Several benchmark websites that regularly run and test response times of programming languages often describe Ruby as one of the slower programming languages.
When compared to other computer languages, Ruby is fairly new and has its own unique coding language. Some programmers consider this a disadvantage because they have to take considerable time just to learn the language before using it.
Author: Bharani G R