Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell vs JVM performance [closed]

I want to write a backend system for a web site (it'll be a custom search-style service). It needs to be highly concurrent and fast. Given my wish for concurrency, I was planning on using a functional language such as Haskell or Scala.

However, speed is also a priority. http://benchmarksgame.alioth.debian.org results appear to show that Java is almost as fast as C/C++, Scala is generally pretty good, but Haskell ranges from slower to a lot slower for most tasks.

Does anyone have any performance benchmarks/experience of using Haskell vs Scala vs Java for performing highly concurrent tasks?

Some sites I've seen suggest that Scala has memory leaks which could be terrible for long running services such as this one.

What should I write my service in, or what should I take into account before choosing (performance and concurrency being the highest priorities)?

Thanks

like image 512
user1037541 Avatar asked Nov 18 '11 16:11

user1037541


People also ask

Is Java faster than Haskell?

http://benchmarksgame.alioth.debian.org results appear to show that Java is almost as fast as C/C++, Scala is generally pretty good, but Haskell ranges from slower to a lot slower for most tasks.

Is Haskell slower than Java?

The programming language benchmark game suggests that Haskell is roughly as fast as Java and C#, but this is complicated by the extensive use of foreign libraries in those languages.

Is Haskell fast enough?

Haskell (with the GHC compiler) is a lot faster than you'd expect. Used correctly, it can get close-ish to low-level languages. (A favorite thing for Haskellers to do is to try and get within 5% of C (or even beat it, but that means you are using an inefficient C program, since GHC compiles Haskell to C).)

Does Haskell run on JVM?

Haskell works beautifully on the JVM. See Eta, a project that brings full GHC 7.10. 3 Haskell onto the JVM with type-safe Java interop.


1 Answers

This question is superficially about performance of code compiled with GHC vs code running on the JVM. But there are a lot of other factors that come into play.

People

  • Is there a team working on this, or just you?
    • How familiar/comfortable is that team with these languages?
    • Is this a language you (all) want to invest time in learning?
  • Who will maintain it?

Behavior

  • How long is this project expected to live?
  • When, if ever, is downtime acceptable?
  • What kind of processing will this program do?
    • Are there well-known libraries that can aid you in this?
    • Are you willing to roll your own library? How difficult would this be in that language?

Community

  • How much do you plan to draw from open source?
  • How much do you plan to contribute to open source?
  • How lively and helpful is the community
    • on StackOverflow
    • on irc
    • on Reddit
    • working on open source components that you might make use of

Tools

  • Do you need an IDE?
  • Do you need code profiling?
  • What kind of testing do you want to do?
  • How helpful is the language's documentation? And for the libraries you will use?
  • Are there tools to fill needs you didn't even know you had yet?

There are a million and one other factors that you should consider. Whether you choose Scala, Java, or Haskell, I can almost guarantee that you will be able to meet your performance requirements (meaning, it probably requires approximately the same amount of intelligence to meet your performance requirements in any of those languages). The Haskell community is notoriously helpful, and my limited experience with the Scala community has been much the same as with Haskell. Personally I am starting to find Java rather icky compared to languages that at least have first-class functions. Also, there are a lot more Java programmers out there, causing a proliferation of information on the internet about Java, for better (more likely what you need to know is out there) or worse (lots of noise to sift through).

tl;dr I'm pretty sure performance is roughly the same. Consider other criteria.

like image 106
Dan Burton Avatar answered Sep 19 '22 05:09

Dan Burton