Eta

A simple & powerful language for building scalable systems on the JVM


Output:
Run

What is Eta?

Eta is a pure, lazy, strongly typed functional programming language on the JVM. It brings two big ecosystems i.e., Java and Haskell together. This means that you can reuse Java and Haskell libraries in Eta projects. Eta's concurrency support helps you to build highly scalable, distributed, and parallel systems on the JVM.

Why Eta?

Robust Interoperability

Eta runs on the Java Virtual Machine and it is designed to be compatable with Java.

-- Type-safe import of a Java method that is null-safe.
foreign import java unsafe "@static java.lang.System.getenv"
  getEnv :: String -> IO (Maybe String)

{- Checks the environment for the HOME environment
variable and prints it out if it exists. -}
main :: IO ()
main = do
  home <- getEnv "HOME"
  case home of
    Just homePath ->
      putStrLn $ "Your home directory is " ++ homePath ++ "!"
    Nothing ->
      putStrLn "Your HOME environment variable is not set"

Ultra Type Safety

Eta uses type inference so that it can understand your intent even if you don't explicity specify the types of your expressions.

-- Declare a datatype for measurements in Feet and Meters.
newtype Feet = Feet Double
newtype Meters = Meters Double

-- Conversions between measurements.
feet2Meters :: Feet -> Meters
feet2Meters (Feet ft) = Meters $ ft * 0.3048

meters2Feet :: Feet -> Meters
meters2Feet (Meters m) = Feet $ m / 0.3048

volumeOfShippingBox :: Meters -> Meters
volumeOfShippingBox (Meters sideLength) =
Meters $ sideLength * sideLength * sideLength

Scalable Concurrency Support

Eta's immutability makes concurrency a pleasure to work with. Eta offers a wide range of strategies for handling concurrency including Software Transactional Memory, MVar, and Fibers for reusable concurrent programming without locks.

-- Purity allows safe usage of methods like Software Transactional
-- Memory, used to make concurrency safe, easy, and enjoyable.
import Control.Concurrent.STM

type Account = TVar USD
type USD = Double

transferMoney :: USD -> Account -> Account -> IO ()
transferMoney amount sender receiver =
atomically $ transact amount sender receiver

transact :: USD -> Account -> Account -> STM ()
transact amount sender receiver = do
  senderBalance <- readTVar sender
  receiverBalance <- readTVar receiver
  writeTVar sender (senderBalance - amount)
  writeTVar receiver (receiverBalance + amount)

Coming Soon to Eta

  • Etlas

    Etlas is a package manager and repository for Eta

  • Eta Fibers

    Eta fibers are lightweight, cooperative threads on the JVM


Integrate with Scala

You can integrate Eta into your Scala projects via the sbt-eta plugin. Check the blog post for more details.

Twitter Feed


Community

Popular ways to connect with the Eta community include mailing lists, chat rooms, and social networks. Please subscribe to the mailing list to receive regular updates about Eta.