Is D appropriate for creating a stable production app?

Burton Radons burton-radons at smocky.com
Fri Nov 10 10:28:18 PST 2006


mmcdermo wrote:
> Repost from "The old D" newsgroup
> Hello,
> I am curious as to what all of you, being involved with the development of
> some of the most fundamental parts of D's progression, have to say about
> whether D should be used in a certain situation.
> 
> My business is developing a web application primarily coded in PHP, and for
> performance reasons, many of the algorithms are to be made with a different
> language. Our team greatly favors PHP over other languages, as we all have
> grown accustomed to a method of creating applications with PHP that are
> extremely easy to maintain over time, take little time to code, and are not
> error-prone. However, we are also concerned very much so with performance, for
> the end user's sake and for our own (Higher application performance means less
> resources used, which ends up meaning more cash in our pocketbook), so we have
> a need to use a different language for certain aspects of our base-framework.

Yuck, that brings back some bad memories. For the period of about a year 
I was exclusively programming in Python, and inevitably in a project 
there was this creep where I'd have to move more and more Python code 
into completely unintelligible C (SWIG was very basic at the time). My 
tour-de-force was this massive class written in C that could be 
overloaded by classes in Python that would call methods overridden in 
Python written a few days after that feature (overloading classes, not 
calling overridden methods - that was my own special insanity) entered 
beta and if I left it alone for a week and came back to it, I would have 
no idea what it was doing. In fact, it was so difficult to understand 
that I would know what the line of code I was working on was doing, but 
the function it was contained within was a mystery.

It came to be that the majority of my time was maintaining and 
developing this layer, where I'd convert a few lines of Python into a 
few hundred lines of far faster C code, then spend ages trying to 
document it so that I could understand what the hell was going on 
afterwards.

You might think I'm being hyperbolic, but I swear that is exactly how it 
happened, and it was completely necessary: the nightmare class I 
described above doubled my frame rate.

Since then I've become convinced that there is no application where a 
scripting language makes sense, particularly when your compiler (dmd) is 
is as fast as or faster than a script compiler without requiring a 
hard-to-maintain layer telling one side how to work with the other. 
Everything you want to do with scripting can be done with D aside from 
making it safe, and I have my reasons for not giving a damn about making 
code safe.

> We are looking into a vast array of different languages at this point,
> analyzing the benefits and downsides of each. As none of us have very much
> experience with the D language (beyond reading some documentation and
> tutorials), I thought that a post here might help us learn more about the D
> language and how it pertains to our situation.
> 
> While analyzing different languages, we look for these qualities:
> 1) Stability and reliance
> 2) Performance
> 3) Ease of code maintenance
> 4) Ease of implementation
> 
> Languages that top our list right now are C and C++, but due to D's similarity
> to these languages and its improvements over both, I think it has a fair
> chance of coming out on top. But then, I'm not very familiar with the D
> language in the first place. Thus, I ask all of you D-Wizards for your input
> and recommendations here, and thank you for taking the time to read this post
> and maybe even taking the time to reply!

In my experience D is as productive to code in as Python (actually more 
so due to the many maintenance problems Python has), and the fragile 
import problems it used to have due to bugs in the compiler (it didn't 
like recursive imports) haven't shown themselves to me in over a year. 
This might be because I've gotten good at avoiding the bugs, but I think 
they're gone now.

One problem I can foresee is that you'll need to spend a lot of effort 
writing a tool to have the D code define the interface to the PHP code, 
as it's unlikely such a tool (like SWIG) already exists. Also, D's 
inherent garbage collectiveness can make such interfaces very problematic.

So instead I would recommend writing in D in the first place. It's 
slightly more difficult to output HTML, but when done properly (not with 
globals) is more robust. Aside from that, the need for main, and a less 
powerful standard library, moving to D from PHP should feel very 
natural. But there's no substitute to trying it yourself.



More information about the Digitalmars-d mailing list