News for hackers. Stuff that matters.
Re:The Power of Ten – Rules for Developing Safety Critical Code by kowdermeister on Thursday July 14, 2016 @08:42AM (#12093216)
If I grasp that right, it says that if something is provable mathematically, then you can write a program for it with an equal meaning.

I still don't see how that prevents user error. My question is then how do you mathematically prove intent?

Also, how far should "sufficiently advanced" be?

We already have a tool for that in the forms of unit tests and types does help if the subject is abstract enough.

Re:The Power of Ten – Rules for Developing Safety Critical Code by oconnore on Thursday July 14, 2016 @10:29AM (#12094078)
You can't prove intent.

However, you can consider the formal specification of your intent (the type), to be an example of fully declarative programming.

Since you write your type without any care about how it might be executed -- the holy grail of abstraction -- you are less likely to make errors.

When using a type system that isn't capable of fully specifying what you're doing (i.e. Haskell), you are of course subject to making implementation errors within the range of possible programs that type check. But in practice it's usually enough to catch the sorts of mistakes that you're likely to make.

Re:The Power of Ten – Rules for Developing Safety Critical Code by pron on Thursday July 14, 2016 @01:50PM (#12095899)
> However, you can consider the formal specification of your intent (the type), to be an example of fully declarative programming.

The vast majority of formal specification and verification tools (I believe Coq and Agda are the only exceptions, and they are rarely used in the industry) express the intent directly in logic rather than in the types (HOL in Isabelle and HOL Light, ZFC+LTL in TLA+ and maybe Scade, ZFC in Alloy, and a typed set theory in SPARK, I believe).

> But in practice it's usually enough to catch the sorts of mistakes that you're likely to make.

I think this claim is supported by little evidence. Most non-dependent type systems are extremely weak (or require cumbersome encoding) to express even all but the most trivial of properties (e.g. they can't even express that the value returned from a max function is indeed maximal, let alone more elaborate properties). Their expressive strength is that of a finite-state machine. How much does that prevent real bugs requires empirical study.

Re:The Power of Ten – Rules for Developing Safety Critical Code by smaddox on Thursday July 14, 2016 @12:03PM (#12094956)
You need more than an advanced type system. You need a declarative constraint solving and proof system. Instead of telling the compiler how to perform a task, you would declare the assumptions and the desired relationships and then, with the help of the proof system, determine what implementation fullfills exactly those constraints.
Re:The Power of Ten – Rules for Developing Safety Critical Code by sfifs on Thursday July 14, 2016 @02:02PM (#12095987)
Or you take the more practical Monte Carlo like approach - Ie Fuzzing
Re:The Power of Ten – Rules for Developing Safety Critical Code by icen on Thursday July 14, 2016 @08:54AM (#12093290)
An expressive and ergonomic type system goes a very long way into codifying that intent.

For example, it's quite obvious what the intent of this Idris function is: `f : Vect n (Vect m a) -> Vect m (Vect n a)` (where `Vect` is the type of lists of a given length).