Have language researchers gotten it all wrong?

bearophile bearophileHUGS at lycos.com
Sun Jul 5 16:04:31 PDT 2009


Walter Bright:
> Certainly, this is a very interesting topic for D's development.
> http://www.reddit.com/r/programming/comments/8yeb0/cacm_almost_the_entire_software_community_has/

Two comments about this topic:

Having a compiler able to catch more bugs is really useful. The less-bug prone nature of D programs compared to C ones is probably one of the most important selling points of D for me. But in such field D is not doing enough yet, there are many other situations where D may catch bugs, like in: stack overflow protection, run-time integer overflow, some region/zone pointer analysis to catch low-level pointer-related bugs (because if you never use pointers then it's better to just use Mono C# instead of D), bugs caused by missing break in switch, missing type controls of printf (because printf is used in D programs too), some safer C std lib functions (because D programs sometimes use C stdlib functions, especially in C code ported to D), some integral promotions/conversions (I have for the third time a bug in a D program caused to automatic conversion to uint), and remove most or all undefined corner-cases of C (like the order of execution of sub-expressions in function calls, etc. Java shows that all such traps can be removed from the language, yet Java is nowdays very fast, sometimes faster than D).

People can talk all they want about the advantages of 'classic' static typing, but sometimes they are wrong. I've programmed in static typed languages most of my time, yet if I write a small but complex (~300-lines long) Python program I am usually able to make it run correctly in a short enough time, shorter than the time to write the same (buggy) program in D, and in the end such D program may even not work correctly and I may lose interest in finding the bug. In some situations this isn't caused by my ignorance of D, or by limits of my brain, or by my laziness, but by the intrinsic less bug-prone nature of Python compared to D programs that use pointers a bit. So while I like to program in D a lot, I don't agree with people that say that 'classic' static typing is able to avoid more bugs. On the other hand, if you refer to the modern type systems of languages like Haskell, then their type system is probably able to actually give you some help to write more correct programs. But in languages with a primitive\simple type system as Java (and D) having a static type system isn't so important in reducing bugs in my small programs.

Bye,
bearophile



More information about the Digitalmars-d mailing list