Undefined behaviour in C [was Re: The Cost of Dynamism]

Rustom Mody rustompmody at gmail.com
Sat Mar 26 01:30:06 EDT 2016


On Friday, March 25, 2016 at 9:20:23 PM UTC+5:30, Steven D'Aprano wrote:
> 
> Undefined behaviour in C is a minefield waiting to blow your program's legs
> off, because the designers of the language made the explicit choice that
> they wanted the language to be as fast and efficient as possible, even at
> the cost of safe, reproducible behaviour.

Thats a nice polemic Steven
Ive been guilty of similar... which Ive subsequently tried to correct:
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html

For one thing its good to remember that we wouldn't be here without python
Python wouldn't be what it is without CPython
And the C there is the C you are talking of.

More pertinently this polemic misses the real culprit -- intel hardware.
40 years ago Dijkstra pointed out that software costs are variable;
hardware costs are fixed.
this results in this that programmers will increasingly skip a test that is
very skew.  If that same super-skew test were taken care of by hardware we
(programmers) wouldn't mind. [1]

To see this consider overflow error for integers and for floats.
Intel hardware catches float errors in hardware but not int errors
So language designers have the hobson choice of catching errors at huge cost
Or ignoring and (inviting programmers to ) creating flaky systems.

[1] Economics/financial considerations drive more than we imagine
https://www.facebook.com/EvolvePolitics/videos/1666350230283584/



More information about the Python-list mailing list