Popularity
3.3
Growing
Activity
9.7
Declining
226
9
23

Description

Elide is a fast batteries-included runtime, combining support for Kotlin, JavaScript, TypeScript, and Python.

elide: verb. to omit (a sound or syllable) when speaking. to join together; to merge.

Programming language: Kotlin
License: MIT License
Tags: Development     Web Frameworks     Java     Projects    

elide alternatives and similar libraries

Based on the "Web Frameworks" category.
Alternatively, view elide alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of elide or a related project?

Add another 'Web Frameworks' Library

README

elide: verb. to omit (a sound or syllable) when speaking. to join together; to merge.

Build codecov Reliability Rating Security Rating Maintainability Rating FOSSA Status

Kotlin Java 17 ECMA GraalVM

Elide is currently in alpha.

Latest version: 1.0-v3-alpha1-rc38

Elide is a Kotlin/Multiplatform meta-framework for rapid, cross-platform application development. Write once in Kotlin and deploy everywhere: your server, the browser, and native app targets.

Distinguishing features

  • Pure Kotlin. Write your core application logic and models once, and share them across platforms transparently. Leverage Kotest for cross-platform, write-once-run-native testing. Enjoy first-class support for the full suite of KotlinX libraries, including serialization, atomicfu, coroutines and datetime.

  • Isomorphic SSR with React. Write your UI in React, using JavaScript, TypeScript, or Kotlin. Package it for serving via client-side rendering or hybrid isomorphic rendering directly from your Kotlin server.

  • Model-driven development. Write your models once, and use them everywhere, across platforms, without copying, without glue-code, and without DTOs. Via Protobuf and Kotlin data classes, the same Elide model is code-generated for use with your database, API, and UI.

  • Extreme performance. Enjoy fast development locally with Kotlin and Gradle, and insanely fast runtime performance thanks to GraalVM Native, Netty, and Micronaut. Deploy to bare metal, Docker scratch images, or JARs.

Code samples

A full suite of [code samples](./samples) demo various functionality. The samples are runnable locally or via pre-built Docker images. Click through to each one for a short tour and getting started guide.

"Blah blah blah, okay, show me some code." Certainly:

App.kt (for the server)

/** GET `/`: Controller for index page. */
@Controller class Index {
  // Serve an HTML page with isomorphic React SSR.
  @Get("/") fun index() = ssr {
    head {
      title { +"Hello, Elide!" }
      stylesheet("/styles/main.css")
      script("/scripts/ui.js", defer = true)
    }
    body {
      injectSSR()
    }
  }

  // Serve styles for the page.
  @Get("/styles/main.css") fun styles() = css {
    rule("body") {
      backgroundColor = Color("#bada55")
    }
    rule("strong") {
      fontFamily = "-apple-system, BlinkMacSystemFont, sans-serif"
    }
  }

  // Serve the built & embedded JavaScript.
  @Get("/scripts/ui.js") suspend fun js(request: HttpRequest<*>) = script(request) {
    module("scripts.ui")
  }
}

main.kt (for the browser)

// React props for a component
external interface HelloProps: Props {
  var name: String
}

// React component which says hello
val HelloApp = FC<HelloProps> { props ->
  div {
    strong {
      +props.name
    }
  }
}

// Entrypoint for the browser
fun main() {
  hydrateRoot(
    document.getElementById("root"),
    Fragment.create() {
      HelloApp {
        name = "Elide"
      }
    }
  )
}

That's it. That's the entire app. In fact, it's just the [fullstack/react-ssr](./samples/fullstack/react-ssr) sample pasted into the README. What we get out of this is surprising:

  • Server: JVM or Native server (via GraalVM) that serves our root page, our CSS, and our JS
  • Client: Embedded JS VM that executes a Node copy of our React UI and splices it into the page for isomorphic rendering
  • For us (the developer):
    • Completely type-checked calls across platforms, with almost no boilerplate
    • Single build graph, with aggressive caching and tool support
    • Build & test virtualized on any platform
    • Ship & perform natively on any platform

What's going on here? Elide has helped us wire together code from Micronaut (that's where @Controller comes from), Kotlin/JS, GraalVM, and esbuild to make the above code make sense on both platforms. The React code builds for the browser and a pure server environment; both are embedded into the JAR and served through a thin runtime layer provided by the framework.

Why is this useful?

If you're participating in the React and Java ecosystems, this gives you a fantastic best-of-both-worlds runtime option: superb tooling support for React and Kotlin and an ideal serving and rendering mode, all handled for you.

