CSC/ECE 517 Fall 2012/ch1 1w6 pp

From Expertiza_Wiki
Jump to navigation Jump to search

This page is about the mixing static and dynamic Object Oriented code. This page will mention some difficulties when these two types of object orientation are mixed and then we will give on practical example of such in JRuby. JRuby is mixing of Java and Ruby, this page will cover the different types of such mixings and examples of each of them.


Introduction

Difficulties in mixing static and dynamic oo

If the static oo makes use of generics for e.g. Java, then the generic types are erased during compilation for backward compatibility. As a result for a dynamically types language like Ruby, there will be problems with type conversion. For example, if you have a Map<String,String>, it will be seen as a simple Map, and JRuby will not be able to determine the correct types using reflection.

JRuby

Advantages of JRuby

Advantages of JRuby over Ruby

- With JRuby you get the best of both worlds: Ruby applications and libraries, plus Java libraries. Anthreads, JRuby supports Unicode natively - Code can be fully compiled ahead of time or just in time. - In addition to native 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

Advantages of JRuby over Java

Examples JRuby

References

Further Reading