Upload
charles-anderson
View
689
Download
1
Embed Size (px)
DESCRIPTION
TBA
Citation preview
A Shallow Survey of Alternative Languages on the JVM
Charles AndersonMarch 2013
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
The Java Language
● Been around for almost 20 years● Verbose● Slow to execute● Slow to start-up● Slow to evolve● Very widely used
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.
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
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
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
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)
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/
Java or Groovy?
class Book {private String title;Book (String theTitle) {
title = theTitle;}String getTitle() {
return title}
}
Stupid Pet Tricksprintln ‘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 }
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/
Little Sample of Mirah
def printN(str:String, n:int) n.times do puts str endend
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/
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
Other New Languages
● Clojure - LISP, functional● Koitlin - compiles to Java or JavaScript
(from JetBrains/IntelliJ)● Ceylon from RedHat
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