JRuby is for Ruby, Java Virtual Machine-based (JVM) an interpreter, which combines the simplicity of Ruby language and powerful JVM implementation mechanisms, including full integration with the Java libraries. Rails to speed up and simplify the complete Web application development, but it is not mature enough people think, especially in the high-end enterprise-class functionality. On the other hand, Java platform and the virtual machine, library and application server, the speed, stability and functionality has been upgraded is now recognized as the leading development platform for high-end server applications. But if not and Ruby Java platform linked to the emerging language, there may be behind the trend.
JRuby combines all the advantages of these technologies complement each other, is expected to increase the visibility of Ruby and Rails, while for the Java platform to run non-Java language gives new role.
Rails: Java development framework
Development officer, on Java, Rails is like a natural on behalf of Le numerous Java Web framework Fazhan trend: reduce unnecessary for Daima, Caiyonggengduo abstract and dynamic mechanism and the general aspects of the Kai that Yong Gong Neng.
Convention over configuration
Early versions of the Java Platform, Enterprise Edition (Java EE) for each component requires a large number of configuration and code. For example, Enterprise JavaBeans to have multiple sources for each bean code and XML configuration files. This complexity makes the heavyweight EJB development has become synonymous with the end result EJB 3 180-degree change occurred: seek regular Java objects (POJO) bean minimum redundancy and configuration. Even so, the heavy-duty Java EE application developers still need to code to represent multiple layers of software (including GUI, business logic and persistence layer) on the same business object. Then, although there is redundancy between layers and similarity, developers still have to use configuration files to glue the layers together. In contrast, like Seam and Spring these relatively new Java Web framework and code using the minimal configuration, you can publish business objects.
Java framework has been in the Web application across multiple layers of the standardized and integrated into the stack. In the early, Java Web application developers to write code by hand, from the server applet access to HTML output; create your own Model - View - Controller (MCV) architecture, and use SQL rather than Java database connectivity (JDBC) to access the database.Later, they gathered the implementation of the most common functions of the components, such as tag libraries, Struts and Hibernate. Recently, Spring will be most of the functionality into a single, top-down light stack.
From the beginning, Rails to reflect the simplicity of these principles in the Rails community is called "Do not repeat yourself" and "convention over configuration" (to avoid redundancy and meaningful default value is software engineering in the field of two Article ancient principle). The framework agreement according to simple, guess the relationship between different layers of connections. Rails can even explicit, dynamically add attributes to the database column reflection: last_name last_name attribute column will automatically appear.
Can not meet the requirements of the agreed special circumstances, you can still use pure Ruby code or YAML format similar to Ruby's light add configuration, Both formats deleting the XML of the redundancy in square brackets and end tags.
Dynamic and reflection
Java framework has been in the reflection and meta-programming mechanisms for the use of more extensive and forward. For example, Spring uses reflection, using dependency injection to connect the various parts; standard Java EE server series is usually static. Hibernate this popular object-relational mapping framework for mapping dynamic element programming, update the byte code at run time, unlike earlier data access framework needs to generate a lot of time in the development of source code or byte code.
Hibernate developers had to use some advanced techniques before to achieve this functionality. But in Ruby, and Yuan programming Que yes Zhezhong an integral part of language, Jie Guo Neng Rails not only in Yunxing O'clock News Sheng Cheng map, but also generate the underlying database Suo Xu Fang Wen and Xian Shi's business layer class Dingyi to minimize Le This needs.
Support the development process
Before and after the late 90s of last century, Java developers use JUnit framework a large number of test methods, but for server side applications written test cases are always difficult. Now Spring in the Web application generated while generating tests. Rails has the same function, full use of the dynamic mechanism and meta-programming techniques to support a variety of testing: unit testing, functional testing and integration testing.
Why in the JVM to run Rails
If you are using Java frameworks such as Spring and Hibernate, it would not need to change.However, if the flexibility to choose a project for the next new development method, consider Rails.
Unfortunately, switching to a new language is generally considered dangerous to move, there are concerns about risk management. Rails JRuby enables more easily accepted by managers. On the JVM, Rails has become a Java framework. For example, "Java" Web framework for non-Java language is actually the same in JavaServer Pages.
As is usually C / C + + operating system written in more abstract language to use applications written in the same framework provides the basis, Java platform for Ruby and other dynamic languages to play "system software" role, providing a level of support infrastructure . Now you can access many features through Java. JDBC and Java Message Service (JMS) and other API is the best kind, and while many irreplaceable internal or independent software developer of enterprise information systems through Java API to access. Rails application using JRuby, you can call Java code as the existing Java libraries, as calls.
With JRuby, Rails applications with Java Web applications in existing Java EE application server to run together. This application server has a strong technology infrastructure. Personnel and training, is usually not a lack of educational programs and experienced developers and support staff. Also as long as the JVM running on the server this application access to the last ten years has invested in many of JVM optimization project benefits.
Ruby has a much more complex than the JVM security model provides for the JRuby on Rails Web application to handle the security problems of common tools, including control of the various sources from the Ruby script. It also contains internal support for internationalization features.
Forward to the dynamic language, this is the mechanism in the abstract to the more advanced one aspect of language development. JVM environment in the management of the operating system level, rather than run the Ruby interpreter is to a higher level of abstraction step. Using Rails as a Web application layer standard implementation mechanism is true, only the application-specific functionality left to the developer.
Links: JRuby problems facing
As the version number shown, JRuby 0.9.2 is not ready to run production applications. Some errors to be resolved; addition, the current rate of JRuby than MRI. Used in conjunction with the Rails requires non-standard Java application server adapter server applet, and build war files need special Ant script, both of which is not a standard part of JRuby release.
Rails in dealing with legacy components is particularly weak area. Although the most common problems to solve Rails provides good support, but lacks the flexibility to support alternative. For example, assume that activity records for each table has a primary key named id of a single column.Although you can use the keys out instead of another name, if it does not use special plug-in, you can not define multi-column key. In contrast, Hibernate and other Java frameworks Although simple (and common) case of developing more slowly, but the legacy code to deal with extreme conditions and the effect is much better than Rails.
In the end, with the main challenges facing Rails is really eager to present a unified standard language and framework. Rails applicable to such a relatively strong desire for new projects and new organizations.
No comments:
Post a Comment