<div class="gmail_quote">On Tue, May 22, 2012 at 3:57 AM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On 2012-05-21 21:48, Andrew Wiley wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Gee, thanks for your enthusiastic support for GSOC projects that will<br>
greatly forward the D ecosystem.<br>
<br>
Ultimately, what's useful to the D community (for reasons discussed in<br>
these NGs many times over) is that we have working, mature, feature-rich<br>
IDEs. The languages they're implemented in are mostly irrelevant, and in<br>
MonoDevelop's case, trying to add language support via a plugin written<br>
in D to an IDE written in C# would be silly. Would you extend Eclipse in<br>
C++? It just doesn't make any sense at all.<br>
</blockquote>
<br></div>
I see no reason why the compiler can't be implemented in D and have a C interface.</blockquote><div><br></div><div>Certainly possible, but we'll need to keep a bootstrap compiler around.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What's more, building tools for D in languages other than D can be<br>
extremely useful. Every time a discussion for a D compiler written in D<br>
comes up, no one really likes to mention the benefits we've gotten from<br>
having a compiler written in C++:<br>
</blockquote>
<br></div>
Again as above.<div class="im"><br></div></blockquote><div><br></div><div>I never said a compiler couldn't be implemented in D. I said implementing it in C++ has given us advantages that no one generally considers.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  - there are no bootstrapping problems because C++ exists on basically<br>
every platform D would ever want to target<br>
</blockquote>
<br></div>
Provide a C backend.</blockquote><div><br></div><div>Not if you want good codegen. Implementing it in C would disable many high level optimizations and force a single implementation for low level concepts that should vary across implementations. I can pull some relevant discussions from the GCC mailing list if you're interested.</div>

<div><br></div><div>Ultimately, I think fixing what few platform-specific bugs remain on GDC is a much better alternative. I can't speak to how well LDC does on other platforms as I haven't touched it in a while, primarily because it doesn't run on Windows as far as I know.</div>

<div><br></div><div>As for the argument that targeting C would be more portable, we get the same benefit by using GCC or LLVM as a backend, so I don't really see the improvement.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  - GDC and LDC were built without reimplementing the entire compiler<br>
and exist on platforms DMD doesn't support<br>
</blockquote>
<br></div>
Just provide a C interface.</blockquote><div><br></div><div>You could pull that off for LDC (although it would make bootstrapping very difficult, as discussed), see below for GCC.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  - GDC can be formally added to GCC without the aforementioned<br>
reimplementation of the compiler<br>
</blockquote>
<br></div>
That's a good point. I actually don't know what they would think about that.</blockquote><div><br></div><div>They wouldn't accept it. Period.</div><div>The only requirement to build GCC is a working C compiler on some platform somewhere. From there, you can bootstrap and cross compile to get to any platform you want. They're not going to give that up.</div>

<div><br></div><div><br></div><div>As for the more general discussion of building a compiler-as-a-library in D, I agree that it would be tremendously useful, but I don't think it's quite the holy grail it first appears to be. For tools written in D, it could be tied right in, but on any VM platform, I question whether using a D library directly is actually feasible. Building a VM<->Native interoperability layer is simple enough when you're just calling the library to perform simple tasks, but we're talking about a library that would primarily be responsible for creating and updating large data structures (namely, the AST). Tying that into a VM language would be very difficult to do efficiently because you'd either make a lot of VM->Native function calls or convert the entire AST back and forth from native to VM-land. It gets even more fun because you'd have to maintain a C-API on the native side as well as a JNI layer (or what Mono/CLI uses) and all the wrapper code in the VM language.</div>

<div>Ultimately, it may be simpler just to port the library to the language of the actual platform. I suppose even that would probably be an improvement.</div></div><br>