All Projects → marcobambini → Gravity

marcobambini / Gravity

Licence: mit
Gravity Programming Language

Programming Languages

c
50402 projects - #5 most used programming language
objective c
16641 projects - #2 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to Gravity

Simple
The Simple Intelligent and Modular Programming Language and Environment
Stars: ✭ 120 (-96.98%)
Mutual labels:  interpreter, portable, virtual-machine
Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (-92.24%)
Mutual labels:  fibers, interpreter, virtual-machine
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 79 (-98.01%)
Mutual labels:  interpreter, portable, virtual-machine
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 101 (-97.45%)
Mutual labels:  interpreter, portable, virtual-machine
vein
🔮⚡️Vein is an open source high-level strictly-typed programming language with a standalone OS, arm and quantum computing support.
Stars: ✭ 31 (-99.22%)
Mutual labels:  interpreter, virtual-machine
jingle
🔔 Jingle is a dynamically-typed, multi-paradigm programming language designed for humans and machines.
Stars: ✭ 34 (-99.14%)
Mutual labels:  interpreter, virtual-machine
X11Basic
X11-Basic BASIC programming language.
Stars: ✭ 42 (-98.94%)
Mutual labels:  interpreter, virtual-machine
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-99.55%)
Mutual labels:  interpreter, virtual-machine
Arduino-FVM
Byte Token Threaded Forth Virtual Machine (FVM) for Arduino
Stars: ✭ 35 (-99.12%)
Mutual labels:  interpreter, virtual-machine
hematita
A memory safe Lua interpreter
Stars: ✭ 118 (-97.03%)
Mutual labels:  interpreter, virtual-machine
maxc
Programming Language maxc
Stars: ✭ 36 (-99.09%)
Mutual labels:  interpreter, virtual-machine
snap
Snap Programming Language
Stars: ✭ 20 (-99.5%)
Mutual labels:  interpreter, object-oriented
Animach
Scheme语言实现和运行时环境 / A Scheme runtime & implementation
Stars: ✭ 45 (-98.87%)
Mutual labels:  interpreter, virtual-machine
jaws
Jaws is an invisible programming language! Inject invisible code into other languages and files! Created for security research -- see blog post
Stars: ✭ 204 (-94.86%)
Mutual labels:  interpreter, virtual-machine
wasm-joey
Serverless Wasm - A lightweight Node.js application for deploying and executing WebAssembly(Wasm) binary-code via HTTP
Stars: ✭ 48 (-98.79%)
Mutual labels:  portable, virtual-machine
lust
A parser, compiler, and virtual machine evaluator for a minimal subset of Lua; written from scratch in Rust.
Stars: ✭ 120 (-96.98%)
Mutual labels:  interpreter, virtual-machine
RISVM
A low overhead, embeddable bytecode virtual machine in C++
Stars: ✭ 21 (-99.47%)
Mutual labels:  interpreter, virtual-machine
Goby
Goby - Yet another programming language written in Go
Stars: ✭ 3,296 (-16.94%)
Mutual labels:  interpreter, object-oriented
Wasm3
🚀 The fastest WebAssembly interpreter, and the most universal runtime
Stars: ✭ 4,375 (+10.26%)
Mutual labels:  interpreter, virtual-machine
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (-96.04%)
Mutual labels:  interpreter, virtual-machine

Build Status

Gravity Programming Language

Gravity is a powerful, dynamically typed, lightweight, embeddable programming language written in C without any external dependencies (except for stdlib). It is a class-based concurrent scripting language with modern Swift-like syntax.

Gravity supports procedural programming, object-oriented programming, functional programming, and data-driven programming. Thanks to special built-in methods, it can also be used as a prototype-based programming language.

Gravity has been developed from scratch for the Creo project in order to offer an easy way to write portable code for the iOS and Android platforms. It is written in portable C code that can be compiled on any platform using a C99 compiler. The VM code is about 4K lines long, the multipass compiler code is about 7K lines and the shared code is about 3K lines long. The compiler and virtual machine combined add less than 200KB to the executable on a 64-bit system.

What Gravity code looks like

class Vector {
	// instance variables
	var x = 0;
	var y = 0;
	var z = 0;

	// constructor
	func init (a = 0, b = 0, c = 0) {
		x = a; y = b; z = c;
	}

	// instance method (built-in operator overriding)
	func + (v) {
		if (v is Int) return Vector(x+v, y+v, z+v);
		else if (v is Vector) return Vector(x+v.x, y+v.y, z+v.z);
		return null;
	}

	// instance method (built-in String conversion overriding)
	func String() {
	        // string interpolation support
		return "[\(x),\(y),\(z)]";
	}
}

func main() {
	// initialize a new vector object
	var v1 = Vector(1,2,3);
	
	// initialize a new vector object
	var v2 = Vector(4,5,6);
	
	// call + function in the vector object
	var v3 = v1 + v2;
	
	// returns string "[1,2,3] + [4,5,6] = [5,7,9]"
    	return "\(v1) + \(v2) = \(v3)";
 }

Features

  • multipass compiler
  • dynamic typing
  • classes and inheritance
  • higher-order functions and classes
  • lexical scoping
  • coroutines (via fibers)
  • nested classes
  • closures
  • garbage collection
  • operator overriding
  • powerful embedding API
  • built-in unit tests
  • built-in JSON serializer/deserializer
  • optional semicolons

Special thanks

Gravity was supported by a couple of open-source projects. The inspiration for closures comes from the elegant Lua programming language; specifically from the document Closures in Lua. For fibers, upvalues handling and some parts of the garbage collector, my gratitude goes to Bob Nystrom and his excellent Wren programming language. A very special thanks should also go to my friend Andrea Donetti who helped me debugging and testing various aspects of the language.

Documentation

The Getting Started page is a guide for downloading and compiling the language. There is also a more extensive language documentation. Official wiki is used to collect related projects and tools.

Community

Seems like a good idea to make a group chat for people to discuss Gravity.
Join the chat at https://gitter.im/gravity-lang/

Contributing

Contributions to Gravity are welcomed and encouraged!
More information is available in the official CONTRIBUTING file.

License

Gravity is available under the permissive MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].