A proper language comparison...
bearophile
bearophileHUGS at lycos.com
Thu Jul 25 13:28:52 PDT 2013
Peter Alexander:
> - What's safe and unsafe is very subjective.
There are large bodies of people that count bugs in code, and
correlate them with coding practices. They have created language
subsets like C for automotive industry, C++ for aviation, code
for space missions, Ada language and its successive refinements
like Ada2012, SPARK subset of Ada. There are lot of people trying
sideways solutions, at Microsoft (Spec#, Liquid typing, etc),
dependent typing (ATS language), and so on and on, even Haskell
variants. Lot of this stuff is not based on statistical data, but
there is also some hard data that has shaped some of those very
strict coding guidelines. There are several serious studies in
the field of coding safety. Dismissing all that decades old work
with a 'very subjective' is unjust.
As usual D code safety is mostly correlated to the coding style
you are using, how you write your unittests and code contracts,
how much good are your code reviews, how much careful your
programmers are, etc. But the language design is also a factor.
To me D safety looks about intermediate between C and Ada-SPARK.
D code normally has undetected integral overflows, it doesn't
help a lot against null pointers (Nullable is not so good yet),
there is no significant stack overflow protection, no
variable-sized stack-allocated arrays that help a bit created
bounded collections, the management of reference escaping is
planned but not yet implemented (scope), and so on. Overall to me
D coding seems significantly safer than C coding, and perhaps
it's a little safer than C++11 coding too. I know no studies
about the safety of D code compared to C++11 code or Ada2012
code, or compared to other languages.
Bye,
bearophile
More information about the Digitalmars-d
mailing list