dibyendumajumdar / Ravi

Licence: mit
Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers

Programming Languages

c
50402 projects - #5 most used programming language
lua
6591 projects

Labels

Projects that are alternatives of or similar to Ravi

Easy Just In Time
LLVM Optimization to extract a function, embedded in its intermediate representation in the binary, and execute it using the LLVM Just-In-Time compiler.
Stars: ✭ 361 (-54.76%)
Mutual labels:  jit
Dynarmic
An ARM dynamic recompiler.
Stars: ✭ 475 (-40.48%)
Mutual labels:  jit
Zetavm
Multi-Language Platform for Dynamic Programming Languages
Stars: ✭ 592 (-25.81%)
Mutual labels:  jit
Dora
Dora VM
Stars: ✭ 371 (-53.51%)
Mutual labels:  jit
Cascade
A Just-In-Time Compiler for Verilog from VMware Research
Stars: ✭ 413 (-48.25%)
Mutual labels:  jit
Wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift
Stars: ✭ 6,413 (+703.63%)
Mutual labels:  jit
Opensmalltalk Vm
Cross-platform virtual machine for Squeak, Pharo, Cuis, and Newspeak.
Stars: ✭ 345 (-56.77%)
Mutual labels:  jit
Inkwell
It's a New Kind of Wrapper for Exposing LLVM (Safely)
Stars: ✭ 732 (-8.27%)
Mutual labels:  jit
Dynasm Rs
A dynasm-like tool for rust.
Stars: ✭ 432 (-45.86%)
Mutual labels:  jit
Potion
_why the lucky stiff's little language (the official repo... until _why returns)
Stars: ✭ 586 (-26.57%)
Mutual labels:  jit
Firebird
Third-party multi-platform emulator of the ARM-based TI-Nspire calculators
Stars: ✭ 374 (-53.13%)
Mutual labels:  jit
Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+556.39%)
Mutual labels:  jit
Mull
Practical mutation testing tool for C and C++
Stars: ✭ 536 (-32.83%)
Mutual labels:  jit
Codegen
Experimental wrapper over LLVM for generating and compiling code at run-time.
Stars: ✭ 362 (-54.64%)
Mutual labels:  jit
Rustc codegen cranelift
Cranelift based backend for rustc
Stars: ✭ 675 (-15.41%)
Mutual labels:  jit
Monohook
hook C# method at runtime without modify dll file (such as UnityEditor.dll)
Stars: ✭ 348 (-56.39%)
Mutual labels:  jit
Libxsmm
Library for specialized dense and sparse matrix operations, and deep learning primitives.
Stars: ✭ 518 (-35.09%)
Mutual labels:  jit
Tinycc
Unofficial mirror of mob development branch
Stars: ✭ 784 (-1.75%)
Mutual labels:  jit
Revise.jl
Automatically update function definitions in a running Julia session
Stars: ✭ 705 (-11.65%)
Mutual labels:  jit
Moarvm
A VM with adaptive optimization and JIT compilation, built for Rakudo
Stars: ✭ 537 (-32.71%)
Mutual labels:  jit

========================= Ravi Programming Language

.. image:: https://travis-ci.org/dibyendumajumdar/ravi.svg?branch=master :target: https://travis-ci.org/dibyendumajumdar/ravi

Ravi is a dialect of Lua <http://www.lua.org/>_ with limited optional static typing and features MIR <https://github.com/vnmakarov/mir>_ powered JIT compilers. The name Ravi comes from the Sanskrit word for the Sun. Interestingly a precursor to Lua was Sol <http://www.lua.org/history.html>_ which had support for static types; Sol means the Sun in Portugese.

Lua is perfect as a small embeddable dynamic language so why a derivative? Ravi extends Lua with static typing for improved performance when JIT compilation is enabled. However, the static typing is optional and therefore Lua programs are also valid Ravi programs.

There are other attempts to add static typing to Lua - e.g. Typed Lua <https://github.com/andremm/typedlua>_ but these efforts are mostly about adding static type checks in the language while leaving the VM unmodified. The Typed Lua effort is very similar to the approach taken by Typescript in the JavaScript world. The static typing is to aid programming in the large - the code is eventually translated to standard Lua and executed in the unmodified Lua VM.

My motivation is somewhat different - I want to enhance the VM to support more efficient operations when types are known. Type information can be exploited by JIT compilation technology to improve performance. At the same time, I want to keep the language safe and therefore usable by non-expert programmers.

Of course there is the fantastic LuaJIT <http://luajit.org>_ implementation. Ravi has a different goal compared to LuaJIT. Ravi prioritizes ease of maintenance and support, language safety, and compatibility with Lua 5.3, over maximum performance. For more detailed comparison please refer to the documentation links below.

Features

  • Optional static typing - for details see the reference manual <https://the-ravi-programming-language.readthedocs.io/en/latest/ravi-reference.html>_.
  • Type specific bytecodes to improve performance
  • Compatibility with Lua 5.3 (see Compatibility section below)
  • Generational GC from Lua 5.4
  • defer statement for releasing resources
  • Compact JIT backend MIR <https://github.com/vnmakarov/mir>_.
  • A distribution with batteries <https://github.com/dibyendumajumdar/Suravi>_.
  • A Visual Studio Code debugger extension <https://marketplace.visualstudio.com/items?itemName=ravilang.ravi-debug>_ - interpreted mode debugger.

