All Projects → vishesh → Racketscript

vishesh / Racketscript

Licence: mit
Racket to JavaScript Compiler

Programming Languages

javascript
184084 projects - #8 most used programming language
racket
414 projects

Labels

Projects that are alternatives of or similar to Racketscript

Libfirm
graph based intermediate representation and backend for optimising compilers
Stars: ✭ 305 (-10.29%)
Mutual labels:  compiler
Craftinginterpreters
Repository for the book "Crafting Interpreters"
Stars: ✭ 4,298 (+1164.12%)
Mutual labels:  compiler
Soll
SOLL is a new compiler for generate Ewasm from solidity and yul. See a demo here: https://asciinema.org/a/ezJqNLicn5fya02zwu4VXIo8a
Stars: ✭ 329 (-3.24%)
Mutual labels:  compiler
Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (-9.41%)
Mutual labels:  compiler
Kgt
BNF wrangling and railroad diagrams
Stars: ✭ 312 (-8.24%)
Mutual labels:  compiler
Webml
A Standard ML Compiler for the Web
Stars: ✭ 326 (-4.12%)
Mutual labels:  compiler
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (-10.29%)
Mutual labels:  compiler
Staticscript
🎉🎉🎉 A new statically typed programming language, syntactically like TypeScript.
Stars: ✭ 337 (-0.88%)
Mutual labels:  compiler
Roblox Ts
A TypeScript-to-Luau Compiler for Roblox
Stars: ✭ 317 (-6.76%)
Mutual labels:  compiler
Pkg
Package your Node.js project into an executable
Stars: ✭ 19,349 (+5590.88%)
Mutual labels:  compiler
Ark
ArkScript is a small, fast, functional and scripting language for C++ projects
Stars: ✭ 312 (-8.24%)
Mutual labels:  compiler
Cl Python
An implementation of Python in Common Lisp
Stars: ✭ 315 (-7.35%)
Mutual labels:  compiler
Phenomic
DEPRECATED. Please use Next.js instead.
Stars: ✭ 3,264 (+860%)
Mutual labels:  compiler
Reduceron
FPGA Haskell machine with game changing performance. Reduceron is Matthew Naylor, Colin Runciman and Jason Reich's high performance FPGA softcore for running lazy functional programs, including hardware garbage collection. Reduceron has been implemented on various FPGAs with clock frequency ranging from 60 to 150 MHz depending on the FPGA. A high degree of parallelism allows Reduceron to implement graph evaluation very efficiently. This fork aims to continue development on this, with a view to practical applications. Comments, questions, etc are welcome.
Stars: ✭ 308 (-9.41%)
Mutual labels:  compiler
Quilc
The @rigetti optimizing Quil compiler.
Stars: ✭ 336 (-1.18%)
Mutual labels:  compiler
Urn
Yet another Lisp variant which compiles to Lua
Stars: ✭ 305 (-10.29%)
Mutual labels:  compiler
Shaderdebugger
[DEPRECATED] C++ library for debugging HLSL & GLSL shaders
Stars: ✭ 323 (-5%)
Mutual labels:  compiler
Passerine
A small extensible programming language designed for concise expression with little code.
Stars: ✭ 341 (+0.29%)
Mutual labels:  compiler
Numpile
A tiny 1000 line LLVM-based numeric specializer for scientific Python code.
Stars: ✭ 341 (+0.29%)
Mutual labels:  compiler
V8
The official mirror of the V8 Git repository
Stars: ✭ 18,808 (+5431.76%)
Mutual labels:  compiler

RacketScript

MIT licensed Build Status Coverage Status Try Online

RacketScript is an experimental lightweight Racket to JavaScript compiler. The generated code is ES6, which can be translated to ES5 using Babel. RacketScript aims to leverage both JavaScript and Racket's ecosystem, and make interoperability between them clean and smooth.

RacketScript takes in Racket source files, uses Racket's macro expander to produce Fully Expanded Programs, and then compile these fully expanded programs to JavaScript. RacketScript doesn't support Racket features which are expensive, for example proper tail calls and continuations.

Try RacketScript

You can try RacketScript in your browser at RacketScript Playground.

Disclaimer

RacketScript is work-in-progress and is not mature and stable. Several Racket features and libraries are not yet implemeted (eg. number pyramid, contracts, tail calls, primitives). That said, we encourage experimentation, user feedback, discussions, bug reports and pull requests.

Installation

Following system packages are required -

Quick Install

RacketScript can be installed by running one of the following commands in your terminal.

For installation via raco

raco pkg install racketscript

For installation via curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/vishesh/racketscript/master/install.sh)"

Or, for installation via wget

sh -c "$(wget https://raw.githubusercontent.com/vishesh/racketscript/master/install.sh -O -)"

See Basic Usage to get started.

Install from Github

Once RacketScript is cloned in your machine -

  1. Fire up your terminal and goto the root directory of the repository.
  2. Execute make setup to install RacketScript compiler and all its dependencies.

If you do not wish to pollute your root NPM directory, you can set a custom global location by changing your npmrc (eg. echo "prefix = $HOME/.npm-packages" >> ~/.npmrc. Then add /prefix/path/above/bin to your PATH.

Basic Usage

RacketScript compiler is named racks.

racks -h # show help

To compile a Racket source file:

# Installs all NPM dependencies and compile file.rkt
racks /path/to/file.rkt

The above command will create a output build directory named js-build, copy RacketScript runtime, copy other support files, install NPM dependencies, compile file.rkt and its dependencies.

The compiled ES6 modules typically goto one of following three folders:

  • "modules": The normal Racket files.
  • "collects": Racket collects source files.
  • "links": Other third party packages.
  • "dist": Contains sources compiled to ES6 or bundled JavaScript ready for distribution.

Here are few other examples that would come in handy:

# To skip `npm install` step. Useful when building
# for second time.
racks -n /path/to/source.rkt
	
# To beautify assembled modules use `-b`. Make sure
# `js-beautify` is installed from NPM or your
# package manager.
racks -b /path/to/source.rkt

# Override default output directory
racks -d /path/to/output/dir /path/to/source.rkt
	
# Print JavaScript output to stdout
racks --js --js-beautify /path/to/source.rkt

node js-build/modules/source.rkt.js

By default tail call optimization is turned off. To enable translation of self recursive tail calls to loop, pass --enable-self-tail flag.

racks --enable-self-tail /path/to/source.rkt

Babel

RacketScript could also use Babel. It will compile each assembled ES6 module to ES5, and put it in dist directory, persevering original directory structure. Replace above command with following -

# Use `--target` or `-t` flag.
racks --target babel /path/to/source.rkt

This will compile each ES6 module generated by RacketScript, and put in js-build/dist with same directory structure. The JavaScript script file produced by Babel in dist can be executed directly using Node. Babel is highly recommended if your target is NodeJS.

Contributing to RacketScript

Please read Contribution Guidelines.

Troubleshooting

Please read the Troubleshooting Wiki.

Related Work

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].