marcobambini/gravity logo

marcobambini/gravity

Free

Gravity Programming Language

FreeFree tier
Type
Open Source

About marcobambini/gravity

Gravity is a powerful, dynamically typed, lightweight, and embeddable programming language written in portable C99 without any external dependencies (except for stdlib). It features a modern Swift-like syntax and supports procedural, object-oriented, functional, and data-driven programming paradigms. The language includes a multipass compiler with optimizer, dynamic typing, classes and inheritance, higher-order functions, lexical scoping, coroutines (via fibers), nested classes, closures, mark-and-sweep garbage collection, operator overriding, string interpolation, enums, modules, structs (value types), switch/case with ranges, optional modules (Math, File, JSON, ENV), and a powerful embedding API with bridging support. It also provides built-in unit tests and JSON serializer/deserializer. The compiler and virtual machine combined add less than 200 KB to the executable. Gravity was developed from scratch for the Creo project to provide an easy way to write portable code for iOS and Android platforms.

Key Features

Multipass compiler with optimizer
Dynamic typing
Classes and inheritance
Higher-order functions and classes
Lexical scoping
Coroutines via fibers
Nested classes
Mark-and-sweep garbage collection
Operator overriding
String interpolation

Pros & Cons

Pros
  • Lightweight and embeddable with minimal footprint (under 200KB)
  • No external dependencies besides stdlib
  • Supports multiple programming paradigms (procedural, OOP, functional, data-driven)
  • Modern Swift-like syntax for readability
  • Built-in coroutines (fibers) for concurrency
  • Comprehensive built-in unit tests and JSON support
  • Cross-platform (C99 compatible)
Cons
  • Relatively niche with a smaller community and ecosystem
  • Limited third-party libraries and tools
  • Documentation primarily in the GitHub repository

Best For

Embedding in C applications for scriptingWriting portable code for iOS and Android (used in Creo project)Prototyping and teaching programming conceptsData-driven and concurrent scripting

FAQ

What is Gravity?
Gravity is a powerful, dynamically typed, lightweight, embeddable programming language written in C with a Swift-like syntax. It supports multiple programming paradigms and was created for the Creo project to write portable code for iOS and Android.
How do I build Gravity?
Gravity can be built using Make (on Linux, macOS, BSD) or CMake (cross-platform, including Windows). No external dependencies are required beyond a C99 compiler. The build process is documented in the repository's README.
What platforms does Gravity support?
Gravity is written in portable C99 and can be compiled on any platform that has a C99 compiler, including Linux, macOS, Windows, iOS, and Android.