Need help with scala-graal?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

japgolly
172 Stars 2 Forks Apache License 2.0 332 Commits 10 Opened issues

Description

Make usage of Graal features easy and safe from Scala. Also features Scala-based React SSR.

Services available

!
?

Need anything else?

Contributors list

# 30,130
fp
scalajs
type-sa...
React
257 commits
# 5,053
scalajs
playfra...
akka-ht...
fp
32 commits

scala-graal

libraryDependencies ++= Seq(
  "com.github.japgolly.scala-graal"  %% "core"           % "1.2.0"
  "com.github.japgolly.scala-graal" %%% "core-js"        % "1.2.0"
  "com.github.japgolly.scala-graal" %%% "ext-boopickle"  % "1.2.0"
  "com.github.japgolly.scala-graal"  %% "ext-prometheus" % "1.2.0"
)

Goals

  • Make it quick, easy and safe to interface with embedded languages from Scala
  • Hide and automate a lot of required GraalVM boilerplate
  • Support React SSR for Scala.JS applications

Demo

import japgolly.scalagraal._

// Use semantics and implicit config for JS // (GraalVM also supports Python, R, Ruby, LLVM) import japgolly.scalagraal.js._ import GraalJs._

// 1. Pre-compile expression functions for fast invocation. // 2. Typeclasses translate and/or marshall data between JVM and JS. val expr: (Int, Int) => Expr[String] = Expr.apply2((a, b) => s"($a + $b) * 2 + '!'").compile(_.asString)

// Use a basic synchronous JS environment val ctx = GraalContext()

val result = ctx.eval(expr(3, 8)) assert(result == Right("22!"))

Learning

Features

  • Expressions
    • composition
    • purity
    • result parsing
    • error handling
    • null handling
    • binding typeclasses
    • binding codecs (eg binary/json/whatever)
  • Service
    • single-threaded
    • multi-threaded pool
    • synchronous
    • asynchronous
    • optional time limits
    • before/around/after hooks
    • automatic metrics
  • Warmup
    • ability to warmup VM
    • rules (eg.
      up to 10000 reps/thread & up to 30 sec | until completes within 20ms
      )
  • React SSR (Server-Side Rendering)
    • support for rendering JS components from JVM
    • conversion to constant-time (conditionally)
    • window
      and especially
      window.location
      management
  • Integrations
    • Prometheus - export metrics to Prometheus
    • BooPickle - marshall data back and forth using binary codecs

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.