Making D better than other programming languages (warning: rant, drivel)

LaggedOnUser laggedOnUser at gmail.com
Sat Oct 28 10:27:55 PDT 2006


Hello, D users.  I have been following the progress of the D programming language with some interest.  It has a nice, clean syntax and seems to be an
improvement in various ways over C, C++, and Java, and is a worthy successor to them.  I would like to offer some ideas based on my general experience
with programming and research into programming languages that might help improve D and make it better than its alternatives.  These are just ideas; I
am an ordinary work-a-day programmer and not an uber-leet hacker so I really couldn't implement these suggestions myself.  Nor could I hope to ever
match Walter Bright's decades of experience in quality compiler design and implementation.  Nonetheless, here are a few points for you all to consider.

It is claimed on the D site that DMD offers the same programming productivity benefits as Ruby.  Based on several typical research projects into
programming language productivity, I find that claim to be very likely false.  (Of course, the specific claim, "Is DMD as productive as Ruby?" has not
been tested, still I can offer some generalizations).  My opinion is derived from considering the following research:

* http://www.theadvisors.com/langcomparison.htm - This site is a nearly exhaustive comparison of programming languages that includes C, C++, Java, and
Perl, among others.  It rates their productivity level as follows:

C - 2.5
C++ - 6.0
Java - 6.0
Perl - 15.0

Notice that C++ and Java are rated exactly the same in terms of productivity, whereas Perl, a typical scripting language, seems to offer roughly twice
the productivity.  This is born out by actual tests, including the following sites.
* http://www.codinghorror.com/blog/archives/000365.html
* http://doi.ieeecomputersociety.org/10.1109/2.876288

The best metric for productivity across languages appears to be Lines of Code (LOC).  The productivity for a typical programmer is inversely
proportional to the number of lines of code he/she has to write.

A comparison of the four most popular script languages at the Programming Language Shootout site (PHP, Python, Perl and Ruby) shows that all of the
most popular web scripting languages are roughly equal in lines of code, and are thus likely to be about equally productive.
* http://dada.perl.it/shootout/

This too is borne out by the actual studies cited above, that showed no significant difference between Python and Perl.  This is rather surprising,
since Perl is somewhat out-of-favor nowadays due to is rather cryptic syntax but Python is considered to be tops in productivity (or Ruby if you
prefer).  The fact that there appears to be no significant difference seems to imply that the superficial syntactic differences between Python and Perl
are not really productivity drivers, but something else is raising them to the same level of productivity.  That "something else" is probably the fact
that both are essentially dynamically-typed, easy-to-use, scripting languages that are terse and expressive.

In that regard, DMD is far more similar to C/C++/Java, than it is to PHP/Python/Perl/Ruby.
- DMD is statically typed and compiled, not dynamically typed.  I know, it can be run as a script, but that doesn't change the syntax, so that probably
doesn't increase coding productivity.
- DMD is probably no more terse or expressive than Java enough to make a difference

After all, if moving from C++ to Java seems to provide no productivity gain, then how much could one really gain by moving from Java to DMD?  Perhaps
not enough to make a difference.

Another problem in general with programming languages and environments, in my opinion, is that they pay insufficient attention to usability
engineering.  They simply don't take an evidence-based, quantitative approach to language design, rather relying on "intuition" about what works, which
is often overhyped and fallible.  The claims about object-oriented software productivity are quite overhyped, for example, and studies don't bear that
out either.

Another limitation of languages is that they don't scale very well.  If you learn a web scripting language, it is not compiled or compilable, therefore
one cannot translate that application into a different environment such as desktop app programming.  This burdens the programmer with learning a number
of niche languages to do different jobs.

Based on these and other considerations, here are my recommendations for improving Digital Mars D and making it competitive/superior to other languages:

1. Pay attention to the evidence of research studies into programming language productivity and usability and apply them to Digital Mars D where
applicable, rather than mere intuition or hype.  It would be better if you were able to back up claims about the language with actual facts or
research.  To this end, Digital Mars could possibly offer itself as a subject for academic study/research.

2. Increase the "scalability" or "portability" of Digital Mars to the scripting world.  I know, there is DMDScript, but that is not what I'm talking
about.  The problem with DMDScript is that it is really ECMAScript, so the user of ECMAScript has to learn a brand new language.  It would be better if
there were one DMD language that scaled all the way from interactive programming (like Python/Ruby), to dynamically-typed web scripting (like
PHP/Perl/etc), to browser-scripting (like ECMAScript), to GUI programming, to in-browser GUI development (like Java), etc.  Having a compatible syntax
for all these different tasks would make D far more scalable and portable as the "one language I need for my programming department to learn".  Such a
language could go from easy-to-learn scripting for noobs up to professional statically-typed compiled language within the same exact syntactic
framework.  This is rather like the way Mercury builds on top of Prolog, if you've ever studied those languages.

3. Provide a richer library with a large vocabulary of built-ins so that programmers don't have to re-invent the wheel.

I would sum up the benefits of these proposals versus current languages as follows:
- C/C++/Java: not compiled, not scripted, hype-driven, bug-prone
- PHP/Perl/Python/Ruby: not compiled, not browser-scripting languages, they're constantly tweaking the syntax and making it backward-incompatible
without a thought for research or evidence into improving it
- Visual Basic/C#: Java wannabees and Microcruft clones
- Insert name of your favorite language here: <index to well-aimed put-down>

These proposals are intended to be practical and not too difficult to implement.  They do not involve radically changing the DMD syntax, but merely
offering different, more simplified versions that scale up to the original, about which I cannot think of any significant improvements since it is
already perfect.  :-)

LaggedOnUser
--
Power to D people.



More information about the Digitalmars-d mailing list