Git Product home page Git Product logo

soabase-halva's Introduction

Halva

Welcome to Halva - Idiomatic Scala... in Java!

Build Status Maven Central

Halva's goal is to bring as many features from Scala to Java as is possible without byte code generation or magic. Using the features in Java should be as close as possibile to how the features are used in Scala.

I wanted to see how close to Scala I could get in Java. Not only close in functionality, but close in syntax as well. No magic, no byte code generation, nothing (too) tricky or magical. Just pure, standard Java 8. Halva is the result. The only reflection is for Google Guice's TypeLiteral class. The only "special" stuff is an annotation processor to generate case classes, type aliases and implicits. There are no dependencies whatsoever (Google Guice's TypeLiteral and JavaPoet are shaded into the code).

There are many 3rd party libraries that add support to Java in some form or another for some of Scala's features. However, most of these libraries are large and use their own DSLs or syntax. I want, where possible, to take unmodified Scala (adding semicolons!!) and get it to work in Java. Of course, this isn't literally possible. But, I began to wonder how close I could actually get. Some features are pretty trivial: some simple "sugaring" that wouldn't be hard to add. Other features, like Tuples, could be supported just as well in Java as in Scala. There are, however, a few features that are complicated or seemingly impossible in Java: Case Classes, Pattern Matching/Extractors/Partials, Comprehensions, and Implicits. There's no way to get total compatibility with Scala. But, could I get 50%? 70%? 80%? I searched the net for what people think are the killer features of Scala and attempted to implement them in pure Java. Project Halva is the result.

Full Featured Example

To see the results of what Halva can do, please look at the Simple Interpreter Example.

Features

Example Generated Files

Many example generated files are shown here.

Using Halva

Halva is available from Maven Central. Use your favorite build tool and specify:

GroupId ArtifactId Description
io.soabase.halva halva-processor Contains the javac processor for @CaseClass, @CaseObject, @TypeAlias, @ImplicitClass, and @TypeContainer
io.soabase.halva halva All the runtime code for Halva: matchers, comprehensions, etc.

FAQs

See miscellaneous info and Frequently Asked Questions

Special Thanks

Special thanks to @Alex-At-Home for his help and great ideas.

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.