From: Matthew Hicks on
> In comp.arch.fpga rickman <gnuarm(a)gmail.com> wrote: (snip)
>
>> People say that strong typing catches bugs, but I've never seen any
>> real proof of that. There are all sorts of anecdotal evidence, but
>> nothing concrete. Sure, wearing a seat belt helps to save lives, but
>> at what point do we draw the line? Should we have four point
>> harnesses, helmets, fireproof suits...?
>>
> Seatbelts may save lives, but statistically many other safety
> improvements don't. When people know that their car has air bags,
> they compensate and drive less safely. (Corner a little faster, etc.)
> Enough to mostly remove the life saving effect of the air bags.
>
> It does seem likely that people will let down their guard and code
> more sloppily knowing that the compiler will catch errors.
>
> One of my least favorite is the Java check on variable initialization.
> If the compiler can't be sure that it is initialized then it is
> a fatal compilation error. There are just too many cases that
> the compiler can't get right.

Sorry, but I have to call BS on this whole line og "logic". Unless you can
point to some studies that prove this, my experiences are contrary to your
assertions. I don't change the way I code when I code in Verilog vs. VHDL
or C vs. Java, the compiler just does a better job of catching my stupid
mistakes, allowing me to get things done faster.


---Matthew Hicks


From: David Brown on
On 15/04/2010 04:07, glen herrmannsfeldt wrote:
> In comp.arch.fpga rickman<gnuarm(a)gmail.com> wrote:
> (snip)
>
>> People say that strong typing catches bugs, but I've never seen any
>> real proof of that. There are all sorts of anecdotal evidence, but
>> nothing concrete. Sure, wearing a seat belt helps to save lives, but
>> at what point do we draw the line? Should we have four point
>> harnesses, helmets, fireproof suits...?
>

It is difficult to be concrete about these things, because it is so
dependent on the programmers involved. If you see strong typing as a
useful tool, and write your code accordingly, then you will write
clearer and neater code and therefore have fewer mistakes - and more of
these will be caught at compile time. If you see strong typing as a
pain that has to be worked around, you will write ugly code that will
have more mistakes than clearly written code in with a weak typed language.

The main thing is to write your code clearly, and to take advantage of
whatever typing mechanisms your tool supports - even if it doesn't check
them (for example, use typedefs and enums in C rather than "int", even
though the compiler treats them the same). You can write good code in
any language, and you certainly can write bad code in any language. But
it is easier to write good code if the language and tools make support it.

> Seatbelts may save lives, but statistically many other safety
> improvements don't. When people know that their car has air bags,
> they compensate and drive less safely. (Corner a little faster, etc.)
> Enough to mostly remove the life saving effect of the air bags.
>

It's a matter of understanding your tools. The big trouble with air
bags is that people think they don't need seatbelts because they have
air bags, without realising that they are designed to work together.

> It does seem likely that people will let down their guard and
> code more sloppily knowing that the compiler will catch errors.
>
> One of my least favorite is the Java check on variable initialization.
> If the compiler can't be sure that it is initialized then it is
> a fatal compilation error. There are just too many cases that
> the compiler can't get right.
>

I don't use Java, but my C compilers have similar checks. There are
very few circumstances that the compiler will get this wrong unless you
have written particularly convoluted code. The answer, of course, is to
avoid writing convoluted code.

Any checking mechanism has a risk of false positives and false negatives
- the compiler doesn't know everything the programmer knows. But you
work with the tool to give the compiler as much knowledge as you can,
and let it help check that as much as /it/ can.


From: Brian Drummond on
On Thu, 15 Apr 2010 10:32:43 +0200, David Brown
<david(a)westcontrol.removethisbit.com> wrote:

>On 15/04/2010 04:07, glen herrmannsfeldt wrote:
>> In comp.arch.fpga rickman<gnuarm(a)gmail.com> wrote:
>> (snip)
>>
>>> People say that strong typing catches bugs, but I've never seen any
>>> real proof of that. There are all sorts of anecdotal evidence, but
>>> nothing concrete. Sure, wearing a seat belt helps to save lives, but
>>> at what point do we draw the line? Should we have four point
>>> harnesses, helmets, fireproof suits...?

