JRuby: The director of Java and ROR

Source: Internet
Author: User
Tags java web

Rails is rapidly becoming a leader in lightweight Web application development. With JRuby, rails is expected to gain the functionality, efficiency, and industry recognition of the Java Library and JVM.

JRuby is a ruby, java-based virtual machine (JVM) interpreter that combines the simplicity of the Ruby language with the powerful JVM's execution mechanism, including full integration with the Java library. Rails accelerates and simplifies the development of Web applications, but it's not mature enough, especially at high-end enterprise-level features. On the other hand, the Java platform and its virtual machines, libraries, and application servers have been upgraded in speed, stability and functionality, and are now recognized as the leading platform for high-end server applications. However, if the Java platform is not associated with emerging languages such as Ruby, it is likely to lag behind in fashion trends.

JRuby combines the benefits of all of these technologies to complement each other, promising to increase the visibility of ruby and rails while giving new roles to the Java platform in running a non-Java language.

The development direction of Rails:java framework

For Java developers, rails is a natural representation of the development of many Java Web frameworks: Reducing unnecessary code, mining more abstract and dynamic mechanisms, and more fully out-of-the-way functionality.

Conventions are better than configurations

Earlier versions of the Java Platform Enterprise Edition (Java EE) required a large amount of configuration and code for each component. For example, each bean in Enterprise JavaBeans has multiple source code and XML configuration files. This complexity makes EJB a byword for heavyweight development, resulting in a 180-degree shift in EJB 3: The minimum redundancy and configuration of common Java object (POJO) beans. Even so, heavy-duty Java EE applications still require developers to develop code to represent the same business object on multiple software tiers, including GUI, business logic, and persistence layers. Then, despite the redundancy and similarity between layers and layers, developers still have to glue the layers together with a configuration file. By contrast, the newer Java Web frameworks, such as seam and spring, use minimal configuration and code to publish business objects.

The Java framework has also been moving toward standardizing and integrating stacks across multiple tiers of Web applications. In the early days, Java Web application developers manually wrote code, obtained HTML output from server applets, created their own model-view-controller (MCV) architecture, and accessed the database using SQL instead of Java database connection (JDBC). Later, they gathered components that performed most of the common functions, such as tag libraries, struts, and hibernate. Most recently, spring has integrated most of the functionality into a single, Top-down, lightweight stack.

From the outset, rails embodies these simplicity principles, which are called "Don't repeat Yourself" and "Contract over configuration" in the rails community (avoiding redundancy and meaningful defaults are two of the oldest principles in the Software engineering World). The framework can be based on a concise agreement to guess the connection between different layers. Rails can even explicitly and dynamically add properties to reflect database columns: The last_name column automatically causes the Last_Name property to appear.

In exceptional cases where the Convention does not meet the requirements, the configuration can still be added using pure Ruby code or a lightweight YAML format similar to Ruby, both of which delete redundant brackets and closing tags for XML.

Dynamic and reflective mechanisms

The Java framework has also been more widely used to reflect and meta programming mechanisms. For example, Spring uses a reflection mechanism to connect parts with dependency injection, and the standard Java EE Server family usually takes a static approach. Hibernate this popular object-relational mapping framework uses dynamic metaprogramming for mapping, updating bytecode at run time, unlike early data access frameworks that need to generate a lot of source code or bytecode during development.

Hibernate developers had to use some advanced technology to implement this feature. In Ruby, Metaprogramming is an organic part of the language, and as a result, rails can not only dynamically generate mappings at run time, but also generate the business layer class definitions needed to access and display the underlying database, minimizing this need.

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.