• Stars
    star
    194
  • Rank 200,219 (Top 4 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

scala-graal

libraryDependencies ++= Seq(
  "com.github.japgolly.scala-graal"  %% "core"           % "2.0.0"
  "com.github.japgolly.scala-graal" %%% "core-js"        % "2.0.0"
  "com.github.japgolly.scala-graal" %%% "ext-boopickle"  % "2.0.0"
  "com.github.japgolly.scala-graal"  %% "ext-prometheus" % "2.0.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

More Repositories

1

scalajs-react

Facebook's React on Scala.JS
Scala
1,644
star
2

svg-android

Fork of svg-android +SVN history +Maven +more
Java
568
star
3

scalacss

Super type-safe CSS for Scala and Scala.JS.
Scala
339
star
4

nyaya

Random Data Generation and/or Property Testing in Scala & Scala.JS.
Scala
185
star
5

test-state

Scala Test-State.
Scala
141
star
6

clear-config

Scala FP configuration library with a focus on runtime clarity
Scala
140
star
7

scalajs-benchmark

Benchmarks: write in Scala or JS, run in your browser. Live demo:
Scala
72
star
8

univeq

Safer universal equivalence (==) for Scala.
Scala
59
star
9

learning

Scala
46
star
10

setup-everything-scala

GitHub Action to prepare the environment for Scala & Scala.JS dev and testing
Scala
40
star
11

mr.boilerplate

Online app to generate Scala boilerplate
Scala
33
star
12

microlibs-scala

Scala
26
star
13

tla2json

Convert TLA+ output (and values) into JSON
Scala
24
star
14

webtamp

Asset bundler. Companion to bundlers like Webpack.
TypeScript
20
star
15

webapp-util

Scala Webapp Utilities
Scala
17
star
16

scala-restructure

Scala
9
star
17

misc

4
star
18

archlinux-packages

Shell
2
star
19

setup-scalajs

GitHub Action to prepare the environment for Scala.JS dev and testing
JavaScript
2
star
20

rubyprof-test

Ruby
1
star
21

setup-scala-util

GitHub Action to add Scala utilities to the PATH
Scala
1
star
22

ruby-corvid

Ruby
1
star
23

astacus

Ruby
1
star
24

autotag2

Years-old app to tag MP3s.
Ruby
1
star
25

android-test-utils

Java
1
star
26

text_to_diagram

Generate software diagrams (ERDs, DFDs, etc) using text files, rather than spending hours combating visual tools.
Ruby
1
star
27

ruby-golly-utils

Ruby
1
star