DevEX - reference for building teams, processes, and platforms
A Shallow Survey of Alternative Languages on the JVM
1. A Shallow Survey of Alternative
Languages on the JVM
Charles Anderson
March 2013
2. Introduction
● Survey a few languages on the JVM
○ Some philosophy of those languages
● Discuss the value of the Java Platform
● These concepts are applicable to other VM-
based platforms - e.g., Microsoft
3. The Java Language
● Been around for almost 20 years
● Verbose
● Slow to execute
● Slow to start-up
● Slow to evolve
● Very widely used
4. Ported Languages
● A language that was originally implemented
elsewhere - probably C/C++
● Common examples include : JRuby, Jython,
Jacl
● Others (from Wikipedia): Ada, Fortran,
Cobol, Go, etc.
5. Why?
● Because I can
● Research
● Easier than writing to bare metal or C
○ C is portable assembly
○ Java is the new C?
● To leverage the Java Platform
6. The Java Platform
● Java the language
● Java libraries - To Leverage Enterprise
Synergies of Multi-vendor, Standards-
compliant, Powerpoint slide decks
● Java Virtual Machine
○ Performance - JIT
○ Garbage collection
○ Threading
● Tools
● There's a reason Twitter moved a lot of their
system to the JVM
7. Best of Both Worlds
● Get to write in a cool, "new" language (e.g.
Ruby) without leaving the benefits of the
Java Platform
● Many such languages include a REPL
● You can use cool frameworks (e.g.
Cucumber or web apps) with your Java code
8. Issues with Ported Languages
● Owe allegiance to the mother language
○ Leads to impedance mismatches - e.g., JRuby
● Usually, can call into Java easily, but can run
into problems with other combinations - e.g.,
inheritance
● Performance - improving (invoke dynamic)
9. New Languages: Groovy
● Starting from Java, add cool stuff, cut down
on boilerplate - easy transition for Java
programmers
● Strives to be compatible with Java/Platform
● Cool playground for future features of the
Java language - e.g., closures
● http://groovy.codehaus.org/
10. Java or Groovy?
class Book {
private String title;
Book (String theTitle) {
title = theTitle;
}
String getTitle() {
return title
}
}
11. Stupid Pet Tricks
println ‘Hello World’
class MyBean implements Serializable {
String myProp
}
Thread.start { /* some code */ }
coll.each { item-> /* some code */ }
coll.findAll { it % 2 == 0 }.each{ ... }
new File(‘foo.txt’).eachLine { println it }
12. New Languages: Mirah
● Start with Ruby and move back towards
Java
○ static typing and type inference
○ no attempt at Ruby compatibility - no Rails
○ macros and meta-programming
● Very immature - v. 0.1 recently release
● http://www.mirah.org/
13. Little Sample of Mirah
def printN(str:String, n:int)
n.times do
puts str
end
end
14. New Languages: Scala
● Let's create a brand new language
● A hybrid of object-oriented and functional
○ Functional is important for multi-core
● Statically typed with a "dynamic" feel
● Still very compatible with Java/Platform
● http://www.scala-lang.org/
15. Samples of Scala
class Point (var x:int, var y:int)
employees.sort (_.age > _.age)
val s = for (x <- 1 to 25 if x*x > 50) yield 2*x
16. Other New Languages
● Clojure - LISP, functional
● Koitlin - compiles to Java or JavaScript
(from JetBrains/IntelliJ)
● Ceylon from RedHat
17. Conclusion
● You don't have to program in Java to get the
benefit of the Java Platform
● Classic Trojan horse strategy - testing or
other "utility" programming
○ not production
○ not performance critical
○ more productive testing means more real code
○ just a jar file