8 ms·
What is the benefit of having multiple compilers for programming languages? Is there a scenario where a GCC compiled rust program would do something that an LLV
by faisal_ksa 4y ago
What is the benefit of having multiple compilers for programming languages? Is there a scenario where a GCC compiled rust program would do something that an LLVM one can't do?
Doesn't this cause fragmentation in the rust ecosystem?
P.S.:I understand that people can work on any project they want. And I don't have the right to tell them not to. I'm just curious about the technical reasons for having multiple compilers.
- tsimionescu 4y agoIt helps ensure that the language standard is relevant, and it can help separate the standard committee from the compiler developers, helping bring in more interest groups to the table (since they're not entirely beholden to a single compiler dev team).
- davidatbu 4y agoThis is answered in various replies to other comments.
- zetaposter 4y ago1. GCC has more backends than LLVM. 2. Competition is good in general. 3. I expect this will trigger inconsistencies between GCC and rustc; because Rust doesn't really have a specification. Which will force both parties to discuss and solve them.
- faisal_ksa 4y agoThank you so much. The specification point is very important
- israrkhan 4y agoand to back up your point... There should be at least 2 implementations for anything to be a spec/standard.
- tomjakubowski 4y agoBeing on gcc, a long-lived platform, also helps ensure the survival of the language even if development of the current compiler (or LLVM) dies or withers.
- duckerude 4y agoDoes it? GCC's Java frontend died and is no longer shipped, they need maintainers like any other compiler.
- genewitch 4y agoGCJ is no more? It was being used within recent memory for things, i thought. I am out of the loop though, so if this is true, that's interesting and a bit weird.
- pjmlp 4y agoSince 2009 actually. Most contributors eventually moved into OpenJDK after it became available. GCC folks left it around for a couple of years, because GCJ unit tests exercised parts of the compiler no one else did. Eventually they decided it wasn't worth that maintenance cost to keep it around only for that purpose.
- apple4ever 4y agoGCC support of Objective-C is very very poor.
- netheril96 4y ago> I expect this will trigger inconsistencies between GCC and rustc; because Rust doesn't really have a specification. Which will force both parties to discuss and solve them. More likely that GCC has to follow all the bugs and quirks of rustc or no people will use GCC for Rust.
- nickitolas 4y ago> 1. GCC has more backends than LLVM Did you mean target platforms? If so, how is this not already addressed by the rustc gcc (Via libgccjit) backend?
- daptaq 4y agoDoesn't GCC support more architectures than LLVM? Wasn't that the issue a while back with the Rust dependency that a cryptography module for Python introduced?
- ATsch 4y agoAdding a GCC backend for Rust (rust-codegen-gcc) does this already. I do not personally see the point of writing another frontend in C++.
- pjmlp 4y agoDependency on an existing Rust compiler during GCC bootstrap process.
- ATsch 4y agoYou already need an existing C++ compiler to bootstrap GCC though I don't see how this is much different. Plus there is already mrustc as a C++ Rust implementatation specifically designed for bootstrapping.
- pjmlp 4y agoIt is one more dependency, not written in C++, and you don't see the difference?
- sicp-enjoyer 4y agoOne advantage is it forces the language to articulate standards instead of the implementation defining the feature set. Standards tend to give stability and longevity to the language, as well as making it possible to write new compilers and make it more portable.
- charcircuit 4y agoThat sounds a little circular. The benefit of alternate compilers is that it makes making alternate compilers easier. For stability compilers already have a large incentive not to break old programs. For longevity I don't really see how a standard affects it that much. For being more portable you do not need an entirely knew compiler.
- trimir2022 4y agoBeing able to specify a language outside an implementation is extremely useful to prevent hidden logical inconsistencies between different parts of the language, and makes the language more robust. It also allows people to design new backends (looking at CUDA LLVM backends)by finding out the right abstraction to support performance. For example, implementing a C or C++ compatible CUDA backend required the C++ committee to make changes to the memory model / consistency guarantees of C++ atomics. If C or C++ had only depended on compiler implementation for it, then there would have just been different implementations with different guarantees with no consistencies between them, and no single way to even define why they were different.
- pjmlp 4y agoActually it was the other way around, CUDA was fixed to follow C++11 memory model. There are a couple of CppCon talks on the subject.
- trimir2022 4y agoPartially correct, even now, SG1 in C++ fixes a lot of things in C++ specification to allow for CUDA like approaches.
- msla 4y agoThere's also political/legal considerations: The modern GCC codebase is derived from the egcs codebase, which forked off the original GCC codebase because the developers of GCC at that time didn't want to prioritize faster development speed: https://gcc.gnu.org/wiki/History https://gcc.gnu.org/wiki/History Thus, a new strain of development can attract people who want to do things differently, and reduce tensions all around. On the legal front, it's unlikely, but sometimes there's legal problems with continuing to use a certain codebase.
- shadowofneptune 4y agoRight now Rust often limits what it does to what is supported by LLVM. An example is the become statement. This is a reserved keyword which will eventually act as a jump to a function without saving a return address, the current stack frame becomes a new one. This is tricky since things like deconstructors need to still work. It is only recently that LLVM supported this well, and Clang did it first. Separate implementations and having a standard or some other form of communicatiom between implementers can help with these delays. EDIT: Clang's version is the attribute 'musttail,' if anyone is interested.
- samatman 4y agoA language with one implementation can't really be said to have a specification. It may have a very detailed accompanying technical documentation of what the implementation is supposed to do, this may be called a specification, but a specification deserves the name with a minimum of two implementations.
- FrankHB 4y agoThis is technically incorrect. A programming language can be designed with specification in mind, even with a formal one (e.g. SML). It is just true that the specification is not likely effectively verified before more than one real implementations landed, if it is not formally verified. (Anyway, verification by testing of existing implementations _is_ the fallback where people cannot afford the cost of formal methods.)
- marcodiego 4y agoIt instantly inherits support for all OS's and architectures GCC support plus a lot of optimizations and debug information.
- maxwell86 4y agoRust already has a GCC backend that can do all that. This post is about a new front-end.
- zokier 4y agoOne big benefit in this case is that bootstrapping gcc is somewhat easier than rustc, and presumably gcc-rust can then be used to compile rustc if needed.
- smolder 4y agoIn addition to what others have said, since there is a plan to introduce Rust kernel modules into the Linux kernel, being able to compile with GCC helps avoid dependence on another toolchain, which was something I've seen mentioned as a concern w.r.t. Rust in the kernel.
- steveklabnik 4y agoTo be clear, while it's a concern some people on the internet have expressed, it's not an actual problem for landing the current work to get Rust in as a framework for writing drivers.
- avgcorrection 4y agoHaving to nominal competitors makes everything good. Like Pepsi/Coke, Republicans/Democrats.
- thrown_22 4y ago>What is the benefit of having multiple compilers for programming languages? Rust will need a standard. The main reason why I don't take it seriously is that code written 5 years ago will often not compile today. For a language that pretends to be a systems language that is a non-starter. If you can't guarantee a 40 year shelf life of your code then no one working on systems cares. People working on systems in the wild don't have the brain power to learn a new tool chain every decade, let alone every year. They are solving real problems and not writing blog posts.
- rightbyte 4y agoWe are still arguing whether to bump the C standard from 89 to 99 where I work. I kinda like the pacing with C. Or as Wikipedia puts it: "C17 addresses defects in C11 without introducing new language features."
- pjmlp 4y agoHopefully you won't have K&R C by the time you adopt C23 then.
- steveklabnik 4y ago> code written 5 years ago will often not compile today. citation needed. Yes, there's a few programs that relied on unsound things for which this is true, but that's a relatively small part of the overall amount of code.
- School-Cotton 4y agoDoesn’t every implementation of a new function on a standard type possibly break existing code? For example if I have a trait Foo with a function bar, and I impl Foo for HashMap, and then a new version of std comes out that has named something HashMap::bar, now every call to my_map.bar() is ambiguous
- steveklabnik 4y ago
- topspin 4y ago> What is the benefit of having multiple compilers for programming languages? I'll give you one, or two, depending on what you'd like to count. At some point in the conceivable future we'll be able to compile some meaningful Rust code base with both compilers and measure; a.) how long it takes to compile and b.) the performance of the compiled code. Obviously that will induce what it always has: incentive to improve.