Skip to content
mattbasta edited this page Dec 21, 2014 · 2 revisions

A project similar to BType is LLJS. LLJS "is a typed dialect of JavaScript that offers a C-like type system with manual memory management." At first glance, LLJS appears to be very similar to BType, but there are a number of major differences.

Features

BType is designed to be used as a high-level language like JavaScript or Go. LLJS is designed to meet parity with C. Most features associated with LLJS are purely designed for parity and performance purposes and do not seek to improve developer productivity.

BType is foremost a language intended to enable efficient development of software with the constraint that all cost must be compilable to a low-level target. This means that it exposes features like:

  • Basic type inference
  • First-class functions
  • Lexical scope

Compile Target

LLJS compiles to JavaScript, not asm.js. BType allows you to compile to both. Unlike LLJS, BType's vanilla JavaScript implementation uses constructs like POJO objects (creating objects using new) to make its output more interoperable with external JavaScript.

A fork of LLJS by James Long compiles LLJS to asm.js, but with a few caveats:

  • Logical binary operators (&& and ||) can only be used as the conditions in an if statement. That is, you cannot perform operations like bool x = foo() && bar().
  • Allocating objects on the heap is not supported (at the time of writing). LLJS's memory management functions are not asm.js-compliant by default.

None of these caveats exist in BType.

BType is also capable of generating code in other compile targets. See the Compile Targets page for more information.

Memory Management

LLJS requires that you manage all memory yourself using functions like malloc() and free(). BType does this for you with basic garbage collection. LLJS also gives the developer access to pointers, which can enable unsafe operations. BType exposes JavaScript-like references, which provide safety and enable simpler garbage collection.

Clone this wiki locally