The miracle of Ruby

The miracle of Ruby

 

 

Ruby on Rails was born in July, and the founder romantically named it Ruby on the birthstone of July. In the web field, is Ruby really the "silver bullet" of software development?

Ruby on Rails is a miracle in the field of web application development. This web development framework, which was born in July 2004, has become the standard-bearer of leading web application reforms in just two years and has caused numerous waves in the field of software development.

Ruby on Rails claims to be 10 times faster than J2EE development since its birth. It is regarded by many as a silver bullet for software development; it has stimulated a large group of development frameworks that imitate Ruby on Rails to spring up like mushrooms.

At the Oscars in the software development industry in 2005, the Jolt Award was presented, and RoR made the show. David Heinemeier Hansson (hereinafter referred to as DHH), the author of the Rails framework, was selected as the 2005 open source software OSCON Hacker of the Year at OSCON hosted by industry giants such as Google, Yahoo, O'Reilly, etc., which is enough to show that the Rails framework is in today The great achievements and widespread recognition in the field of Web development.

In addition, RoR is not only attracting the attention of developers. In 2006, Wired magazine used a large photo of DHH as the cover character to report on the achievements of RoR. On the cover of Wired, DHH was Wearing the black one-piece suit of Neo in "The Matrix", he seems to be a leader in the field of software development, appearing in a posture of saving all beings in the software field.

At the same time, the Rails community is growing at an alarming rate, and the degree of community activity can also be described as hot. The Railsconf held in 2005 and 2006 for two consecutive years has become a grand event for Rails developers and fans. Why can RoR accomplish these miracles?

The source of Rails power

Ruby is an object-oriented dynamic scripting language, created by Japanese Matsumoto Yukihiro in 1993, and the first version of Ruby was officially released in 1995. Since the publication of "Programming Ruby" (commonly known as "The Pickaxe Book") in 2000, Ruby has begun to attract worldwide attention. But the catalyst for Ruby's rapid promotion is precisely because of the launch of the Rails framework and the advent of the Internet Web2.0 era.

The reason why Ruby can create a framework like Rails is inseparable from the many powerful capabilities of its dynamic object-oriented language:

Scripting language

It does not require a compilation process and can be run directly, so it can greatly speed up the process of writing-deploying-running and increasing the speed of development. This advantage of scripting languages ​​is difficult to overcome by compiled languages.

Dynamic language

The category of objects can be dynamically changed during the runtime of the program, and the characteristics of dynamic languages ​​make Ruby extremely powerful. However, Java does not have this ability, and the behavior of this object cannot be changed dynamically during the running of the program. Although Java has gradually introduced dynamic reflection and proxy mechanisms, it is expected that more behaviors will be woven into Java objects at runtime, thereby providing more powerful and flexible functions.

All these efforts in the Java field are actually AOP (Aspect Oriented Programming). In the past few years, Java's AOP programming has made great progress, and it has always been one of the hotspot technologies in the Java field. However, for Ruby, due to the dynamic capabilities of the language itself, AOP is not needed at all. Ruby's dynamic capabilities are much more powerful, flexible and convenient than those provided by any Java AOP framework.

No need to specify the object

The figurative statement is: if an animal walks like a duck and calls like a duck, then we think it is a duck.

In the Java language, the behavior of an object is defined by the interface implemented by the object's class. This interface specifies what kind of behavior the type should have, that is, the type determines the behavior.

But for Ruby, it's the opposite. Behavior determines type, not type determines behavior. What kind of behavior an object exhibits during program operation, then what type it is. Therefore, Ruby does not require an interface, nor does it require an IoC container.

Ruby also has many interesting and powerful features, which are much more powerful and simpler than Java, and the power of the Rails framework comes from the Ruby language, which far exceeds the powerful capabilities of Java.

Why is Rails so popular?

The birth of the Rails framework is quite legendary: DHH, the author of Rails, was an undergraduate at the University of Copenhagen in Denmark in 2003. Before he came into contact with the Ruby language, he had only two years of PHP programming experience and a J2EE graduation project experience. At that time DHH received an invitation from 37signals in Chicago, USA to help 37signals develop a web-based project collaboration management software-basecamp. DHH decided to use Ruby to develop this web project on the recommendation of a friend. After 4 months, DHH completed the development of basecamp. After that, DHH stripped out the underlying framework written by itself in basecamp and named it Ruby on Rails, which was officially released in July 2004. Then Rails caused an earthquake in the entire web development field. What makes Rails so magical?

Amazing development speed

Rails advertises that it is 10 times faster than J2EE development. This is not an exaggeration. According to the author’s own development experience and feedback from other Rails developers, Ruby on Rails can indeed achieve about 10 times the efficiency of Java development of Web projects, even if not very Developers familiar with Rails can often achieve 5 times the development speed of Java. A 10 times speed means that the work that was originally completed in 10 months can now be completed in only 1 month, and productivity can be increased by 10 times. It is really unlikely that it will not cause a sensation.

Very little development code

Developed with Rails, the amount of code in the project is very small. A typical view is that the amount of code in a Rails project is about 1/4 of the amount of code in a Java project. Maybe this algorithm includes the page code. According to the author's actual experience, the page code is not counted, only the background program code. The Ruby code and configuration of the Rails project are only 1/10 of the number of Java code and XML configuration lines of the Java project.

A substantial reduction in the amount of project code can not only effectively speed up the development speed, but also greatly reduce the cost of project maintenance. After all, compared to maintaining 5000 lines of code and maintaining 50,000 lines of code, the maintenance cost does not increase proportionally, but exponentially. Finally, for developers, the psychological pressure of 5,000 lines of code and the psychological pressure of 50,000 lines of code cannot be compared. In a relaxed and happy mood, the quality of the software code will be very high.

 

 

Simple is beautiful

For a Java developer, it takes at least 6 months of training to be proficient in using mainstream frameworks to develop web projects, but a Ruby developer must be proficient in using the Rails framework to develop web projects, at most one month is enough. The learning threshold has been greatly reduced, and the training cycle of developers has been greatly shortened. This is one of the main reasons why Rails has become popular in just two years. Only the simpler can be quickly mastered by more people.

Web 2.0 fuels the flames

Ruby on Rails itself was born for the development of typical Web2.0 applications, so Ruby on Rails is like tailor-made for Web2.0 website development, and it has quickly gained the favor of many Web2.0 website developers. With the advent of the Web2.0 era, RoR has naturally captured the attention of Web developers.

Of course, some people doubt whether the scripting language can complete enterprise-level program development. The static compilation check of the compiled language is actually not as reliable as expected. With the extensive use of AOP, dynamic proxy technology, and bytecode enhancement technology in Java projects, in fact The security assurance brought by the compilation check has been severely damaged.

Through the practice of Rails development projects, I have not found that scripting language brings much trouble in this regard. On the contrary, because the script language programming is simple, it can significantly improve the quality of the software code.

View Image

The founder of Rails is introducing RoR

View Image

Image comparison between RoR and J2EE

 

 

Reference : https://blog.csdn.net/chenguoda/article/details/2284968