All Projects → cincheo → Jsweet

cincheo / Jsweet

Licence: other
A Java to JavaScript transpiler.

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
typescript
32286 projects
language
365 projects

Projects that are alternatives of or similar to Jsweet

Elixirscript
Converts Elixir to JavaScript
Stars: ✭ 1,504 (+28.88%)
Mutual labels:  compiler, transpiler
Retyped
Access 3600+ libraries from C# and let Bridge.NET compile your project into JavaScript.
Stars: ✭ 216 (-81.49%)
Mutual labels:  compiler, transpiler
Crossshader
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
Stars: ✭ 113 (-90.32%)
Mutual labels:  compiler, transpiler
Fetlang
Fetish-themed programming language
Stars: ✭ 1,337 (+14.57%)
Mutual labels:  compiler, transpiler
Haxe
Haxe - The Cross-Platform Toolkit
Stars: ✭ 4,665 (+299.74%)
Mutual labels:  compiler, transpiler
Godzilla
Godzilla is a ES2015 to Go source code transpiler and runtime
Stars: ✭ 1,464 (+25.45%)
Mutual labels:  compiler, transpiler
Elchemy
Write Elixir code using statically-typed Elm-like syntax (compatible with Elm tooling)
Stars: ✭ 1,080 (-7.46%)
Mutual labels:  compiler, transpiler
Evm2wasm
[ORPHANED] Transcompiles EVM code to eWASM
Stars: ✭ 96 (-91.77%)
Mutual labels:  compiler, transpiler
Bytecoder
Rich Domain Model for JVM Bytecode and Framework to interpret and transpile it.
Stars: ✭ 401 (-65.64%)
Mutual labels:  compiler, transpiler
Wax
A tiny programming language that transpiles to C, C++, Java, TypeScript, Python, C#, Swift, Lua and WebAssembly 🚀
Stars: ✭ 373 (-68.04%)
Mutual labels:  compiler, transpiler
Transcrypt
Python 3.7 to JavaScript compiler - Lean, fast, open! -
Stars: ✭ 2,502 (+114.4%)
Mutual labels:  compiler, transpiler
J2cl
Java to Closure JavaScript transpiler
Stars: ✭ 773 (-33.76%)
Mutual labels:  compiler, transpiler
Ratel Core
High performance JavaScript to JavaScript compiler with a Rust core
Stars: ✭ 367 (-68.55%)
Mutual labels:  compiler, transpiler
Nimporter
Compile Nim Extensions for Python On Import!
Stars: ✭ 474 (-59.38%)
Mutual labels:  compiler, transpiler
Typescripttolua
Typescript to lua transpiler. https://typescripttolua.github.io/
Stars: ✭ 783 (-32.9%)
Mutual labels:  compiler, transpiler
Tiny Lisp
A tiny lisp compiler written in JS
Stars: ✭ 58 (-95.03%)
Mutual labels:  compiler
Charly Vm
Fibers, Closures, C-Module System | NaN-boxing, bytecode-VM written in C++
Stars: ✭ 66 (-94.34%)
Mutual labels:  compiler
Tachyon
Experimental Programming Language Coded in Python!
Stars: ✭ 58 (-95.03%)
Mutual labels:  compiler
Idris Elixir
A code-generator for Idris that targets Elixir
Stars: ✭ 56 (-95.2%)
Mutual labels:  compiler
Orange
The Orange programming language
Stars: ✭ 67 (-94.26%)
Mutual labels:  compiler

JSweet: a Java to JavaScript transpiler

Continuous integration build Download

JSweet leverages TypeScript to write rich and responsive Web applications in Java through the use of JavaScript libraries and frameworks. With JSweet, Java programs are transpiled (source-to-source compiled) to TypeScript and JavaScript for being run in browsers, mobile Web views, or in Node.js.

  • JSweet is safe and reliable. It provides web applications with type-checking and generates fully type-checked JavaScript programs. It stands on Oracle's Java Compiler (javac) and on Microsoft's TypeScript (tsc).
  • JSweet allows you to use your favorite JS library (JSweet+Angular2, JSweet+threejs, IONIC/Cordova, ...).
  • JSweet enables code sharing between server-side Java and client-side JavaScript. JSweet provides implementations for the core Java libraries for code sharing and legacy Java migration purpose.
  • JSweet is fast, lightweight and fully JavaScript-interoperable. The generated code is regular JavaScript code, which implies no overhead compared to JavaScript, and can directly interoperate with existing JavaScript programs and libraries.

