5 ms·
Indeed, but I think they should first create a standard?
by pca006132 4y ago
Indeed, but I think they should first create a standard?
- rob74 4y agoIf not a standard, then at least a specification. This discussion is from 2020, so I'm not sure if it's still up to date: https://users.rust-lang.org/t/where-is-the-rust-language-specification/42047 https://users.rust-lang.org/t/where-is-the-rust-language-spe... "For the most part though, rustc itself is the spec" - so, for implementing the GCC frontend, read the current LLVM frontend really carefully and do everything the same way? And try to keep up with all the changes which will inevitably happen in the LLVM frontend while you are implementing the GCC frontend?
- b3morales 4y agoIntegration-style tests are a good tool here. Given a set of programs in the target language with certain expected behavior on the reference compiler, you check that compiling and running with the second compiler produces the same behavior.
- steveklabnik 4y ago> so, for implementing the GCC frontend, read the current LLVM frontend really carefully and do everything the same way? At a high level, this is correct: https://github.com/Rust-GCC/gccrs/wiki/Frequently-Asked-Questions#what-is-the-plan-for-inconsistencies-in-behaviour https://github.com/Rust-GCC/gccrs/wiki/Frequently-Asked-Ques... > If gccrs interprets a program differently from rustc, this is considered a bug. I don't believe they are only reading the frontend, but using the reference first, then looking to the implementation second, and asking a lot of questions along the way.
- Alghranokk 4y agoRust already has stable standards. There's Rust editions 2015 (1.0), 2018 (1.31.0), and 2021 (1.56.0).
- wging 4y agoUnfortunately that's not quite the same thing as a standard in the sense that is meant here. A 'standard' is a written document that explains how the language should work. A standard that just says "the compiler is correct if it compiles code the way that rustc 1.xy does" is technically unambiguous in that it provides a procedure by which a compiler author can check their work, but leaves quite a bit on the table and is probably the wrong goal to aim at in the long term, even if it enables forward progress for now. (For example, we know rustc contains bugs; do we want gcc-rust to include all the bugs, or should it differ from rustc in that respect? Which behaviors are bugs, which are undesired but accepted quirks of the language, and which are intentional? For that matter, it's unreasonable to expect gcc-rust to produce binaries that are byte-for-byte identical, so what other mechanism should be used to determine equivalence?) (btw, there's also https://doc.rust-lang.org/reference/ https://doc.rust-lang.org/reference/)
- thesuperbigfrog 4y agoCorrect. With an ideal standard document that describes the language, someone could build a compiler for the language from scratch and it should behave correctly. See https://en.wikipedia.org/wiki/Programming_language_specification https://en.wikipedia.org/wiki/Programming_language_specifica... Some example standards: C: https://www.open-std.org/jtc1/sc22/wg14/ https://www.open-std.org/jtc1/sc22/wg14/ ECMAScript (Javascript): https://tc39.es/ecma262/ https://tc39.es/ecma262/ C++: https://isocpp.org/std/the-standard https://isocpp.org/std/the-standard Scheme: https://schemers.org/Documents/Standards/ https://schemers.org/Documents/Standards/ Ada: http://www.ada-auth.org/standards/ada12_w_tc1.html http://www.ada-auth.org/standards/ada12_w_tc1.html For Rust, Ferrous Systems is working on the Ferrocene Language Specification to formally document the Rust subset that Ferrocene will use. https://ferrous-systems.com/blog/ferrocene-language-specification/ https://ferrous-systems.com/blog/ferrocene-language-specific... https://ferrous-systems.com/ferrocene/ https://ferrous-systems.com/ferrocene/
- pornel 4y agoThere are various reference documents for Rust, but how do you know if they're complete and accurate without creating a working interoperable implementation? ISO will stamp any fantasy like OOXML, but that doesn't mean the standard is useful.
- int_19h 4y agoHaving another implementation first actually helps create a good standard, by highlighting things that are implementation-specific assumptions.