Live data from Hacker News

Vigil: A programming language with eternal moral vigilance

github.com

51–60 of 120 posts

Re: Vigil: A programming language with eternal moral vigilance

#51

The underlying idea here is a contract system, first pioneered by Bertrand Meyer in the programming language Eiffel[1] and then augmented with the ability to describe higher-order functions by Robby Findler[2]. PLT also strongly advocated the use of blame with contracts -- the ability to blame the responsible party (function) when a contract fails. My Masters thesis under Robby Findler was on guided random testing us…

> I should note that an ordinary > contract system does not delete your code...

Much to my dismay.

Re: Vigil: A programming language with eternal moral vigilance

#52
Punished code deserves to be shamed and be made an example of. Vigil should make an image with the deleted code, such as it cannot be copy pasted and has to be rewritten in shame.

This idea seems actually quite awesome for a competition. Its truly a dungeon-crawler of programming.

Suggested extra hard-mode for short competitions: deletes all code.

Re: Vigil: A programming language with eternal moral vigilance

#53

You know, I don't think this is a half bad idea. I mean, deleting offending code is a bit much, but shouldn't a code-by-contract language not allow code that failed a contract to be compiled until it changes? That would seem to make sense.

To explicate this, it would make sense that when you pass a source file to the compiler, it would:

1. Parse the code into an AST (to strip away any pre-parse differences, like formatting or syntactic sugar usage), then hash that AST (recursively--replace any non-primitive function references with hashes of their own current ASTs)

2. Run unit tests, fuzz, etc--taking the AST hashes of each function of the testing code as well (though using symbolic, rather than "hard", references to the implementation-code, so it can change without making the test's hash change)

3. If a piece of code fails a test, add the pair (test AST hash, code AST hash) to some database (preferably an online, global database).

4. From then on, before anything is allowed to be compiled, perform a lookup in said database, and refuse to compile anything if the database finds any known (test, failed code) pairs in your code.

---

The interesting thing is that this system is very conservative--if a piece of code depended on by the code you wrote changes, then your code is given another chance (because maybe your code was just failing because it was expecting something of that other code, and that other code was wrong, and then it was fixed.)

Likewise, if you change the requirements, your code must be re-evaluated for conformance--code shouldn't be barred because it fails a "wrong test" like assert_equal(add_two_plus_two(), 5);.

But on the other hand, if you add tests, the old barrings based on previous tests stay in effect as well--this actually incentivizes breaking unit tests into small, orthogonal functions that pass or fail separately.

I don't think there would actually be any problem doing real development under this "restriction". In practice, given the way we currently do software engineering, it would only catch problems within your own project that had been seen+caught before--because those would be the only tests you had included.

In theory, though, you could also import, say, a global "test set"--basically, AST hashes for every test of the current stable branch of all major open source projects, or something similar--and check your code against that as well, just in case you happened to write, say, an incorrect date-handling function that someone else had ever written in an AST-identical way.

Re: Vigil: A programming language with eternal moral vigilance

#54

Supposedly an unreleased version of the GHC Haskell compiler had this feature first: https://twitter.com/bos31337/status/116372971509121025

GHC Haskell compiler = Glasgow Haskell Compiler Haskell compiler

You're not supposed to expand all those acronyms that mostly serve as names, you know.

Re: Vigil: A programming language with eternal moral vigilance

#56
post #50

Earlier quoted context omitted.

How will functions learn to stay in line if the compiler doesn't make an example every now and then? On a serious note, what you're thinking of is contracts, like so[0] [0] http://disnetdev.com/contracts.coffee/

projects like this are why coffeescript needs to support macros. There are so many coffeescript dialects out there that make minor changes to the language to accomodate one or two extra features, e.g. IcedCoffee. I don't want to have to use a separate, presumably less well supported language for this kind of stuff, just let me plug it in!

> The golden rule of CoffeeScript is: "It's just JavaScript"[0]

Macros would be deviating from core JS too much to fit with CoffeeScript's goal. Just happens that the compiler is nicely hackable to allow for these projects.

Not to say I object to the idea of an expanded CoffeeScript, just that it should be a fork.

[0] http://coffeescript.org/

Re: Vigil: A programming language with eternal moral vigilance

#57

Punished code deserves to be shamed and be made an example of. Vigil should make an image with the deleted code, such as it cannot be copy pasted and has to be rewritten in shame. This idea seems actually quite awesome for a competition. Its truly a dungeon-crawler of programming. Suggested extra hard-mode for short competitions: deletes all code.

It should also upload the image to imgur or some such site.

Re: Vigil: A programming language with eternal moral vigilance

#58
post #46
post #37

Earlier quoted context omitted.

This compiler would probably delete all the code. See http://blog.regehr.org/archives/761

I think that website is confused about undefined behavior, they accuse LLVM and GCC of "executing undefined behavior" for the minimal empty-main C99 program because the default headers included in the compiler have UB code in them. But only user code is required to be well-formed and have defined behavior, system headers could just as well be written in Forth as long as the actual behavior under the compiler they com…

> But only user code is required to be well-formed and have defined behavior, system headers could just as well be written in Forth as long as the actual behavior under the compiler they come with is correct.

To understand this better, realize that, ultimately, a standard is a contract. A standard says, in part, "If you refrain from doing these things, the system promises to do these things and not do these other things here."

"Undefined behavior", then, is invoked by code that strays from the standard by doing things the standard makes no guarantees about, like casting a value of type pointer-to-double to type pointer-to-char and dereferencing the result; the behavior of the compiler and the code the compiler emits is then undefined, which is to say its behavior is not guaranteed by the standard.

And, yes, a conformant C compiler is perfectly within its rights to delete code that it can tell invokes undefined behavior.

Re: Vigil: A programming language with eternal moral vigilance

#60
I rather enjoyed reading about the language, but was a bit disappointed that they made no attempt at static analysis, especially with such a rich set of assertions that the language enforces. I'd really like to see my entire program get deleted at compile-time rather than having to run it a bunch of times to delete all the faulty nested function calls one at a time.
Post reply on HN