Take a couple of exciting new JVM languages, add Java itself, sprinkle on a performance test and what do you get?

Fantom - Faster than Java!

Some surprising results!

In a test that performed calculations on financial instrument price movements, it was found that Fantom, a language that compiles into Java byte code, was more than twice the speed (x2) of Java itself!

Fantom is x2 faster than Java and x3 faster than Kotlin

Kotlin, another language that compiles into Java byte code, was much much slower. In fact, it was more than 3 times slower than Fantom, and as you might expect for a derivative language, was also slower than Java.

How!?

So how can Fantom, a language based on Java, be faster than Java?

Although Fantom runs on the JVM, all of Fantom's core libraries have been written from scratch. Brian Frank, one of Fantom's creators, comments:

There are definitely some libraries we've optimized the heck out of - especially the sys APIs.

In fact, after inspecting the test code Brian goes on to mention that the Fantom test code is sub-optimal. And that with a couple of minor type changes, it could be even faster!

The Test

The test processes a directory of stock data files taken from finance.yahoo.com and calculates the Open-high-low-close data.

The test, along with the source code for Fantom, Java and Kotlin, is available on GitHub.

The full results, as reported on the Fantom Discussion Forum, are:

:            Time      Code Size
---------------------------------
 Fantom    1.2 secs    105 lines
 Java 8    2.9 secs    141 lines
 Kotlin    4.2 secs    130 lines

Moar Details

Read the full discussion on the Fantom Forum under Fantom speed impressive....

And here you can read an official stance on Fantom vs Kotlin (and other JVM langs).

Have fun!

Oh, and by the way...

All the facts presented here are correct. The style however is a bit tongue-in-cheek and an attempt at writing a sensationalist tabloid article. Hope you liked it!

Edits:

  • 9 April 2017 - Added Fanny vs Duke picture.
  • 16 Jun 2014 - Original article.

Discuss