||2 years ago|
|.devcontainer||3 years ago|
|.github/workflows||2 years ago|
|build-utils||2 years ago|
|docker/linux-ubuntu||2 years ago|
|include||2 years ago|
|mir||2 years ago|
|patches||2 years ago|
|ravicomp||2 years ago|
|readthedocs||2 years ago|
|src||2 years ago|
|tests||2 years ago|
|vscode-debugger||2 years ago|
|.clang-format||4 years ago|
|.gitignore||3 years ago|
|.gitmodules||5 years ago|
|.travis.yml||2 years ago|
|CMakeLists.txt||2 years ago|
|LICENSE||3 years ago|
|Makefile||3 years ago|
|README.md||2 years ago|
|lua-config.cmake.in||3 years ago|
|ravi-config.h.in||2 years ago|
|ravi-env.bat.in||3 years ago|
|ravi-env.linux.sh.in||3 years ago|
|ravi-env.osx.sh.in||3 years ago|
Ravi Programming Language
Ravi is a dialect of Lua with limited optional static typing and features MIR powered JIT compilers. The name Ravi comes from the Sanskrit word for the Sun. Interestingly a precursor to Lua was Sol 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.
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 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.
- Optional static typing - for details see the reference manual.
- Type specific bytecodes to improve performance
- Compatibility with Lua 5.3 (see Compatibility section below)
- Generational GC from Lua 5.4
deferstatement for releasing resources
- Compact JIT backend MIR.
- A distribution with batteries.
- A Visual Studio Code debugger
- interpreted mode debugger.
- For the Lua extensions in Ravi see the Reference Manual.
- MIR JIT Build instructions.
- Also see Ravi Documentation.
- and the slides I presented at the Lua 2015 Workshop.
- An Introduction to Lua attempts to provide a quick overview of Lua for folks coming from other languages.
- Lua 5.3 Bytecode Reference is my attempt to bring up to date the Lua 5.1 Bytecode Reference.
- A patch for Lua 5.3 implements the 'defer' statement.
- A patch for Lua 5.4.[0-2] implements the 'defer' statement.
- Updated patch for Lua 5.4.3 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
- 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
- Implemented JIT compilation using LLVM
- Implemented libgccjit based alternative JIT (now discontinued)
- Implemented debugger for Ravi and Lua 5.3 for Visual Studio Code
- Embedded C compiler using dmrC project (C JIT compiler) (now discontinued)
- Additional type-annotations
- Implemented Eclipse OMR JIT backend (now discontinued)
- Created Ravi with batteries.
- New language feature - defer statement
- New JIT backend MIR.
- New parser / type checker / compiler
- Generational GC back-ported from Lua 5.4
- Support for LLVM backend archived
- 2021 (Plan)
- Integrated AOT and JIT compilation support
- Ravi 1.0 release