News for hackers. Stuff that matters.
Re:Mrustc: a Rust compiler written in C++ by CUViper on Thursday September 21, 2017 @05:35PM (#15307565)
By not self-hosting in Rust, it should be easier to bootstrap on a new target. C++ is ubiquitous -- what other language would you choose?
Re:Mrustc: a Rust compiler written in C++ by fyrerise on Thursday September 21, 2017 @05:44PM (#15307627)
> what other language would you choose?

As far as I can tell the goal of the project isn't to target more platforms (Rust targets quite a few by way of LLVM), so I don't think I'd choose any other language, including C++.

Having a compiler and standard library written in the language that it compiles has some huge benefits for increasing the pool of possible contributors.

Re:Mrustc: a Rust compiler written in C++ by kibwen on Thursday September 21, 2017 @06:03PM (#15307742)
> As far as I can tell the goal of the project isn't to target more platforms (Rust targets quite a few by way of LLVM)

There appears to be an attempt to leverage this project to target ESP8266, which AFAIK LLVM does not support: https://github.com/emosenkis/esp-rs

Re:Mrustc: a Rust compiler written in C++ by kbenson on Thursday September 21, 2017 @07:34PM (#15308190)
Interesting. Along with with your other comment about the borrow checker, I guess you could develop using (or occasionally check against) the rustc compiler for borrow checker correctness, and deploy using mrustc. That's pretty cool.
Re:Mrustc: a Rust compiler written in C++ by tatterdemalion on Thursday September 21, 2017 @06:31PM (#15307901)
> Having a compiler and standard library written in the language that it compiles has some huge benefits for increasing the pool of possible contributors.

But this isn't the official compiler, this is someone's personal project?

Re:Mrustc: a Rust compiler written in C++ by fyrerise on Thursday September 21, 2017 @09:30PM (#15308759)
> But this isn't the official compiler, this is someone's personal project?

True, but compilers are complicated machines and Rust is still changing at a fairly frantic rate.

The author seems to be doing quite a good job of development today, but if it has any hope of staying current, it probably needs to think about how to increase its bus factor (something happens like changing jobs, starting a family, or they just become interested in something else, and a single person suddenly has less time to contribute).

Re:Mrustc: a Rust compiler written in C++ by steveklabnik on Thursday September 21, 2017 @10:16PM (#15308951)
rust is changing, but in a backwards compatible way. That said the standard library aggressively makes use of new features, so the challenge isn't the language, but compiling libstd.
Re:Mrustc: a Rust compiler written in C++ by tmzt on Friday September 22, 2017 @09:04AM (#15311769)
Could rustc have a way to output desugared code or code targeting a specific epoch with new features like generators expand to a backwards compatible form. This might allow for preprocessed source that could be compiled by something like mrustc even if it doesn't implement every single RFC?
Re:Mrustc: a Rust compiler written in C++ by steveklabnik on Friday September 22, 2017 @10:26AM (#15312448)
That's sort of MIR, but we have no intentions of stabilizing it any time soon, if ever.
Re:Mrustc: a Rust compiler written in C++ by tmzt on Friday September 22, 2017 @03:31PM (#15315044)
Yes, but I mean outputing actual Rust source but with generators or async/await expanded into calls to Futures. Similar to how Go is now bootstrapped from a down-level compiler.
Re:Mrustc: a Rust compiler written in C++ by steveklabnik on Friday September 22, 2017 @08:17PM (#15317174)
Yeah, I get it. But that's what I mean; MIR is the common sub-language that's the same across epochs.

I don't think there's any real plans for a source-based approach. But epochs can only change a limited amount of things for exactly this reason; they minimize the compiler burden of supporting them.

Re:Mrustc: a Rust compiler written in C++ by yjftsjthsd-h on Thursday September 21, 2017 @05:43PM (#15307620)
If bootstrapping/portability is the goal, probably C.
Re:Mrustc: a Rust compiler written in C++ by damnstraight on Thursday September 21, 2017 @06:16PM (#15307816)
Conveniently there are already C++ compilers bootstrappable with C.
Re:Mrustc: a Rust compiler written in C++ by tavert on Thursday September 21, 2017 @07:16PM (#15308115)
Any that are both open-source and C++11 compliant? Guess you can still build g++-4.6 with just C, then a newer g++ from that, but it's a bit of a pain.
Re:Mrustc: a Rust compiler written in C++ by xioxox on Thursday September 21, 2017 @11:32PM (#15309220)
If the goal is to break the dependency cycle, a higher level language like Python would make development much easier. C++ is powerful, but not as rapid to develop in.
Re:Mrustc: a Rust compiler written in C++ by xioxox on Friday September 22, 2017 @03:24AM (#15310071)
Why the downvotes?

It's clearly easier to make a compiler in a higher level language (Python is just an example, but Lisps are suited to this kind of thing). For example, text parsing is easier in Perl/Ruby/Python/Swift/etc. As someone who knows C++, more thought is required to do the same thing as in a higher level language, although it runs much faster. If you just wanted to bootstrap the compiler, then you'd choose the easiest route to that. It could also be easier to read and understand than a C++ compiler.

Re:Mrustc: a Rust compiler written in C++ by pjmlp on Friday September 22, 2017 @01:00AM (#15309492)
Ada, for example.

There is an open source version available in every system supported by gcc.

However C++17 is quite safe, provided one doesn't follow "write C with C++ compiler" idiom.

Re:Mrustc: a Rust compiler written in C++ by pcwalton on Friday September 22, 2017 @01:50AM (#15309697)
> However C++17 is quite safe, provided one doesn't follow "write C with C++ compiler" idiom.

No, it's not. There is no use-after-free protection among other things. It doesn't matter how much you write code like C or not: it's just not safe.

Re:Mrustc: a Rust compiler written in C++ by pjmlp on Friday September 22, 2017 @02:33AM (#15309855)
Then better stop using LLVM on Rust.

Until then, those comments only annoy those of us that happen to like Rust, but don't find it mature enough to replace C++ on the use cases we happen to care about.

Re:Mrustc: a Rust compiler written in C++ by pcwalton on Friday September 22, 2017 @03:21AM (#15310055)
I didn't say you can't write useful software in C++. I said that C++ software is not, in general, memory safe. Sometimes the benefits of a particular piece of software (for example, having an excellent production-grade optimizer) outweigh its drawbacks (for example, not being memory-safe).

I don't think you'd find a single LLVM developer who would claim that LLVM is memory safe. Giving invalid IR to LLVM and not running the verifier frequently segfaults it, for example...

Re:Mrustc: a Rust compiler written in C++ by pjmlp on Friday September 22, 2017 @04:02AM (#15310208)
I do agree with that, but that is exactly why I always mention the "C with C++ compiler" idiom, which is usually followed by your remark.
Re:Mrustc: a Rust compiler written in C++ by rtpg on Friday September 22, 2017 @02:05AM (#15309750)
safety is a spectrum, I think declaring it unsafe entirely might not be conducive to more interesting points