Ruby, a simple and gorgeous language

Source: Internet
Author: User

When it comes to Ruby, it's just a reflex to think of rails, which seems to have only one use for Ruby, rails. Although I didn't write rails, I thought the Ruby language itself was far more attractive than the third-party framework of rails. It is a language worthy of tasting, as well as a book called "Metaprogramming Ruby", which is also a taste of the language. Here is a passage from this book.

The Great Unified theory "the Ruby object model is a beautiful place,"
Bill notes, with a dreamy expression on the his face. "There is classes,
Eigenclasses, and modules. There is instance methods, class methods,
and Singleton Methods. " At first glance, it all looks very complex.
Look closer, and the complexity fades away. If you put eigenclasses
Together with regular classes and modules, your end up with the seven
Rules of the Ruby object model:
1. There is only one kind of object-be it a regular object or a module. ? 2. There is only one kind of module-be it a regular module, a
Class, an eigenclass, or a proxy class.
3. There is only one kind of the method, and it lives in a module-most often in a class.
4. Every object, classes included, have its own "real class," Is it a regular class or an eigenclass.
5. Every class has exactly one superclass, with the exception of Basicobject, and which has none. This means has a single ancestors
Chain from any class up to basicobject.
6. The superclass of the eigenclass of a object is the object ' s class. The superclass of the eigenclass of a class is the Eigenclass
Of the class ' s superclass. (Try repeating that three times, fast! Then
Look back at Figure 4.5, on the preceding page, and it'll all make
sense.)
7. When your call is a method, Ruby goes "right" in the receiver's real class and then "up" the ancestors chain. That's all there are to know
About the the-the-by Ruby finds methods.

When I read this, I was going crazy. With seven principles you can define a language and ask what language to do it (at least there is no second door in the language I've learned). Simplicity itself is a kind of beauty, and Ruby in its concise logic on the basis of the hypothesis, derived from complex and changeable characteristics, can simply be described with gorgeous. In fact, a lot of complex theoretical system is from a few mundane assumptions deduction.
I hope to follow these seven clues, with you taste ruby this simple and gorgeous language.

Ruby, a simple and gorgeous language

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.