dibyendumajumdar / ravi

Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
http://ravilang.github.io/
Other
1.16k stars 60 forks source link
c jit lua mirjit programming-language

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

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

Features

Articles about Ravi

Documentation

Lua Goodies

Lua 5.4 Position Statement

Lua 5.4 relationship to Ravi is as follows:

Compatibility with Lua 5.3

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:

History

License

MIT License