How does it work? JSweet depends on well-typed descriptions of JavaScript APIs, so-called "candies", most of them being automatically generated from TypeScript definition files. These API descriptions in Java can be seen as headers (similarly to *.h header files in C) to bridge JavaSript libraries from Java. There are several sources of candies for existing libraries and you can easily build a candy for any library out there (see more details).

With JSweet, you take advantage of all the Java tooling (IDE's, Maven, ...) to program real JavaScript applications using the latest JavaScript libraries.

Java -> TypeScript -> JavaScript

Here is a first taste of what you get by using JSweet. Consider this simple Java program:

package org.jsweet;

import static jsweet.dom.Globals.*;

/**
 * This is a very simple example that just shows an alert.
 */
public class HelloWorld {
	public static void main(String[] args) {
		alert("Hi there!");
	}
}

Transpiling with JSweet gives the following TypeScript program:

namespace org.jsweet {
    /**
     * This is a very simple example that just shows an alert.
     */
    export class HelloWorld {
        public static main(args : string[]) {
            alert("Hi there!");
        }
    }
}
org.jsweet.HelloWorld.main(null);

Which in turn produces the following JavaScript output:

var org;
(function (org) {
    var jsweet;
    (function (jsweet) {
        /**
         * This is a very simple example that just shows an alert.
         */
        var HelloWorld = (function () {
            function HelloWorld() {
            }
            HelloWorld.main = function (args) {
                alert("Hi there!");
            };
            return HelloWorld;
        }());
        jsweet.HelloWorld = HelloWorld;
    })(jsweet = org.jsweet || (org.jsweet = {}));
})(org || (org = {}));
org.jsweet.HelloWorld.main(null);

More with the live sandbox.

Features

  • Full syntax mapping between Java and TypeScript, including classes, interfaces, functional types, union types, tuple types, object types, string types, and so on.
  • Extensive support of Java constructs and semantics added since version 1.1.0 (inner classes, anonymous classes, final fields, method overloading, instanceof operator, static initializers, ...).
  • Over 1000 JavaScript libraries, frameworks and plugins to write Web and Mobile HTML5 applications (JQuery, Underscore, Angular, Backbone, Cordova, Node.js, and much more).
  • A Maven repository containing all the available libraries in Maven artifacts (a.k.a. candies).
  • Support for Java basic APIs as the J4TS candy (forked from the GWT's JRE emulation).
  • An Eclipse plugin for easy installation and use.
  • A Maven plugin to use JSweet from any other IDE or from the command line.
  • A Gradle plugin to integrate JSweet with Gradle-based projects.
  • A debug mode to enable Java code debugging within your favorite browser.
  • A set of nice WEB/Mobile HTML5 examples to get started and get used to JSweet and the most common JavaScript APIs (even more examples in the Examples section).
  • Support for bundles to run the generated programs in the most simple way.
  • Support for JavaScript modules (commonjs, amd, umd). JSweet programs can run in a browser or in Node.js.
  • Support for various EcmaScript target versions (ES3 to ES6).
  • Support for async/await idiom
  • ...

For more details, go to the language specifications (PDF).

Getting started

  • Step 1: Install (or check that you have installed) Git, Node.js and Maven (commands git, node, npm and mvn should be in your path).
  • Step 2: Clone the jsweet-quickstart project from Github:
$ git clone https://github.com/cincheo/jsweet-quickstart.git
  • Step 3: Run the transpiler to generate the JavaScript code:
$ cd jsweet-quickstart
$ mvn generate-sources
  • Step 4: Check out the result in your browser:
$ firefox webapp/index.html
  • Step 5: Edit the project and start programming:
    • Checkout the examples to see various use cases
    • Get access to hundreds of libs (candies)
    • Refer to the language specifications to know more about programming with JSweet
    • Eclipse users: install the Eclipse plugin to get inline error reporting, build-on-save, and easy configuration UI

More info at http://www.jsweet.org.

Examples

Sub-projects

This repository is organized in sub-projects. Each sub-project has its own build process.

  • JSweet transpiler: the Java to TypeScript/JavaScript compiler.
  • JSweet core candy: the core APIs (JavaScript language, JavaScript DOM, and JSweet language utilities).
  • JDK runtime: a fork from GWT's JRE emulation to implement main JDK APIs in JSweet/TypeScript/JavaScript.
  • JSweet candy generator: a tool to generate Java APIs from TypeScript definition files, and package them as JSweet candies.
  • JSweet documentation: JSweet documentation.

Additionally, some tools for JSweet are available in external repositories.

How to build

Please check each sub-project README file.

Contributing

JSweet uses Git Flow. You can fork this repository. Default branch is develop. Please use git flow feature start myAwesomeFeature to start working on something great :) When you are done, you can submit a regular GitHub Pull Request.

License

Please read the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].