Giter Site home page Giter Site logo

sekaiser / loom-generators Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 78 KB

Comparison of different approaches for implementing geneartors in Java using Project Loom.

Home Page: https://www.linkedin.com/pulse/having-fun-loom-generators-sebastian-kaiser

Kotlin 6.46% Java 93.54%
generators java jdk21 loom

loom-generators's Introduction

Implementation of Generators with JDK21

This repositories contains code discussed in an article I wrote. The article can be found here.

What's in it

The package loom.generators.mvysny contains the generator as implemented in mvysny/vaadin-loom. The developer also wrote a nice article explaining how it works.

The package loom.generators.robaho contains the generator as implemented in robaho/generators. He also provides a synchronous version.

The package loom.generators.sk4is3r contains a generator implemented by myself. This generator is based on jdk.internal.vm.Continuation. Later, I figured out that someone else already had this idea and provided a decent implementation of continuations based generators in JDK21. Therefore, I highly recommend that you check out his pedrolamarao/generators-jvm.

Although not explicitly mentioned in my article, the package loom.generators.kelemen contains another custom implementation of a queue based generator. The article does not cover it, because another queue based generator is already discussed and the implementation depends on a couple of custom 3rd party dependencies. Discussing them is out of scope of the article.

Setup

You will need JDK21 to run this project. I recommend using sdkman, e.g. sdk install java 21.ea.31-open

This project uses gradle 8.2.1. You can install gradle via homebrew, e.g. brew install gradle

Build

Just run gradle build.

Note: The loom.generators module requires JDK version 21 with preview features enabled.

Results of performance test

The code is located in loom.generators.perf.

Implementation avg time
No generator 3.1 ms
loom.generators.robaho 1258.3 ms
loom.generators.mvysny 432.5 ms
loom.generators.sk4is3r 156.7 ms
loom.generators.kelemen 3400.6 ms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.