>The main thing is to write your code clearly, and to take advantage of
>whatever typing mechanisms your tool supports - even if it doesn't check
>them (for example, use typedefs and enums in C rather than "int", even
>though the compiler treats them the same). You can write good code in
>any language, and you certainly can write bad code in any language. But
>it is easier to write good code if the language and tools make support it.

Then (using enums as a simple example), strong typing can either catch
or eliminate errors that may not immediately be considered as type
errors.

Loop count errors or indexing off the end of an array, for example, are
usually type errors, since they use the range of a discrete subtype. In
C you have to build something complex and error prone, simply to
replicate "for i in my_enum'range loop ..." And remember to maintain it
whenever you add a value to the enum...

>
>Any checking mechanism has a risk of false positives and false negatives
>- the compiler doesn't know everything the programmer knows. But you
>work with the tool to give the compiler as much knowledge as you can,
>and let it help check that as much as /it/ can.
>
Agreed

- Brian
From: Patrick Maupin on
On Apr 15, 12:20 am, Matthew Hicks <mdhic...(a)uiuc.edu> wrote:
> > In comp.arch.fpga rickman <gnu...(a)gmail.com> wrote: (snip)
>
> >> People say that strong typing catches bugs, but I've never seen any
> >> real proof of that.  There are all sorts of anecdotal evidence, but
> >> nothing concrete.  Sure, wearing a seat belt helps to save lives, but
> >> at what point do we draw the line?  Should we have four point
> >> harnesses, helmets, fireproof suits...?
>
> > Seatbelts may save lives, but statistically many other safety
> > improvements don't.  When people know that their car has air bags,
> > they compensate and drive less safely.  (Corner a little faster, etc.)
> > Enough to mostly remove the life saving effect of the air bags.
>
> > It does seem likely that people will let down their guard and code
> > more sloppily knowing that the compiler will catch errors.
>
> > One of my least favorite is the Java check on variable initialization.
> > If the compiler can't be sure that it is initialized then it is
> > a fatal compilation error.  There are just too many cases that
> > the compiler can't get right.
>
> Sorry, but I have to call BS on this whole line og "logic".  Unless you can
> point to some studies that prove this, my experiences are contrary to your
> assertions.  I don't change the way I code when I code in Verilog vs. VHDL
> or C vs. Java, the compiler just does a better job of catching my stupid
> mistakes, allowing me to get things done faster.
>
> ---Matthew Hicks

From: Patrick Maupin on
On Apr 15, 12:20 am, Matthew Hicks <mdhic...(a)uiuc.edu> wrote:
> > In comp.arch.fpga rickman <gnu...(a)gmail.com> wrote: (snip)
>
> >> People say that strong typing catches bugs, but I've never seen any
> >> real proof of that.  There are all sorts of anecdotal evidence, but
> >> nothing concrete.  Sure, wearing a seat belt helps to save lives, but
> >> at what point do we draw the line?  Should we have four point
> >> harnesses, helmets, fireproof suits...?
>
> > Seatbelts may save lives, but statistically many other safety
> > improvements don't.  When people know that their car has air bags,
> > they compensate and drive less safely.  (Corner a little faster, etc.)
> > Enough to mostly remove the life saving effect of the air bags.
>
> > It does seem likely that people will let down their guard and code
> > more sloppily knowing that the compiler will catch errors.
>
> > One of my least favorite is the Java check on variable initialization.
> > If the compiler can't be sure that it is initialized then it is
> > a fatal compilation error.  There are just too many cases that
> > the compiler can't get right.
>
> Sorry, but I have to call BS on this whole line og "logic".  Unless you can
> point to some studies that prove this, my experiences are contrary to your
> assertions.  I don't change the way I code when I code in Verilog vs. VHDL
> or C vs. Java, the compiler just does a better job of catching my stupid
> mistakes, allowing me to get things done faster.

You can "call BS" all you want, but the fact that you don't change the
way you code in Verilog vs. VHDL or or C vs. Java indicates that your
experiences are antithetical to mine, so I have to discard your
datapoint.

Regards,
Pat