const?? When and why? This is ugly!

bearophile bearophileHUGS at lycos.com
Wed Mar 4 06:46:26 PST 2009


Lutger:

>When you say 'not that many bugs', how often does you code compile with errors?<

I am not able to give you a good answer, I am sorry, so I can just chat a little.
What I can tell you is that I now know both Python and D (I know Python more, but my experience of D is getting sufficient), and I am usually able to write correct programs in quite less time in Python. "correct programs" includes unit tests, debugging, global testing, etc too. It's not easy to tell when a program is "debugged enough", it's an art.
To write a "correct" program in C I need even more time and sometimes at the end I am not sure yet the program is debugged enough (despite I know C for far more time than D). This is what I care of.


>Because every compile time error you encounter is a bug in a dynamic language, and within that perspective I think it's quite a lot.<

The situation isn't so linear. In Python I often don't put many bugs in the first place, because syntax and semantics is less bug prone or more flexible, etc.
In Python I have the shell, where I can try out single lines of code or whole functions, that helps both in writing correct code and in debugging it (and later you can even copy&paste such interactive sessions, with small changes, to use them as doctests).


>Now, that doesn't mean dynamic languages are more bug prone, just that the way you program with them is different. Different enough that you can't compare type systems of static and dynamic languages that easily.<

I agree. Yet, I have often written the same small programs in both D and Python so I can compare the whole programming time, how much long they are, how much reliable they are, etc. I have adopted in my D coding some of the good practices I have developed in Python (regarding unit testing, functional-style programming, using higher-level functions, using templates to make more flexible functions), and the results seems good enough :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list