Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Go to file
Pavel R. 7adbc171f6
changed types to strict (nil disallowed) in lcode.c
3 years ago
.devcontainer Add support for codespaces 3 years ago
.github/workflows Remove cmake branch from build.yml 3 years ago
build-utils issue #203 Removing LLVM support, see llvm branch for archived version 3 years ago
docker/linux-ubuntu issue #203 Removing LLVM support, see llvm branch for archived version 3 years ago
include Removed RAVI_DEFER_STATEMENT define (there are no reasons to disable it) 3 years ago
mir issue #169 Sync with upstream project 3 years ago
patches Update Lua 5.4.3 defer patch - minor change to remove some leftover stuff 3 years ago
ravicomp Removed RAVI_DEFER_STATEMENT define (there are no reasons to disable it) 3 years ago
readthedocs Update docs 3 years ago
src changed types to strict (nil disallowed) in lcode.c 3 years ago
tests Bump binary version & smaller sizes for stripped binaries 3 years ago
vscode-debugger issue #204 Code reorg 3 years ago
.clang-format issue #98 reformat 5 years ago
.gitignore issue #169 Update MIR to latest version 4 years ago
.gitmodules issue #126 remove dmr_C as a submodule 6 years ago
.travis.yml Update .travis.yml 3 years ago
CMakeLists.txt issue #198 Cleanup 3 years ago
LICENSE Update copyright notices 4 years ago
Makefile issue #195 Some improvements to Makefile build - based on Lua 5.4 build improvements 4 years ago
README.md Add README.md 3 years ago
lua-config.cmake.in issue #182 4 years ago
ravi-config.h.in issue #186 leftover cleanup 3 years ago
ravi-env.bat.in issue #182 #178 Fix issue with scripst after moving to CMAKE_INSTALL_BINDIR 4 years ago
ravi-env.linux.sh.in issue #182 #178 Fix issue with scripst after moving to CMAKE_INSTALL_BINDIR 4 years ago
ravi-env.osx.sh.in issue #182 #178 Fix issue with scripst after moving to CMAKE_INSTALL_BINDIR 4 years ago

README.md

Ravi Programming Language

image

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.

There are other attempts to add static typing to Lua - e.g. Typed Lua 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 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

Documentation

Lua Goodies

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

License

MIT License