Revamping associative arrays

bearophile bearophileHUGS at lycos.com
Sun Oct 18 15:01:51 PDT 2009


Denis Koroskin:

>Why would you want to port C code to D, if you can easily interface with it?<

First of all you have to consider programmer experience, they know C, so keeping the language backwards compatible with C helps them avoid bugs and learn D faster.
If you ignore what programmers know, and you assume an easy interface between a new language and C, then you don't need to design a language like C++/D, that keeps lot of little compatibility with C, you are more free, and you can avoid warts like the design of C switch().

I have ported some thousands of lines of C code to D. Surely there are situations where keeping a large amount of C code is the best thing do to, and saves you lot of time and work.

But other times you may want to port the C code. Some of the reasons you may have to port C code to D:
- because I like the look of D code more than D code;
- because the original C code may be so old and ugly that keeping it in my project hurts my aesthetic sense;
- gives me more safety than certain C code;
- allows me to use a GC that may be safer than the original manual memory management;
- because I may use my dlibs and shorten the original C code. Less code is usually a good thing;
- because I will probably need to change and improve the code and I prefer to do it on D code that's nicer and allows me to program in a faster way;
- because I use bud to compile small D projects and in them adding a C dependency requires more time than translating 20 lines of C code and adding it into an already existing D module;
- because I am creating some pure D library, to keep things simpler and tidy.
- I'd even like to see the official D2 compiler to be written in D1/D2 (and a little of assembly).

Bye,
bearophile



More information about the Digitalmars-d mailing list