|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| .github/workflows/ | H | 22-Jul-2021 | - | 72 | 60 |
| api/ | H | 22-Jul-2021 | - | 896 | 734 |
| binding/ | H | 22-Jul-2021 | - | 2,940 | 2,470 |
| docs/ | H | 07-May-2022 | - | 2,152 | 1,732 |
| examples/ | H | 22-Jul-2021 | - | 837 | 677 |
| gravity.xcodeproj/ | H | 22-Jul-2021 | - | 648 | 634 |
| gravity_visualstudio/ | H | 22-Jul-2021 | - | 1,391 | 1,352 |
| src/ | H | 03-May-2022 | - | 27,578 | 18,938 |
| test/ | H | 22-Jul-2021 | - | 12,940 | 10,759 |
| .gitattributes | H A D | 22-Jul-2021 | 62 | 3 | 2 |
| .gitignore | H A D | 22-Jul-2021 | 5.4 KiB | 327 | 269 |
| .travis.yml | H A D | 22-Jul-2021 | 106 | 11 | 10 |
| CONTRIBUTING.md | H A D | 22-Jul-2021 | 1.4 KiB | 27 | 21 |
| CONTRIBUTORS | H A D | 22-Jul-2021 | 404 | 9 | 8 |
| LICENSE | H A D | 22-Jul-2021 | 1 KiB | 22 | 17 |
| Makefile | H A D | 22-Jul-2021 | 1.6 KiB | 74 | 56 |
| README.md | H A D | 22-Jul-2021 | 4.4 KiB | 94 | 74 |
| TODO.md | H A D | 22-Jul-2021 | 349 | 12 | 10 |
README.md
1[![Build Status](https://travis-ci.com/marcobambini/gravity.svg?branch=master)](https://travis-ci.com/marcobambini/gravity)
2
3<p align="center" >
4<img src="https://raw.githubusercontent.com/marcobambini/gravity/master/docs/assets/images/logo-gravity.png" height="74px" alt="Gravity Programming Language" title="Gravity Programming Language">
5</p>
6
7**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 <a href="https://github.com/apple/swift">Swift</a>-like syntax.
8
9**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.
10
11**Gravity** has been developed from scratch for the <a href="http://creolabs.com" target="_blank">Creo</a> 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.
12
13## What Gravity code looks like
14
15```swift
16class Vector {
17 // instance variables
18 var x = 0;
19 var y = 0;
20 var z = 0;
21
22 // constructor
23 func init (a = 0, b = 0, c = 0) {
24 x = a; y = b; z = c;
25 }
26
27 // instance method (built-in operator overriding)
28 func + (v) {
29 if (v is Int) return Vector(x+v, y+v, z+v);
30 else if (v is Vector) return Vector(x+v.x, y+v.y, z+v.z);
31 return null;
32 }
33
34 // instance method (built-in String conversion overriding)
35 func String() {
36 // string interpolation support
37 return "[\(x),\(y),\(z)]";
38 }
39}
40
41func main() {
42 // initialize a new vector object
43 var v1 = Vector(1,2,3);
44
45 // initialize a new vector object
46 var v2 = Vector(4,5,6);
47
48 // call + function in the vector object
49 var v3 = v1 + v2;
50
51 // returns string "[1,2,3] + [4,5,6] = [5,7,9]"
52 return "\(v1) + \(v2) = \(v3)";
53 }
54 ```
55
56## Features
57* multipass compiler
58* dynamic typing
59* classes and inheritance
60* higher-order functions and classes
61* lexical scoping
62* coroutines (via fibers)
63* nested classes
64* closures
65* garbage collection
66* operator overriding
67* powerful embedding API
68* built-in unit tests
69* built-in JSON serializer/deserializer
70* **optional semicolons**
71
72## Special thanks
73Gravity was supported by a couple of open-source projects. The inspiration for closures comes from the elegant <a href="http://www.lua.org" target="_blank">Lua</a> programming language; specifically from the document <a href="http://www.cs.tufts.edu/~nr/cs257/archive/roberto-ierusalimschy/closures-draft.pdf">Closures in Lua</a>. For fibers, upvalues handling and some parts of the garbage collector, my gratitude goes to <a href="http://journal.stuffwithstuff.com" target="_blank">Bob Nystrom</a> and his excellent <a href="https://github.com/munificent/wren">Wren</a> 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.
74
75## Documentation
76The <a href="https://marcobambini.github.io/gravity/#/README">Getting Started</a> page is a guide for downloading and compiling the language. There is also a more extensive <a href="http://gravity-lang.org">language documentation</a>. Official [wiki](https://github.com/marcobambini/gravity/wiki) is used to collect related projects and tools.
77
78## Community
79Seems like a good idea to make a group chat for people to discuss Gravity.<br> [![Join the chat at https://gitter.im/gravity-lang/](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gravity-lang/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
80
81## Contributing
82Contributions to Gravity are welcomed and encouraged!<br>
83More information is available in the official [CONTRIBUTING](CONTRIBUTING.md) file.
84* <a href="https://github.com/marcobambini/gravity/issues/new">Open an issue</a>:
85 * if you need help
86 * if you find a bug
87 * if you have a feature request
88 * to ask a general question
89* <a href="https://github.com/marcobambini/gravity/pulls">Submit a pull request</a>:
90 * if you want to contribute
91
92## License
93Gravity is available under the permissive MIT license.
94