CSC/ECE 517 Fall 2013/ch1 1w03 ss

From Expertiza_Wiki
Revision as of 16:40, 17 September 2013 by Sarora3 (talk | contribs)
Jump to navigation Jump to search

Background

Over the last 10-15 years , the Java Virtual Machine (JVM) has been a popular platform to host languages other than Java. This can be attributed to the performance and “write-once-run-anywhere” portability of the JVM , as well as the other advanced features, providing runtime environments to the other languages.

Why have so many languages , including Ruby, Groovy,and Python, been ported to Java ?

The main reason is because its easier to target one platform and rely on the multi platform JVM to host it than it is to write interpreters for each of the operating system.

Additionally , with the JVM’s advanced Just-in-time (JIT) compilation ,the resulting compiled and optimized Java bytecode will typically run with equal or better performance than naive interpreters. Further , the Java JIT compiler continues to optimize code well after it’s first complied ,depending upon changes in code execution and branching. The cost and effort associated with building this into each independent interpreter makes this kind of performance prohibitive; so , it makes sense to leverage the JVM’s existing multi platform implementation of this performance optimization feature .

A list of other features that JVM brings along are a huge set of well tested libraries , garbage collection , excellent built-in tools and debugging interfaces that a language developer can easily plug into. The biggest advantage that JVM brings to the table is interoperability that it provides.

Prior to Java Se 7 2011 , there was a small penalty hit when crossing the barrier to and from Java code . This was because JVM was not initially built to support dynamically typed languages. To fix this Java Specification Request 292 was developed with the goal of creating a new bytecode instruction to resolve this issue. The result is the invoked dynamic bytecode, which is an enhancement to the JVM that allows dynamic and direct linkage between the calling code and receiving code at run time.

Different Fusion Languages

JRuby

JRuby is an implementation of the Ruby programming language atop the Java Virtual Machine, written largely in Java. JRuby is tightly integrated with Java to allow the embedding of the interpreter into any Java application with full two-way access between the Java and the Ruby code.

History of JRuby

Developers
  • Charles Oliver Nutter
  • Thomas Enebo

It was originally created by Jan Arne Petersen, in 2001.

JRuby 1.1 added Just-in-time compilation and Ahead-of-time compilation modes to JRuby and was already faster in most cases than the then-current Ruby 1.8.7 reference implementation.

JRuby packages are available for most platforms; Fedora 9 was among the first to include it as a standard package at JRuby 1.1.1 Recently , JRuby has been gaining more and more attention in the Java and Ruby communities.

Commercial Support for JRuby : Engine Yard Inc.

Compilation of JRuby code is mixed mode ie code can be interpreted ,JIT (Just in time ) compiled or AOT compiled.

JRuby was a big reason the invoke dynamic bytecode was added to Java with the Java SE 7 release. This allows all Java-to-Ruby and reverse calls to be treated the same as Java-to-Java calls. Additionally, JRuby inspired Sun's Multi-VM JVM research effort, where one JVM can act as a separate sandbox to each of multiple applications, allowing different versions of the JRuby runtime to be loaded and active at the same time.

Frameworks Support

JRuby has built-in support for Rails, RSpec, Rake, and RubyGems. It embeds an FFI subsystem to allow to use C libraries bundled as gems. It also allows launching the Interactive Ruby Shell (irb) as Ruby MRI does. The Netbeans Ruby Pack, available since NetBeans 6.0, allows IDE development with Ruby and JRuby, as well as Ruby on Rails for the two implementations of Ruby.

Advantages of JRuby over Java

• Ruby has features missing from Java

  • Closure (blocks)
  • Open classes
  • Meta programming
  • Duck-typing

• Domain Specific Language (DSL)

  • Through (J)Ruby's capability of allowing expressive method names and cushy semantics

Advantages of JRuby over Ruby

With JRuby you get the best of both worlds: Ruby applications and libraries, plus Java libraries. And you can access those libraries with Ruby syntax (or Java syntax, if you want).

  • On average JRuby, runs 2 and a half times faster than Ruby, except at startup
  • In addition to native threads, JRuby supports Unicode natively
  • Code can be fully compiled ahead of time or just in time