Documentation

  • For the Lua extensions in Ravi see the Reference Manual <https://the-ravi-programming-language.readthedocs.io/en/latest/ravi-reference.html>_.
  • MIR JIT Build instructions <https://the-ravi-programming-language.readthedocs.io/en/latest/ravi-mir-instructions.html>_.
  • Also see Ravi Documentation <http://the-ravi-programming-language.readthedocs.org/en/latest/index.html>_.
  • and the slides I presented at the Lua 2015 Workshop <http://www.lua.org/wshop15.html>_.

Lua Goodies

  • An Introduction to Lua <http://the-ravi-programming-language.readthedocs.io/en/latest/lua-introduction.html>_ attempts to provide a quick overview of Lua for folks coming from other languages.
  • Lua 5.3 Bytecode Reference <http://the-ravi-programming-language.readthedocs.io/en/latest/lua_bytecode_reference.html>_ is my attempt to bring up to date the Lua 5.1 Bytecode Reference <http://luaforge.net/docman/83/98/ANoFrillsIntroToLua51VMInstructions.pdf>_.
  • A patch for Lua 5.3 <https://github.com/dibyendumajumdar/ravi/blob/master/patches/defer_statement_for_Lua_5_3.patch>_ implements the 'defer' statement.
  • A patch for Lua 5.4 <https://github.com/dibyendumajumdar/ravi/blob/master/patches/defer_statement_for_Lua_5_4.patch>_ implements the 'defer' statement.

Lua 5.4 Position Statement

Lua 5.4 relationship to Ravi is as follows:

  • Generational GC - back-ported to Ravi.
  • New random number generator - back-ported to Ravi.
  • Multiple user values can be associated with userdata - under consideration.
  • <const> variables - not planned.
  • <close> variables - Ravi has 'defer' statement which is the better option in my opinion, hence no plans to support <close> variables.
  • Interpreter performance improvements - these are beneficial to Lua interpreter but not to the JIT backends, hence not much point in back-porting.
  • Table implementation changes - under consideration.
  • String to number coercion is now part of string library metamethods - back-ported to Ravi.
  • utf8 library accepts codepoints up to 2^31 - back-ported to Ravi.
  • Removal of compatibility layers for 5.1, and 5.2 - not implemented as Ravi continues to provide these layers as per Lua 5.3.

Compatibility with Lua 5.3

Ravi should be able to run all Lua 5.3 programs in interpreted mode, but following should be noted:

  • Ravi supports optional typing and enhanced types such as arrays (see the documentation). Programs using these features cannot be run by standard Lua. However all types in Ravi can be passed to Lua functions; operations on Ravi arrays within Lua code will be subject to restrictions as described in the section above on arrays.
  • Values crossing from Lua to Ravi will be subjected to typechecks should these values be assigned to typed variables.
  • Upvalues cannot subvert the static typing of local variables (issue #26) when types are annotated.
  • Certain Lua limits are reduced due to changed byte code structure. These are described below.
  • Ravi uses an extended bytecode which means it is not compatible with Lua 5.x bytecode.
  • Ravi incorporates the new Generational GC from Lua 5.4, hence the GC interface has changed.

+-----------------+-------------+-------------+ | Limit name | Lua value | Ravi value | +=================+=============+=============+ | MAXUPVAL | 255 | 125 | +-----------------+-------------+-------------+ | LUAI_MAXCCALLS | 200 | 125 | +-----------------+-------------+-------------+ | MAXREGS | 255 | 125 | +-----------------+-------------+-------------+ | MAXVARS | 200 | 125 | +-----------------+-------------+-------------+ | MAXARGLINE | 250 | 120 | +-----------------+-------------+-------------+

When JIT compilation is enabled there are following additional constraints:

  • Ravi will only execute JITed code from the main Lua thread; any secondary threads (coroutines) execute in interpreter mode.
  • In JITed code tailcalls are implemented as regular calls so unlike the interpreter VM which supports infinite tail recursion JIT compiled code only supports tail recursion to a depth of about 110 (issue #17)
  • Debug api and hooks are not supported in JIT mode

History

  • 2015 - Implemented JIT compilation using LLVM - Implemented libgccjit based alternative JIT <https://github.com/dibyendumajumdar/ravi/tree/gccjit-ravi534>_ (now discontinued)
  • 2016 - Implemented debugger for Ravi and Lua 5.3 for Visual Studio Code <https://github.com/dibyendumajumdar/ravi/tree/master/vscode-debugger>_
  • 2017 - Embedded C compiler using dmrC project (C JIT compiler) (now discontinued) - Additional type-annotations
  • 2018 - Implemented Eclipse OMR JIT backend <https://github.com/dibyendumajumdar/ravi/tree/omrjit>_ (now discontinued) - Created Ravi with batteries <https://github.com/dibyendumajumdar/Suravi>_.
  • 2019 - New language feature - defer statement - New JIT backend MIR <https://github.com/vnmakarov/mir>_.
  • 2020 - New parser / type checker / compiler <https://github.com/dibyendumajumdar/ravi-compiler>_ - Generational GC back-ported from Lua 5.4 - Support for LLVM backend <https://github.com/dibyendumajumdar/ravi/tree/llvm>_ archived
  • 2021 (Plan) - Integrated AOT and JIT compilation support - Ravi 1.0 release

License

MIT License

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