You can do the same thing with these same tools in a custom codebase, but setting up the build environment for this kind of app is challenging and error-prone. Elide intentionally leverages existing frameworks with rich ecosystems and docs, instead of re-providing existing functionality so that you always have an escape hatch up to a more industrial toolset if you need it.

Trying it out

Note Elide is early. This guide will soon be usable without cloning the source.

There are currently two ways to try out Elide. You can build a sample from source, or run the pre-built Docker images. Native images are not yet available via Docker, but you can build and test them locally.

The react-ssr sample is recommended, because it demoes the broadest set of functionality currently available. Source code for each sample is in the [samples/](./samples) directory. If you're going to build from source, make sure to see the Requirements to build section.

Run the helloworld sample via Docker (JVM):

docker run --rm -it -p 8080:8080 ghcr.io/elide-dev/samples-server-helloworld-jvm

Run the react-ssr sample via Docker (JVM):

docker run --rm -it -p 8080:8080 ghcr.io/elide-dev/samples-fullstack-react-ssr-jvm:latest

Run the react-ssr sample via Gradle (JVM):

git clone [email protected]:elide-dev/v3.git && cd v3
./gradlew :samples:fullstack:react-ssr:server:run

Run the react-ssr sample via Gradle (Native):

git clone [email protected]:elide-dev/v3.git && cd v3
./gradlew :samples:fullstack:react-ssr:server:runNative
Requirements to build

To build the JVM or JS samples in Kotlin, you will need JDK 11 or later. Zulu is a good option if you don't have a preferred JVM.

To build native code, you'll need a recent version of GraalVM. Make sure to install the native-image tool after initially downloading, which you can do with:

gu install native-image espresso
gu rebuild-images

Finally, you'll need a recent Node.js runtime if you want to build JS or frontend code. That's it!

To summarize:

  • For building via Gradle: JDK11+, any reasonable JVM should work.
  • For building native: GraalVM (consult compat table for version advice).
  • For building browser/embedded JS: Recent Node.js toolchain. 16.x+ is recommended.

Powered-by

Elide is modular. You can mix and match the following technologies in server, client, or hybrid/fullstack development scenarios:

  • Kotlin. Elide is written from the inside out with support for Kotlin/Multiplatform, including native platforms. Write once and use the same consistent code across server-side and client-side(s) platforms.

  • GraalVM. GraalVM is a JVM and toolchain from Oracle which includes modernized JIT support, cross-language polyglot development in JS, Ruby, Python, and LLVM, and the ability to build native binaries from JVM apps.

  • Micronaut. Micronaut is a new JVM-based framework for building server-side applications. Elide leverages Micronaut's dependency injection and AOP features, and transparently works with most add-ons.

  • React. React is a popular UI library written for browser and server environments. Elide leverages Kotlin/JS support for React for isomorphic UI rendering. CSR and SSR modes are supported natively.

  • Protobuf / gRPC. Elide leverages cross-platform serialization through KotlinX's protobuf module, and includes native support for gRPC Web without running a proxy.

  • Gradle. Early support for building multi-platform Kotlin applications via Gradle, including integrated support for Webpack-based frontend builds and esbuild-based embedded SSR builds.

  • esbuild. Elide leverages ESBuild when compiling and minifying JS code for the server or browser. ESBuild sports extremely fast build times, modern language support, and tunable minification/DCE.

Version compatibility

The following version matrix indicates tested support across tool and platform versions, including Java, Kotlin, GraalVM, Micronaut, and React.

Following this guide is recommended but optional. Depending on the style of development you're doing with Elide, you may not need some of these components:

Status Java Kotlin GraalVM Micronaut React Protobuf/gRPC
Status Java 19 1.7.21 22.3.x 3.7.x 18.x 3.20.1/1.46.0
Status Java 17 1.7.21 22.3.x 3.7.x 18.x 3.20.1/1.46.0
Status Java 11 1.7.21 22.3.x 3.5.x 18.x 3.20.1/1.46.0
Status Java 8 -- -- -- -- --

If you aren't using certain components on this list, for example, gRPC/Protobuf, you can ignore that column entirely.

Reports

Licensing

Elide itself is licensed [under MIT](LICENSE) as of November 2022. Dependencies are scanned for license compatibility; the report is available via FOSSA:

FOSSA Status

Coverage

Code coverage is continuously reported to Codecov and SonarCloud:

Coverage grid


*Note that all licence references and agreements mentioned in the elide README section above are relevant to that project's source code only.