comp.lang.ada
 help / color / mirror / Atom feed
From: Paul Rubin <no.email@nospam.invalid>
Subject: Re: Introductory Presentations, especially aimed at C++ programmers!
Date: Thu, 08 Dec 2016 17:30:01 -0800
Date: 2016-12-08T17:30:01-08:00	[thread overview]
Message-ID: <87mvg551pi.fsf@nightsong.com> (raw)
In-Reply-To: 0ad2eb12-421f-4159-8df2-5bf7e0dddf06@googlegroups.com

Maciej Sobczak <see.my.homepage@gmail.com> writes:
> How? Your unit test contains the checks for proper program outcome, 

This type of thing wouldn't show up in unit tests, since the bug was
from a mismatch between behaviours of two separate units.  But it could
show up during whole-system testing.

> Let's say I made a bug that overflows the array under some
> specific conditions, but my "private workflow" for testing does not
> involve input that overflows that array. This error will go to
> release, no matter what is the programming language.

Let's say you write the program in C, and you do make such a bug.
Assigning arbitrary probabilities to possible outcomes, let's say:

 1) with 40% likelihood, your test inputs don't encounter the bug, so
    you don't detect the bug, and you ship the buggy code.
 2) with 30% likelihood, the test input encounters the bug and the
    program crashes.  You find and fix the bug before shipping.
 3) with 30% likelihood, the test input encounters the bug, but the
    program keeps running with no observable misbehaviour (you've
    written outside the array bounds in a way that doesn't break
    anything for that particular input).  You don't notice the bug
    so you ship the buggy code.

So you have 70% chance of shipping the buggy code.  With Ada and
subscript checks, you eliminate possibility #3, so it becomes 40% #1 and
60% #2.  You aren't guaranteed to fix the bug before shipping, but your
chances of doing so have nearly doubled.  Sounds like a win to me.

>> I think the claim was that it's impossible for humans to stop making
>> silly errors in general
> Agreed. But the argument was that Ada would prevent humans from making
> such errors, which is (yet) an unfounded claim.

I think the claim is that Ada prevents a certain class of silly errors,
not that it eliminates all silly errors.  If you write the code in
assembler, there might be 100 places where you could go wrong.  If you
write it in C, you get control structures, named variables, etc. so that
might eliminate 50 of the 100 possible error sites.  With Ada you get a
serious type system, much more runtime checks, etc., so that might
eliminate another 30.  It's possible (say with SPARK) to eliminate even
more, but never all 100, and it gets harder and harder as you push
closer to machine-checked perfection.

> Of course, there are errors that can be detected at compile-time and
> there are some that are even prevented by the grammar itself -
> arguably Ada is stronger in this area than C (or C++), but buffer
> overflows are not, at least directly, in this category.

I would say that C++ is stronger in this area than Ada, since it has
dynamically sized strings in the STL container library.  You'd use those
instead of fixed-size buffers, so there's no way to overflow except OOM.
The main cost becomes non-deterministic timing from the dynamic
allocation, making STL strings unsuitable for realtime control.  But
since we're talking about a desktop application, it's ok to use them.


  reply	other threads:[~2016-12-09  1:30 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10 12:24 Introductory Presentations, especially aimed at C++ programmers! John McCabe
2009-07-10 21:49 ` jimmaureenrogers
2009-07-10 23:37   ` wwilson
2009-07-11  0:07     ` jimmaureenrogers
2009-07-12  4:00       ` wwilson
2009-07-11  8:15 ` Stephen Leake
2009-07-15  6:43 ` Jean-Pierre Rosen
2016-12-07 17:06 ` john
2016-12-07 17:44   ` Luke A. Guest
2016-12-07 18:35     ` Jeffrey R. Carter
2016-12-07 23:03       ` Randy Brukardt
2016-12-07 23:47         ` Jeffrey R. Carter
2016-12-08  0:08           ` Paul Rubin
2016-12-09 22:01             ` Randy Brukardt
2016-12-09 22:18               ` Jeffrey R. Carter
2016-12-13  0:53                 ` Randy Brukardt
2016-12-13  3:21                   ` Jeffrey R. Carter
2016-12-13 21:15                     ` Robert A Duff
2016-12-13 22:05                       ` Jeffrey R. Carter
2016-12-13 22:52                         ` Robert A Duff
2016-12-14  0:02                           ` Jeffrey R. Carter
2016-12-13 23:05                         ` Randy Brukardt
2016-12-14  0:13                           ` Jeffrey R. Carter
2016-12-14 22:48                             ` Randy Brukardt
2016-12-15  0:00                               ` Jeffrey R. Carter
2016-12-15 10:46                                 ` Maciej Sobczak
2016-12-16  7:37                                   ` Paul Rubin
2016-12-15 20:14                                 ` Niklas Holsti
2016-12-15 20:27                                   ` Jeffrey R. Carter
2016-12-15 21:04                                     ` Niklas Holsti
2016-12-15 21:40                                       ` Jeffrey R. Carter
2016-12-16  7:41                                     ` Paul Rubin
2016-12-13 22:50                     ` Randy Brukardt
2016-12-14  0:08                       ` Jeffrey R. Carter
2016-12-14  1:01                         ` Shark8
2016-12-08  8:08           ` Maciej Sobczak
2016-12-08  8:38             ` Dmitry A. Kazakov
2016-12-08 10:25             ` Paul Rubin
2016-12-08 13:39               ` Maciej Sobczak
2016-12-09  1:30                 ` Paul Rubin [this message]
2016-12-09  8:31                   ` J-P. Rosen
2016-12-09  8:58                     ` Paul Rubin
2016-12-09  9:18                       ` J-P. Rosen
2016-12-09  9:27                         ` Paul Rubin
2016-12-09 10:49                           ` J-P. Rosen
2016-12-09 19:58                             ` Jeffrey R. Carter
2016-12-09  8:35                   ` G.B.
2016-12-09  8:57                     ` Paul Rubin
2016-12-09 22:15                     ` Randy Brukardt
2016-12-09 21:58           ` Randy Brukardt
2016-12-08  8:23     ` Maciej Sobczak
2016-12-08 18:54   ` Adam Jensen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox