[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6619":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":41,"readmeContent":42,"aiSummary":43,"trendingCount":16,"starSnapshotCount":16,"syncStatus":19,"lastSyncTime":44,"discoverSource":45},6619,"gravity","marcobambini\u002Fgravity","marcobambini","Gravity Programming Language","https:\u002F\u002Fgravity-lang.org",null,"C",4533,238,108,38,0,5,26,2,29.14,"MIT License",false,"master",true,[26,27,28,29,30,5,31,32,33,34,35,36,37,38,39,40],"bridge","bytecode","c","closure","fibers","interpreter","json","language","object-oriented","objective-c","portable","pratt-parser","programming-language","scripting-language","virtual-machine","2026-06-12 02:01:27","\u003Cp align=\"center\" >\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fmarcobambini\u002Fgravity\u002Fmaster\u002Fdocs\u002Fassets\u002Fimages\u002Flogo-gravity.png\" height=\"74px\" alt=\"Gravity Programming Language\" title=\"Gravity Programming Language\">\n\u003C\u002Fp>\n\n**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 \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift\">Swift\u003C\u002Fa>-like syntax.\n\n**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.\n\n**Gravity** has been developed from scratch for the \u003Ca href=\"http:\u002F\u002Fcreolabs.com\" target=\"_blank\">Creo\u003C\u002Fa> 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 6.5K lines long, the multipass compiler code is about 10K lines and the shared code is about 4.7K lines long. The compiler and virtual machine combined add less than 200KB to the executable on a 64-bit system.\n\n## What Gravity code looks like\n\n```swift\nclass Vector {\n\t\u002F\u002F instance variables\n\tvar x = 0;\n\tvar y = 0;\n\tvar z = 0;\n\n\t\u002F\u002F constructor\n\tfunc init (a = 0, b = 0, c = 0) {\n\t\tx = a; y = b; z = c;\n\t}\n\n\t\u002F\u002F instance method (built-in operator overriding)\n\tfunc + (v) {\n\t\tif (v is Int) return Vector(x+v, y+v, z+v);\n\t\telse if (v is Vector) return Vector(x+v.x, y+v.y, z+v.z);\n\t\treturn null;\n\t}\n\n\t\u002F\u002F instance method (built-in String conversion overriding)\n\tfunc String() {\n\t        \u002F\u002F string interpolation support\n\t\treturn \"[\\(x),\\(y),\\(z)]\";\n\t}\n}\n\nfunc main() {\n\t\u002F\u002F initialize a new vector object\n\tvar v1 = Vector(1,2,3);\n\t\n\t\u002F\u002F initialize a new vector object\n\tvar v2 = Vector(4,5,6);\n\t\n\t\u002F\u002F call + function in the vector object\n\tvar v3 = v1 + v2;\n\t\n\t\u002F\u002F returns string \"[1,2,3] + [4,5,6] = [5,7,9]\"\n    \treturn \"\\(v1) + \\(v2) = \\(v3)\";\n }\n ```\n\n## Features\n* multipass compiler with optimizer\n* dynamic typing\n* classes and inheritance\n* higher-order functions and classes\n* lexical scoping\n* coroutines (via fibers)\n* nested classes\n* closures\n* garbage collection (mark-and-sweep)\n* operator overriding\n* string interpolation\n* enums, modules, and structs (value types)\n* switch\u002Fcase and ranges\n* optional modules (Math, File, JSON, ENV)\n* powerful embedding API with bridging support\n* built-in unit tests\n* built-in JSON serializer\u002Fdeserializer\n* **optional semicolons**\n\n## Building\n\n**Make (Linux \u002F macOS \u002F BSD)**\n```bash\nmake                    # Build the gravity CLI executable\nmake mode=debug         # Debug build with symbols\nmake lib                # Build shared library (libgravity.dylib\u002Fso\u002Fdll)\nmake example            # Build the C embedding API example\nmake clean              # Clean all build artifacts\n```\n\n**CMake (cross-platform, including Windows)**\n```bash\ncmake -B build\ncmake --build build\n# Optionally disable the CLI and build the library only:\ncmake -B build -DBUILD_CLI=OFF\ncmake --build build\n```\n\nRequires a C99 compiler. No external dependencies.\n\n## Usage\n\n```bash\n.\u002Fgravity file.gravity                  # Compile and execute a source file\n.\u002Fgravity -c file.gravity               # Compile to bytecode (outputs gravity.json)\n.\u002Fgravity -o out.json -c file.gravity   # Compile to a specific output file\n.\u002Fgravity -x gravity.json               # Execute precompiled bytecode\n.\u002Fgravity -i 'return 2 + 3'             # Execute inline code\n.\u002Fgravity -t test\u002Funittest              # Run unit tests\n```\n\n## Testing\n\n```bash\n.\u002Fgravity -t test\u002Funittest              # Run all unit tests via the VM\n.\u002Ftest\u002Funittest\u002Frun_all.sh              # Run all unit tests via shell script (with per-test timeouts)\n.\u002Fgravity test\u002Funittest\u002Fsomefile.gravity # Run a single test file\n```\n\nThe `test\u002F` directory also contains `fuzzy\u002F` (randomised fuzzing inputs) and `infiniteloop\u002F` (tests that must terminate with a runtime error rather than hang).\n\n## Project Structure\n\n```\nsrc\u002F\n├── cli\u002F            Command-line interface\n├── compiler\u002F       Lexer, parser, AST, semantic analysis, IR, optimizer, codegen\n├── runtime\u002F        Stack-based VM, built-in types and core methods\n├── shared\u002F         Value representation, opcodes, hash table, array, memory\u002FGC\n├── optionals\u002F      Optional modules: Math, File, JSON, ENV\n└── utils\u002F          Debug disassembler, JSON serialization, file I\u002FO, UTF-8\n```\n\nFor a comprehensive technical deep-dive into the implementation, see [ARCHITECTURE.md](ARCHITECTURE.md).\n\n## Embedding API\n\nGravity is designed to be embedded inside a host application. The complete API lives in `src\u002Fruntime\u002Fgravity_vm.h` and `src\u002Fcompiler\u002Fgravity_compiler.h`. A minimal example:\n\n```c\n#include \"gravity_compiler.h\"\n#include \"gravity_core.h\"\n#include \"gravity_vm.h\"\n\nstatic void report_error(gravity_vm *vm, error_type_t type,\n                         const char *description, error_desc_t desc, void *xdata) {\n    printf(\"%s\\n\", description);\n}\n\nint main(void) {\n    const char *source = \"func main() { return 6 * 7; }\";\n\n    gravity_delegate_t delegate = {.error_callback = report_error};\n\n    \u002F\u002F compile\n    gravity_compiler_t *compiler = gravity_compiler_create(&delegate);\n    gravity_closure_t *closure   = gravity_compiler_run(compiler, source, strlen(source), 0, true, true);\n\n    \u002F\u002F create VM and transfer compiler-owned objects into it\n    gravity_vm *vm = gravity_vm_new(&delegate);\n    gravity_compiler_transfer(compiler, vm);\n    gravity_compiler_free(compiler);\n\n    \u002F\u002F execute and read result\n    if (gravity_vm_runmain(vm, closure)) {\n        gravity_value_t result = gravity_vm_result(vm);\n        gravity_value_dump(vm, result, NULL, 0);  \u002F\u002F prints: 42\n    }\n\n    gravity_vm_free(vm);\n    gravity_core_free();\n    return 0;\n}\n```\n\nSee [`examples\u002Fexample.c`](examples\u002Fexample.c) and the [embedding documentation](https:\u002F\u002Fgravity-lang.org) for the full bridging API.\n\n## Special thanks\nGravity was supported by a couple of open-source projects. The inspiration for closures comes from the elegant \u003Ca href=\"http:\u002F\u002Fwww.lua.org\" target=\"_blank\">Lua\u003C\u002Fa> programming language; specifically from the document \u003Ca href=\"http:\u002F\u002Fwww.cs.tufts.edu\u002F~nr\u002Fcs257\u002Farchive\u002Froberto-ierusalimschy\u002Fclosures-draft.pdf\">Closures in Lua\u003C\u002Fa>. For fibers, upvalues handling and some parts of the garbage collector, my gratitude goes to \u003Ca href=\"http:\u002F\u002Fjournal.stuffwithstuff.com\" target=\"_blank\">Bob Nystrom\u003C\u002Fa> and his excellent \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmunificent\u002Fwren\">Wren\u003C\u002Fa> 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.\n\n## Documentation\nThe \u003Ca href=\"https:\u002F\u002Fmarcobambini.github.io\u002Fgravity\u002F#\u002FREADME\">Getting Started\u003C\u002Fa> page is a guide for downloading and compiling the language. There is also a more extensive \u003Ca href=\"https:\u002F\u002Fgravity-lang.org\">language documentation\u003C\u002Fa>. Official [wiki](https:\u002F\u002Fgithub.com\u002Fmarcobambini\u002Fgravity\u002Fwiki) is used to collect related projects and tools. For implementation internals, see the [Architecture Document](ARCHITECTURE.md).\n\n## Where Gravity is used\n* Gravity is the core language built into Creo (https:\u002F\u002Fcreolabs.com)\n* Gravity is the scripting language for the Untold game engine (https:\u002F\u002Fyoutu.be\u002FOGrWq8jpK14?t=58)\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a summary of changes across versions.\n\n## Community\n\n[![GitHub Discussions](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdiscussions-GitHub-blue)](https:\u002F\u002Fgithub.com\u002Fmarcobambini\u002Fgravity\u002Fdiscussions)\n\nQuestions, ideas, and general discussion are welcome in [GitHub Discussions](https:\u002F\u002Fgithub.com\u002Fmarcobambini\u002Fgravity\u002Fdiscussions).\n\n## Contributing\nContributions to Gravity are welcomed and encouraged!\u003Cbr>\nMore information is available in the official [CONTRIBUTING](CONTRIBUTING.md) file.\n* \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmarcobambini\u002Fgravity\u002Fissues\u002Fnew\">Open an issue\u003C\u002Fa>:\n\t* if you need help\n\t* if you find a bug\n\t* if you have a feature request\n\t* to ask a general question\n* \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmarcobambini\u002Fgravity\u002Fpulls\">Submit a pull request\u003C\u002Fa>:\n\t* if you want to contribute\n\n## License\nGravity is available under the permissive MIT license.\n","Gravity 是一种用 C 语言编写的轻量级、动态类型、可嵌入的编程语言，无外部依赖（除了标准库）。它支持过程式、面向对象、函数式和数据驱动编程，并具有类似 Swift 的现代语法。核心功能包括多阶段编译器优化、动态类型、类与继承、高阶函数、协程（通过纤程实现）、闭包以及垃圾回收等。特别地，Gravity 还提供了强大的嵌入 API 和桥接支持，适用于需要在 iOS 和 Android 平台上编写可移植代码的应用场景。其简洁的语法和低资源占用使其成为移动开发的理想选择。","2026-06-11 03:07:57","top_language"]