Giter Site home page Giter Site logo

vigil's Introduction

Vigil is a very safe programming language, and an entry in the January 2013 PLT Games competition.

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 are 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:

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:

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 to absolutely forbid code that fails to do so. With Vigil, it will do this 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.

vigil's People

Contributors

munificent avatar nahakiole avatar zeveisenberg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.