Slashdot Mirror


High Integrity Software

Jack Ganssle writes "High Integrity Software: the title alone got me interested in this book by John Barnes. Subtitled "The SPARK Approach to Safety and Security," the book is a description of the SPARK programming language's syntax and rationale. The very first page quotes C.A.R Hoare's famous and profound statement:'There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.' This meme has always rung true, and is one measure I use when looking at the quality of code. It's the basis of the SPARK philosophy." Read on for more of Ganssle's review of the book, and some more on the SPARK language. High Integrity Software author John Barnes pages 448 publisher Addison-Wesley rating 8 reviewer Jack Ganssle ISBN 0321136160 summary The book describes a language that insures programs are inherently correct.

What is SPARK? It's a language, a subset of Ada that will run on any Ada compiler, with extensions that automated tools can analyze to prove the correctness of programs. As the author says in his Preface, "I would like my programs to work without spending ages debugging the wretched things." SPARK is designed to minimize debugging time (which averages 50% of a project's duration in most cases).

SPARK relies on Ada's idea of "programming by contract," which separates the ability to describe a software interface (the contract) from its implementation (the code). This permits each to be compiled and analyzed separately.

It specifically attempts to insure the program is correct as built, in contrast to modern Agile methods which stress cranking a lot of code fast and then making it work via testing. Though Agility is appealing in some areas, I believe that, especially for safety critical system, focus on careful design and implementation beats a code-centric view hands down.

SPARK mandates adding numerous instrumentation constructs to the code for the sake of analysis. An example from the book:

Procedure Add(X: In Integer);

--#global in out Total;

--#post Total=Total~ + X;

--#pre X > 0;

The procedure definition statement is pure Ada, but the following three statements SPARK-specific tags. The first tells the analysis tool that the only global used is Total, and that it's both an input and output variable. The next tag tells the tool how the procedure will use and modify Total. Finally a precondition is specified for the passed argument X.

Wow! Sounds like a TON of work! Not only do we have to write all of the normal code, we're also constructing an almost parallel pseudo-execution stream for the analysis tool. But isn't this what we do (much more crudely) when building unit tests? In effect we're putting the system specification into the code, in a clear manner that the tool can use to automatically check against the code. What a powerful and interesting idea!

And it's similar to some approaches we already use, like strong typing and function prototyping (though God knows C mandates nothing and encourages any level of software anarchy).

There's no dynamic memory usage in SPARK -- not that malloc() is inherently evil, but because use of those sorts of constructs can't be automatically analyzed. SPARK's philosophy is one of provable correctness. Again -- WOW!

SPARK isn't perfect, of course. It's possible for a code terrorist to cheat the language, defining, for instance, that all globals are used everywhere as in and out parameters. A good program of code inspections would serve as a valuable deterrent to lazy abuse. And it is very wordy; in some cases the excess of instrumentation seems to make the software less readable. Yet SPARK is still concise compared to, say, the specifications document. Where C allows a starkness that makes code incomprehensible, SPARK lies in a domain between absolute computerese and some level of embedded specification.

The book has some flaws: it assumes the reader knows Ada, or can at least stumble through the language. That's not a valid assumption any more. And I'd like to see real-life examples of SPARK's successes, though there's more info on that at www.sparkada.com.

I found myself making hundreds of comments and annotations in the book, underlining powerful points and turning down corners of pages I wanted to reread and think about more deeply.

A great deal of the book covers SPARK's syntax and the use of the automated analysis tools. If you're not planning to actually use the language, your eyes may glaze over in these chapters. But Part 1 of the tome, the first 80 pages which describes the philosophy and fundamentals of the language and the tools, is breathtaking. I'd love to see Mr. Barnes publish just this section as a manifesto of sorts, a document for advocates of great software to rally around. For I fear the real issue facing software development today is a focus on code ueber alles, versus creating provably correct code from the outset.

You can purchase High Integrity Software from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, carefully read the book review guidelines, then visit the submission page.

3 of 238 comments (clear)

  1. Re:What does "on the spoke" mean? by Mz6 · · Score: 0, Offtopic

    Perhaps... here?

    --
    Hmmm.
  2. Re:Car Whores? by happyfrogcow · · Score: 0, Offtopic

    I thought car whores are the girl who pose for all the car magazines. Or the ones that sleep with the guy with the coolest car.

    i ride the subway, who do i get to sleep with? (eeewwwwwww, i don't want to know)

  3. Talk about integrity by stoneaxe+coming · · Score: 0, Offtopic

    I posted my venture Rocket, Ship and Highway on eBay yesterday trying to raise capital for my 3 tech projects. It was my astonishment that I received from ukinvestigations@ebay.com the following:

    We regret to inform you that your eBay account has been suspended due to concerns we have for the safety and integrity of the eBay community.

    As we state in the User Agreement, Section 8, we may immediately issue a warning, suspend, or terminate your membership and refuse to provide our services to you if we believe that your actions may cause legal liability for you, our users or us. We may also take these actions if you have breached the User Agreement or if we are unable to verify or authenticate any information you provide to us.

    Due to the suspension of this account, please note that you are prohibited from using eBay in any way. This includes the registering of a new account.

    Please note that this suspension does not relieve you of your obligation to pay any fees you may currently owe to eBay.

    Regards,

    eBay Trust and Safety

    I am an honest person with integrity. I have not stolen and capitalised on other people's ideas. They were all genuinely created by me and the venture was deemed by me as fair to potential investors.
    eBay even allowed a lesbian to sell her virginity on their site (that made them literally a pimp, excuse me), but they won't let a decent entrepreneur raise capital through their web-site. There are other business plans listed in that category of eBay and mine should be the best. Combined with what I have encountered in the past 3 years for the projects, it is my judgement that there is a depicable war out there. And people at eBay have become war criminals (or more precisely Nazis, I know) themselves.

    Note: A same message was delivered to this forum anonymously by mistake.