https://github.com/dibyendumajumdar/ravi Skip to content Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} dibyendumajumdar / ravi Public * Notifications * Fork 58 * Star 1.1k * Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers ravilang.github.io/ License View license 1.1k stars 58 forks Branches Tags Activity Star Notifications * Code * Issues 90 * Pull requests 2 * Discussions * Actions * Projects 0 * Wiki * Security * Insights Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Wiki * Security * Insights dibyendumajumdar/ravi This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 2,384 Commits .devcontainer .devcontainer .github/workflows .github/workflows aot-examples aot-examples build-utils build-utils docker/linux-ubuntu docker/linux-ubuntu include include mir mir patches patches ravicomp ravicomp readthedocs readthedocs src src tests tests vscode-debugger vscode-debugger .clang-format .clang-format .gitignore .gitignore .gitmodules .gitmodules .readthedocs.yaml .readthedocs.yaml .travis.yml .travis.yml CMakeLists.txt CMakeLists.txt LICENSE LICENSE Makefile Makefile README.rst README.rst lua-config.cmake.in lua-config.cmake.in ravi-config.h.in ravi-config.h.in ravi-env.bat.in ravi-env.bat.in ravi-env.linux.sh.in ravi-env.linux.sh.in ravi-env.osx.sh.in ravi-env.osx.sh.in View all files Repository files navigation * README * License Ravi Programming Language [badge] Ravi is a dialect of Lua with limited optional static typing and features a JIT compiler powered by 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 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 * Optional static typing * 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 * A distribution with batteries * A Visual Studio Code debugger extension - interpreted mode debugger * A new compiler framework for JIT and AOT compilation * AOT Compilation to shared library * Preview feature: Ability to embed C code snippets Articles about Ravi * Ravi - Lua Dialect. * Embedding C code in Ravi. Documentation * Reference Manual. * MIR JIT Build instructions. * Lua 2015 Workshop. * Lua 2022 Workshop. Lua Goodies * 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-4] 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. * variables - not planned. * variables - Ravi has 'defer' statement which is the better option in my opinion, hence no plans to support 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 o Implemented JIT compilation using LLVM o Implemented libgccjit based alternative JIT (now discontinued) * 2016 o Implemented debugger for Ravi and Lua 5.3 for Visual Studio Code * 2017 o Embedded C compiler using dmrC project (C JIT compiler) (now discontinued) o Additional type-annotations * 2018 o Implemented Eclipse OMR JIT backend (now discontinued) o Created Ravi with batteries. * 2019 o New language feature - defer statement o New JIT backend MIR. * 2020 o New parser / type checker / compiler o Generational GC back-ported from Lua 5.4 o Support for LLVM backend archived * 2021 o Integrated AOT and JIT compilation support o Embedded C syntax * 2022-2023 o Improve Embedded C support with more validation o Improve tests and documentation overall o Ensure new compiler is production grade (i.e. always generates correct code) License MIT License About Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers ravilang.github.io/ Topics c programming-language lua jit mirjit Resources Readme License View license Activity Stars 1.1k stars Watchers 50 watching Forks 58 forks Report repository Releases 36 Ravi (a Lua dialect) 1.0 Beta-11 Release with JIT/AOT compilation support Latest Jan 14, 2023 + 35 releases Packages 0 No packages published Contributors 5 * @dibyendumajumdar * @XmiliaH * @niaow * @mingodad * @wdv4758h Languages * C 85.1% * Lua 10.8% * LLVM 3.0% * Makefile 0.4% * CMake 0.3% * Python 0.2% * Other 0.2% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.