
DigitalMars C/C++ Compiler - tomcam
https://github.com/DigitalMars/Compiler/tree/master/dm/src/dmc
======
WalterBright
Note that the compiler is fully open source using the Boost license.

If you want to build it, you'll need to download the C++ binary from
digitalmars.com, and the D compiler from dlang.org.

~~~
exikyut
This is absolutely awesome. Until now, the DM C/C++ compiler was closed-source
freeware, with contracting/consulting available
([https://digitalmars.com/consulting.html](https://digitalmars.com/consulting.html)).
This makes things 10x as amazing :)

Also related is that D is now completely under the Boost license as well.

Historically D was "partially open, partially closed"; the D frontend (syntax
parser and some other pipeline stages) was open, but the backend/code-
generator was built on top of the Zortech C++ compiler for DOS/Windows/OS/2\.
(I only have a hazy notion of the Datalight>Zorland>Zortech>Symantec
transition; I'll bet the story would make for an awesome history book, if that
doesn't already exist. _Hint_ )

There was (highly appropriate) major fanfare when Symantec, who bought Zortech
in Aug 1991, allowed the compiler backend technology to be open-sourced in
April 2017, 1 year and 1 month ago:
[https://news.ycombinator.com/item?id=14060846](https://news.ycombinator.com/item?id=14060846)

And that, fairly clearly, is what made this source release possible. Also
[https://news.ycombinator.com/item?id=17131274](https://news.ycombinator.com/item?id=17131274)
:)

References (most insightful first):

\-
[http://www.edm2.com/index.php/Zortech_C%2B%2B](http://www.edm2.com/index.php/Zortech_C%2B%2B)

\-
[https://en.wikipedia.org/wiki/Digital_Mars](https://en.wikipedia.org/wiki/Digital_Mars)

\-
[http://www.computinghistory.org.uk/det/10940/Zortech%20C/](http://www.computinghistory.org.uk/det/10940/Zortech%20C/)

\-
[http://www.edm2.com/index.php/Symantec_C%2B%2B](http://www.edm2.com/index.php/Symantec_C%2B%2B)

------
Rexxar
Apparently, the compiler is progressively rewritten in d. For those
interested, there is a tag for the last pure c version:
[https://github.com/DigitalMars/Compiler/tree/Last-C-
Version](https://github.com/DigitalMars/Compiler/tree/Last-C-Version)

Would probably be interesting to convert it in C++17 :-)

Meta-comment: I delete my previous comment by error and want to put it again,
and didn't manage to do it again. Is there some anti-duplication code that
prevent to write 2 times the same comment on HN?

~~~
WalterBright
> Apparently, the compiler is progressively rewritten in d.

Can confirm, that's what I'm doing. Most of the code is written in an old-
fashioned style, but rather than redo that, it's more productive to convert to
D, and then into a modern style.

The D conversion as it stands is by rote translation, thereby retaining the
technical debt. I don't plan on improving the structure until it is all in D.

~~~
cjhanks
If I may ask, why did you opt to port the code in that order (translate -> re-
architect)? I suspect you have experience in this, and I was curious what
experience taught you.

Edit: Answered below in "May it have been better to start from scratch?"

~~~
oblio
Not Walter Bright, but I'm pretty sure it minimizes the chances for new bugs.
You do a dumb conversion that tries to minimize the actual code changes, check
that works ok, then start making larger changes.

[https://www.joelonsoftware.com/2002/01/23/rub-a-dub-
dub/](https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/)

> 1\. No New Features, not even small ones, would be added.

> 2\. At any time, with any check in, the code would still work perfectly.

> 3\. All I would do is logical transformations — the kinds of things that are
> almost mechanical and which you can convince yourself immediately will not
> change the behavior of the code.

------
0x00000000
Automated Teller ATM Machine

If you are also confused by the title, DMC = DigitalMars Compiler. It is a
C/C++ compiler which seems to be almost completely written by one person

[https://en.wikipedia.org/wiki/Digital_Mars](https://en.wikipedia.org/wiki/Digital_Mars)

~~~
stochastic_monk
He is also the only person who has ever written an entire C++ compiler on
their own, in addition to the first direct-from-C++ compiler. Cfront was a
transpiler.

~~~
JdeBP
I suspect that both Tom Pennello and Chris Lattner would also qualify by your
criteria.

~~~
stochastic_monk
Chris Lattner as the primary builder of LLVM deserves enormous credit for that
work. Did he really write the entire C++ compiler himself?

I haven't been able to find much on Tom Pennello besides some parsing papers
from the 70s... I'm interested, but don't know how to find more about his
work.

~~~
JdeBP
One name to look for is MetaWare.

------
WalterBright
Walter here. AMA.

~~~
greenhouse_gas
How does it feel having your "life's work"[1] becoming big enough to be
noticed, but ignored by the mainstream?

You created the first "better C" out there to get any traction, it had a
perfect name (B -> C -> D), but due to factors that were partially [2] outside
your control [3], D's niche got eaten by Go and Rust.

[1]. The D programming language. [2]. I've seen people blaming the D to D2.0
transition, but D was a niche language before too. I've also seen people blame
D for not having an Open Source compiler for years, but neither did Java, and
it took off anyways. [3]. Such as Sun's marketing, or the general push to
scripting languages between 1995-2010 (such as perl, tcl, PHP, Ruby, Python
and Node)

~~~
WalterBright
When I started, I was well aware of:

"Certainty of death. Small chance of success. What are we waiting for?"

[https://www.youtube.com/watch?v=8joT0oFuGoI](https://www.youtube.com/watch?v=8joT0oFuGoI)

For a language without a megacorp pushing it, D is spectacularly successful.
Consider:

1\. It's developed by volunteers who work on it for the joy of it without
remuneration.

2\. People who spend the effort to get past the learning curve find it very
pleasing and productive.

3\. Other major languages have been continuously copying D's features :-)

4\. Corporations that have adopted it for mission critical use have told me
that D is their "secret weapon" that allows them to out-maneuver and out-
innovate their competitors.

It's like the music business - you don't have to be the Beatles to have a very
good career.

~~~
thawkins
Walter, I have been using your products way back since before Zortech, at the
time it was the only C++ system that I could get to work with the Phar Lap DOS
extender to create big binaries.

Thank you for all your hard work, your products formed the center on my early
career, and most of what i know i learned using your tools.

Note I particularly loved "Zed" the text editor that came with the early
toolchain.

Regards Tim Hawkins, a grateful hacker.

~~~
WalterBright
Welcs!

------
tux1968
Hasn't had a release since 2013, but the Github code is still getting updates
as recently as the last few weeks. It appears to be written in a mix of itself
and D. Wasn't clear to me how you would go about bootstrapping it.

~~~
WalterBright
Download DMC and DMD, and you should be good to go.

------
vzaliva
I was scratching my head how I never heard of DMC++ until I realized that this
is related to Zortech C++ compiler I've used (and loved) while ago.

------
yuhong
I have been asking for them to fix the license on Open Watcom for a while now.
A C compiler that has full support for x86 segmentation would be very useful
for some projects.

~~~
WalterBright
You've got that with DMC today.

------
mathieubordere
Why should I favor this compiler instead of gcc or clang?

~~~
exikyut
It was the first 3rd party compiler for Windows (1.0)

It's apparently really nice to use (I'm on Linux :( )

It was written by one person

It targets DOS, Windows and OS/2 (mostly Win32)

~~~
WalterBright
For a while it was the only C++ compiler for Windows. (I had figured out how
to do all the various weird stack frame variations Windows required.) We sold
a lot of those :-)

~~~
exikyut
Interesting to know.

------
ivanfon
What’s the use case for this compared to gcc or clang?

------
jbb67
What C and C++ standard versions does this support?

~~~
jfultz
There doesn't appear to have been an official release of the compiler since
8.57, announced on August 8, 2013.

[https://forum.dlang.org/group/c++.announce](https://forum.dlang.org/group/c++.announce)

I can't find anything about what changed between 8.52 and 8.57. But in 8.52,
there wasn't even support for C++03, which the DMC site self-reports:

[https://digitalmars.com/ctg/CPP0x-Language-
Implementation.ht...](https://digitalmars.com/ctg/CPP0x-Language-
Implementation.html)

cppreference maintains a compiler support grid for features in the C++11 and
later standards, which includes DMC 8.52 and mentions a small number of
supported features.

[http://en.cppreference.com/w/cpp/compiler_support](http://en.cppreference.com/w/cpp/compiler_support)

Here's a post on the DMC forum from 2015 which seems to agree that C++11
support is generally not there.

[https://forum.dlang.org/thread/dbmsmttdbpfjsuhrhpkd@forum.dl...](https://forum.dlang.org/thread/dbmsmttdbpfjsuhrhpkd@forum.dlang.org)

