Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Frege - "Haskell for the JVM"  RSS feed

 
Sean Corfield
Ranch Hand
Posts: 314
14
Clojure Linux Mac OS X Monad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whilst this InfoWorld piece about Frege is light on detail, Frege is a very interesting project that brings a Haskell-like functional programming language to the JVM.

Frege is based on Haskell 2010 with some clearly-documented differences that make for a better fit with the JVM. Frege compiles to Java source code and then compiles that to bytecode. Frege uses Java's native core types and maps Haskell constructs onto classes and interfaces very successfully. Frege's interop with Java is extremely good - Frege has syntax to declare Java types and methods so they can be used easily within Frege's much more sophisticated type system; similarly writing Java code that calls into compiled Frege code is straightforward (a well-structured and well-annotated Frege API will compile down to static methods on classes; more complex Frege compiles down to a handful of interfaces that expose lazy values and functions).
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting - what happened to Jaskell?

I'm curious about the compile-to-Java-source approach e.g. compared to Scala or Clojure. But I think my personal FP-languages cup runneth over right now!
 
Sean Corfield
Ranch Hand
Posts: 314
14
Clojure Linux Mac OS X Monad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chris webster wrote:Interesting - what happened to Jaskell?

It doesn't seem to have been updated since June 2006 (and it doesn't look like a full port - hard to tell from the docs). Also, it's an interpreter, not a compiler. The Haskell wiki lists several attempts to port Haskell to CLR / JVM and they all seem to have stalled, often very early on. Frege is being actively maintained and is a fairly full port.
chris webster wrote:I'm curious about the compile-to-Java-source approach e.g. compared to Scala or Clojure. But I think my personal FP-languages cup runneth over right now!

I was initially very skeptical of the compile-to-Java approach but it's proved very helpful in learning how Frege actually works under the hood and, in particular, was very helpful for figuring out how to drive the Frege compiler from Clojure. It also lets you figure out whether your Frege code is going to be fast or not, based on the generated Java (Frege produces static methods on native Java types wherever it can, in addition to the fully lazy, curried versions). Running the Java compiler as a "phase" of the Frege compilation is seamless and the Frege-to-Java portion is pretty fast so, overall, it's not much slower than compiling Java source code.

I know what you mean about your FP cup - there are a huge number of interesting languages out there, both on the client and the server now, and it can seem a bit overwhelming. I'm trying to keep to one language for work (Clojure on the server, ClojureScript on the client) and then limit my play time exploration to just two languages: Elm on the client and, now, Frege on the server.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!