Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/munificent/vigil
Vigil, the eternal morally vigilant programming language
https://github.com/munificent/vigil
Last synced: about 1 month ago
JSON representation
Vigil, the eternal morally vigilant programming language
- Host: GitHub
- URL: https://github.com/munificent/vigil
- Owner: munificent
- Created: 2013-01-03T08:05:26.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-09-26T22:21:21.000Z (about 2 years ago)
- Last Synced: 2024-10-01T13:04:33.165Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 2,894
- Watchers: 75
- Forks: 61
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dev-fun - Vigil - Vigil, the eternal morally vigilant programming language. (Esoteric languages)
README
Vigil is a *very safe* programming language, and an entry in the [January 2013 PLT Games competition](http://www.pltgames.com/competition/2013/1).
Many programming languages claim to take testing, contracts and safety seriously, but only Vigil is *truly* vigilant about not allowing code that fails to pass programmatic specifications.
## Syntax and semantics
Vigil is very similar to Python with the minor proviso that you must provide a `main()` function which will be automatically called for you.
Infinitely more important than mere syntax and semantics is its addition of **supreme moral vigilance**. This is similar to contracts, but less legal and more medieval.
### The `implore` statement to beseech your needs
Often, a function will require that parameters have certain desirable properties. A function in Vigil can state what it requires by using `implore`:
```python
def square_root(n):
implore n >= 0
return math.sqrt(n)
```If a caller fails to provide valid arguments, it is *wrong* and must be punished.
### The `swear` statement to state what you provide in return
If a good caller meets its obligations, the onus is thus on you to fulfill your end of the bargain. You can state the oaths that you promise to uphold using `swear`:
```python
def fib(n):
if n < 2:
result = n
else:
result = fib(n - 1) + fib(n - 2)# fib() never returns negative number.
swear result >= 0
return result
```If a function fails to uphold what it has sworn to do, it is *wrong* and must be punished.
### Unhandled exceptions
It goes without saying that any function that throws an exception which isn't caught is *wrong* and must be punished.
## Runtime vigilance
This is where Vigil sets itself apart from weaker languages that lack the courage of their convictions. When a Vigil program is executed, Vigil itself will monitor all oaths (implorations and swears) that have been made. If an oath is broken, the offending function (the caller in the case of `implore` and the callee in the case of `swear`) *will be duly punished.*
How?
**Simple: it will be deleted from your source code.**
The only way to ensure your program meets its requirements is to absolutely forbid code that fails to do so. With Vigil, this shall be done for you *automatically*. After enough runs, Vigil promises that all remaining code meets its oaths.
## Usage
Vigil is a command-line executable. Pass it the path to a file to run:
```
$ ./vigil example/hello.vg
```The "example" directory has some to get you started.
## FAQ
### Is this serious?
Eternal moral vigilance is no laughing matter.
### But isn't a language that deletes code crazy?
No, wanting to keep code that demonstrably has bugs *according to its own specifications* is crazy. What good could it possibly serve? It is corrupted and must be cleansed from your codebase.
Vigil will do this for you automatically.
### Vigil deleted a function. Won't that cause the functions that call it to fail?
It would seem that those functions appear to be corrupted as well. Run Vigil again and it will take care of that for you. Several invocations may be required to fully excise all bugs from your code.