.. image:: https://github.com/dibyendumajumdar/ravi/workflows/build/badge.svg :target: https://github.com/dibyendumajumdar/ravi
Ravi is a dialect of Lua <http://www.lua.org/>
with limited optional static typing and
features a JIT compiler powered by MIR <https://github.com/vnmakarov/mir>
as well as support for AOT compilation to native code.
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.
defer
statement for releasing resourcesMIR <https://github.com/vnmakarov/mir>
_distribution with batteries <https://github.com/dibyendumajumdar/Suravi>
_Visual Studio Code debugger extension <https://marketplace.visualstudio.com/items?itemName=ravilang.ravi-debug>
_ - interpreted mode debuggerJIT and AOT compilation <https://the-ravi-programming-language.readthedocs.io/en/latest/ravi-compiler.html>
_AOT Compilation to shared library <https://github.com/dibyendumajumdar/ravi/tree/master/aot-examples>
_embed C code snippets <https://github.com/dibyendumajumdar/ravi-compiler/wiki/Embedding-C>
_Ravi - Lua Dialect <https://medium.com/@dibyendumajumdar/ravi-a-lua-dialect-690f3844d4cd>
_.Embedding C code in Ravi <https://medium.com/@dibyendumajumdar/embedding-c-code-in-ravi-a-lua-dialect-1777c8be8819>
_.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>
_.Lua 2015 Workshop <http://www.lua.org/wshop15.html>
_.Lua 2022 Workshop <https://www.lua.org/wshop22.html>
_.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>
.patch for Lua 5.3 <https://github.com/dibyendumajumdar/ravi/blob/master/patches/defer_statement_for_Lua_5_3.patch>
_ implements the 'defer' statement.patch for Lua 5.4.[0-2] <https://github.com/dibyendumajumdar/ravi/blob/master/patches/defer_statement_for_Lua_5_4.patch>
_ implements the 'defer' statement.patch for Lua 5.4.[3-4] <https://github.com/dibyendumajumdar/ravi/blob/master/patches/defer_statement_patch_for_Lua_5_4_3.patch>
_ implements the 'defer' statement.Lua 5.4 relationship to Ravi is as follows:
<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. Ravi should be able to run all Lua 5.3 programs in interpreted mode, but following should be noted:
+-----------------+-------------+-------------+ | 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:
libgccjit based alternative JIT <https://github.com/dibyendumajumdar/ravi/tree/gccjit-ravi534>
_ (now discontinued)Visual Studio Code <https://github.com/dibyendumajumdar/ravi/tree/master/vscode-debugger>
_Eclipse OMR JIT backend <https://github.com/dibyendumajumdar/ravi/tree/omrjit>
_ (now discontinued)Ravi with batteries <https://github.com/dibyendumajumdar/Suravi>
_.defer
statementMIR <https://github.com/vnmakarov/mir>
_.New parser / type checker / compiler <https://github.com/dibyendumajumdar/ravi-compiler>
_LLVM backend <https://github.com/dibyendumajumdar/ravi/tree/llvm>
_ archivedEmbedded C syntax <https://github.com/dibyendumajumdar/ravi-compiler/wiki/Embedding-C>
_ MIT License