10 reasons for learning Ruby

Source: Internet
Author: User
Tags ruby on rails
Recently, Ruby On Rails is very popular. This is a brand new way to develop Web programs. Using its advanced construction can help users quickly build a Web platform.
However, it is not clear to many developers why they need to switch to Ruby. H3raLd lists 10 reasons for learning Ruby.
1. You can use the powerful functions of all languages
The first is the error handling function, which must be controlled by all senior R & D personnel. In PHP, you can only print the error content on the screen, and then slowly guess what went wrong. Ruby uses a try/catch module method similar to C ++.
Secondly, Ruby namespace is also very easy to use. With the built-in powerful regular expression processor and various heavy-duty operators, you can find all the practical technologies you can think of in other languages.
2. You will fall in love with Ruby's Cute details
3. You don't need to call a semicolon.
In Ruby, it is the same as in Python. However, in this way, you will lose the chance to write all programs in the same line. Some people like this very much and hope you do not.
4. Everything is an object, which is the same as reality.
When I started learning Java, they told me that everything was an object, so I asked:
"So 14 and 374346.678 are also objects ?"
"Dummies, they're just numbers !"
However, in Ruby, all numbers, strings, and boolean values are objects! This means that you can write:
"You shouldn't always use capitals". lowcase
Then the screen will show: you shouldn't always use capitals
In PHP, YOU have to write: strtolower ("you shouldn't always use capitals ")
Let's take a look. You have saved time and parentheses. The most important thing is that such a program is more readable. Using everything as an object is obviously very helpful for expanding your thinking.
5. Each item has a value.
You will no longer use return to return a value. All Ruby statements return a value, which means that even if you do not return a value at the end, Ruby automatically returns a value.
6. You can switch freely in different R & D environments
After you use the classes provided by the system or the classes of others for research and development, you suddenly feel that some functions or methods are not well written and you should write one by yourself. If you are in traditional R & D, you have the following options:
A. modify the original code of the class. However, this is generally not recommended.
B. You inherit a new class from that class, and then add the code slowly. However, this will affect the code you wrote before.
C. You give up and create another class on your own. This may be very good, but it is very time-consuming and laborious.
In Ruby, you only need to simply add the new method to the original class. This does not involve any modification to the original code. For example, if you want to automatically convert from meters to inches, you can add a new method for the Numeric category:
Class Numeric
Def feet
Self x 3.2808399
End
End
From now on, you have added a feet method for all numbers.
5. feet #=> Returns 16.4041995
7. Ruby does not support multiple inheritance
8. You no longer need XML
Yes, I have to admit that XML is widely used. But to be honest, the first impression of XML is really bad, the structure is not clear, the mark is complex, and it is very difficult to understand. It is also difficult to describe and analyze programs. Because this Ruby's favorite markup language is YAML. This does not mean that Ruby does not support XML parsing. Ruby still supports XML, but many developers have realized that YAML has excellent performance and transferred from XML to YAML.
9. Lambda is much more than a Greek letter
10. You can use it on Rails
You will find that Ruby on Rails is the best R & D mode. Rails is integrated with Ruby because Ruby provides excellent performance that is not available in all other languages.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.