6 ms·
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/Compi
by Rexxar 8y ago
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 8y ago> 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.
- giancarlostoro 8y agoThis is great, are there some intended goals for having a C++ compiler written in pure D after you've started to improve the structure? I'm thinking of things like the faster C++ preprocessor that was done for Facebook in D (was it Warp?) and similar improvements to C++ through D. Thanks for all your awesome hard work by the way!
- WalterBright 8y agoI don't really have any scathingly brilliant goals for the D version, other than inspiring others to make use of it. I still maintain it, it'll be much easier to maintain in D, and not much work to convert it to DasBetterC. Yes, it was Warp: https://github.com/facebookarchive/warp https://github.com/facebookarchive/warp https://code.facebook.com/posts/476987592402291/under-the-hood-warp-a-fast-c-and-c-preprocessor/ https://code.facebook.com/posts/476987592402291/under-the-ho... You're welcome! It's reactions like yours that make it worthwhile.
- AlexeyBrin 8y agoThanks for your hard work. Can you please add, if you have time, a few lines (the commands required) for building the compiler from source ?
- WalterBright 8y agomake clean make scppn
- AlexeyBrin 8y agoThanks, I've installed DMD and DMC, when I try to build the compiler I get a compilation error: .\code.d(16): Error: module `cc` is in file 'ddmd\backend\cc.d' which cannot be read
- WalterBright 8y agoSeems I haven't tried to build it from the github in a while. code.d was missing from the makefile command to update github. Fixed.
- AlexeyBrin 8y agoPrevious error is now fixed. New error: dmd -c -betterC -noboundscheck -mv=dmd.backend=. -mv=tk=tk -version=SCPP -O -release -inline dt.d -ofdth.obj dt.d(36): Error: TypeInfo cannot be used with -betterC --- errorlevel 1 --- errorlevel 1
- sigzero 8y agoThere are probably better ways to do this.
- WalterBright 8y agoHmm, looks like you're using the latest dmd. I've been using 2.074. I suggest switching to 2.074, or wait until I get it working properly with the latest dmd.
- cjhanks 8y agoIf 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 8y agoNot 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.
- userbinator 8y agoMost 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. I'm not sure what exactly you have in mind for "modern style", but I found the code as it is to be quite readable and a breath of fresh air from a lot of other code I've heard referred to as "modern" (which seems to mostly mean laboriously long identifiers, excessive amounts of abstraction, and CamelCaseScreamingAtYouEverywhere.)
- WalterBright 8y agoExcessive use of global state, poor encapsulation, leaky abstractions, generally clumsy code. It is bad enough that I considered not open sourcing it for fear of damage to my career :-) but then decided what the hell. The good thing about the DMC++ source code is, it works. You can make anything work if you invest enough effort into it.
- dvfjsdhgfv 8y agoThank you so much, Walter, for creating such a great language! I'm now coding mostly in D, and it's a joy to use. It's expressive and powerful, but at the same time really fast. I regret not giving it a chance earlier.
- WalterBright 8y agoGlad it's working for ya!