All Projects → ocsigen → Js_of_ocaml

ocsigen / Js_of_ocaml

Licence: other
Compiler from OCaml to Javascript.

Programming Languages

javascript
184084 projects - #8 most used programming language
ocaml
1615 projects

Labels

Projects that are alternatives of or similar to Js of ocaml

Lacc
A simple, self-hosting C compiler
Stars: ✭ 580 (-9.8%)
Mutual labels:  compiler
Rezoom.sql
Statically typechecks a common SQL dialect and translates it to various RDBMS backends
Stars: ✭ 621 (-3.42%)
Mutual labels:  compiler
Janino
Janino is a super-small, super-fast Java™ compiler.
Stars: ✭ 627 (-2.49%)
Mutual labels:  compiler
Packem
📦⚡ A precompiled JavaScript module bundler
Stars: ✭ 586 (-8.86%)
Mutual labels:  compiler
Felix
The Felix Programming Language
Stars: ✭ 609 (-5.29%)
Mutual labels:  compiler
Clio
Clio is a functional, parallel, distributed programming language.
Stars: ✭ 555 (-13.69%)
Mutual labels:  compiler
C2compiler
the c2 programming language
Stars: ✭ 576 (-10.42%)
Mutual labels:  compiler
Cyclone
🌀 A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
Stars: ✭ 634 (-1.4%)
Mutual labels:  compiler
Oakc
A portable programming language with a compact intermediate representation
Stars: ✭ 617 (-4.04%)
Mutual labels:  compiler
Minic Hosting
A simple stack-based virtual machine that runs C in the browser.
Stars: ✭ 628 (-2.33%)
Mutual labels:  compiler
Mypyc
Compile type annotated Python to fast C extensions
Stars: ✭ 575 (-10.58%)
Mutual labels:  compiler
Rescript Compiler
The compiler for ReScript.
Stars: ✭ 5,640 (+777.14%)
Mutual labels:  compiler
Lyo
📦 Node.js to browser - The easy way
Stars: ✭ 624 (-2.95%)
Mutual labels:  compiler
Ccl
Clozure Common Lisp
Stars: ✭ 584 (-9.18%)
Mutual labels:  compiler
Lebab
Turn your ES5 code into readable ES6. Lebab does the opposite of what Babel does.
Stars: ✭ 5,479 (+752.1%)
Mutual labels:  compiler
Pl Compiler Resource
程序语言与编译技术相关资料(持续更新中)
Stars: ✭ 578 (-10.11%)
Mutual labels:  compiler
Rhine Ml
🏞 an OCaml compiler for an untyped lisp
Stars: ✭ 621 (-3.42%)
Mutual labels:  compiler
Llvmswift
A Swift wrapper for the LLVM C API (version 9.0.1)
Stars: ✭ 641 (-0.31%)
Mutual labels:  compiler
Fastexpressioncompiler
Fast ExpressionTree compiler to delegate
Stars: ✭ 631 (-1.87%)
Mutual labels:  compiler
Sultan
Sultan: Command and Rule over your Shell
Stars: ✭ 625 (-2.8%)
Mutual labels:  compiler

Build Status

Js_of_ocaml (jsoo)

Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js.

  • It is easy to install and use as it works with an existing installation of OCaml, with no need to recompile any library.
  • It comes with bindings for a large part of the browser APIs.
  • According to our benchmarks, the generated programs runs typically faster than with the OCaml bytecode interpreter.
  • We believe this compiler will prove much easier to maintain than a retargeted OCaml compiler, as the bytecode provides a very stable API.

Requirements

See opam file for version constraints.

optional

Toplevel requirements

  • tyxml, reactiveData
  • ocp-indent: needed to support indentation in the toplevel
  • higlo: needed to support Syntax highlighting in the toplevel
  • cohttp: needed to build the toplevel webserver

Installation

Opam

opam install js_of_ocaml js_of_ocaml-compiler js_of_ocaml-ppx

Usage

Your program must first be compiled using the OCaml bytecode compiler ocamlc. JavaScript bindings are provided by the js_of_ocaml package. The syntax extension is provided by js_of_ocaml.syntax package.

ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml-ppx -linkpkg -o cubes.byte cubes.ml

Then, run the js_of_ocaml compiler to produce JavaScript code:

js_of_ocaml cubes.byte

Features

Most of the OCaml standard library is supported. However,

  • Weak semantic cannot be implemented using JavaScript. A dummy implementation is provided.
  • Most of the Sys module is not supported.

Extra libraries distributed with OCaml (such as Thread) are not supported in general. However,

  • Bigarray: bigarrays are supported using Typed Arrays
  • Num: supported
  • Str: supported
  • Graphics: partially supported using canvas (see js_of_ocaml-lwt.graphics)
  • Unix: time related functions are supported

Tail call is not optimized in general. However, mutually recursive functions are optimized:

  • self recursive functions (when the tail calls are the function itself) are compiled using a loop.
  • trampolines are used otherwise. More about tail call optimization.

Data representation differs from the usual one. Most notably, integers are 32 bits (rather than 31 bits or 63 bits), which is their natural size in JavaScript, and floats are not boxed. As a consequence, marshalling, polymorphic comparison, and hashing functions can yield results different from usual:

  • marshalling of floats is not supported (unmarshalling works);
  • the polymorphic hash function will not give the same results on datastructures containing floats;
  • these functions may be more prone to stack overflow.

Toplevel

Contents of the distribution

Filename Description
LICENSE license and copyright notice
README this file
compiler/ compiler
examples/ small examples
lib/ library for interfacing with JavaScript APIs
ppx/ ppx syntax extensions
runtime/ runtime system
toplevel/ web-based OCaml toplevel
ocamlbuild/ ocamlbuild plugin for js_of_ocaml
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].