16 ms·
MiniRust
- tb131 4y agoI wonder how this fits in with the whole trademark "panic"... [1] but considering they're part of the rust-lang org on GitHub, I'm guessing that issue would have been brought up by now. [1]: Living with the Rust trademark [LWN.net] https://lwn.net/Articles/901816/ https://lwn.net/Articles/901816/
- kibwen 4y agoRalf is the head of the official Rust team tasked with specifying Rust's operational semantics, so as far as trademark usage this is approximately as official as it gets (keeping in mind that the project in the OP is still just an experiment, and not any sort of stable or normative document).
- ralfj 4y agoIt's certainly not official, so please don't take all the choices MiniRust makes as being anyone's opinion but mine -- but we're working towards having something official like it. :)
- GRBLDeveloped 4y agoAnyone able to explain to me the significance of this? Read the article and ReadME but I don't understand its use case particularly well or why this has shot to the top of the front page
- gavinray 4y agoSame here, I read "specification" but the "syntax.md" seems unfinished and there are no examples of this being used, even "could-be" examples
- mjw1007 4y agoThis is one small piece of the work that's going to need doing to get Rust properly described. It's not "useful" in the sense of being something that you'd actually run. This is a start on the lowest layer of the description, describing the "abstract machine" that runs Rust programs; it assumes that all borrow-checking and type-checking has already been done, generics have been expanded, and so on. The other two big pieces that will need doing are properly describing the type system, and properly describing how the high-level features that aren't strictly necessary can be "lowered" into simpler forms. In the last year there's been some real work on the first of those under the name "A MIR Formality": https://nikomatsakis.github.io/a-mir-formality/docs/intro https://nikomatsakis.github.io/a-mir-formality/docs/intro Maybe the existing Rust Reference will turn into the second.
- adsharma 4y ago> It's not "useful" in the sense of being something that you'd actually run. What if we could actually run it (stay with me for a second) with a well known interpreter such as python3 or v8? That is the direction py2many has taken. Trying to define a small subset of python + missing rust features (pattern matching as an expression), interfacing with formal verification methods such as z3 and then finally building a transpiler to transpile this language to rust.
- ralfj 4y agoMy goal is that we can actually run it, but that would still only be useful for the following things: - Testing the spec itself - Ensuring that a more production-grade interpreter like Miri has the same semantics as the spec it claims to implement It's not intended that unsafe Rust authors would ever run the MiniRust interpreter; if they want something like that, they should run Miri instead. They might still read the MiniRust interpreter sources to figure out what the heck Miri is doing.
- mappu 4y agoNQP is also a similar project from the Perl world, a subset of the language that's simpler to implement and has clearer edge-cases.
- ralfj 4y agoIf you are writing unsafe Rust code and want to be sure that your code is following the rules of the language, then this is an important steps towards giving you a sufficiently precise description of those rules that you can use for this purpose. If you are writing a Rust compiler or a Rust verification tool, then a spec like MiniRust is a key part of telling you whether you got it right. If you are not doing either of these things then you probably don't have a use-case for MiniRust. :)
- kibwen 4y agoThe readme has a more direct explanation of this project's objective: "MiniRust is the cornerstone of my vision for a normative specification of Rust semantics. It is an idealized MIR-like language with the purpose of serving as a "core language" of Rust. This is part of a larger story whose goal is to precisely specify the operational behavior of Rust, i.e., the possible behaviors that a Rust program might have when being executed: the behavior of a Rust program is defined by first translating it to MiniRust (which is outside the scope of this repository), and then considering the possible behaviors of the MiniRust program as specified in this document. That translation does a lot of work; for example, traits and pattern matching are basically gone on the level of MiniRust. On the other hand, MiniRust is concerned a lot with details such as the exact evaluation order, data representations, and precisely what is and is not Undefined Behavior." It is yet another step on the path to having a Rust specification, especially with respect to precisely specifying the capabilities and requirements of `unsafe` code.
- rst 4y agoIt's one of a few ongoing efforts along these lines -- at least the Ferrocene spec is also worthy of attention: https://ferrous-systems.com/blog/the-ferrocene-language-specification-is-here/ https://ferrous-systems.com/blog/the-ferrocene-language-spec...
- ralfj 4y agoI compare MiniRust and Ferrocene at https://github.com/RalfJung/minirust#what-about-the-ferrocene-language-specification https://github.com/RalfJung/minirust#what-about-the-ferrocen.... :) TL;DR they re quite different in style, precision, and scope.
- deleted 4y ago[deleted]
- j-pb 4y agoAwesome! Rusts ad-hoc "the compiler is the specification" has always been a huge turnoff for me, and a huge hurdle when learning the language. The language is just too complex and the compiler is too large and smart/magical to really get what's going on from ad-hoc alone. Zig is also very compiler dependent, but at least the language has direct enough translation as a goal, that it's straightforward to learn the semantics from trial and error alone.
- jasonpeacock 4y agoC was invented in 1972 and became one of the most widely used languages in the world with "the compiler is the specification" - and there were many different compiler implementations too. It wasn't standardized until 1989 - 17 years later! I think Rust will do just fine, and the compiler error message is (IMO) the best of any language, making adhoc exploration possible. Can you imagine trying to explore C from ad-hoc alone based on its compiler errors?!
- jjtheblunt 4y agoThere was the original K&R Book on C, though, the one which was about 100 pages, was super clear, and i believe gave compilers a common idea of what is normal. I wish i still had my late 80s copy.
- tialaramex 4y agoThe first edition of K&R is 221 pages, so roughly double what you remember.
- jjtheblunt 4y agoSame in big-O though! And man I'm jealous you have one!
- lelanthran 4y ago> C was invented in 1972 and became one of the most widely used languages in the world with "the compiler is the specification" - and there were many different compiler implementations too. > It wasn't standardized until 1989 - 17 years later! > I think Rust will do just fine, Not based on the example you gave - using the behaviour of a single C compiler as a specification for the language implemented by that fairly easy due to how small C is. Rust is very much larger than C. > and the compiler error message is (IMO) the best of any language, making adhoc exploration possible. > Can you imagine trying to explore C from ad-hoc alone based on its compiler errors?! Not much different from Rust: Gcc and clang C compiler errors are exceptionally good, and I miss them terribly when programming in some other language (like C++, or Javascript).
- bebrws 4y agoThe end of that first paragraph is beautifully written.
- emptyparadise 4y ago>Is that someone the cool bear making an appearance on my blog? We’ll never know… and also I’d have to ask fasterthanlime to ask them for permission and didn’t plan this well enough. Cool bear has breached containment. I do have to admit I love the recent-ish trend of including dialogues in blog posts. Plato would be proud.
- fasterthanlime 4y agoRalfJ if you see this: you have my permission to use Cool Bear on your blog. Thanks for asking!
- ralfj 4y agoHi Amos, thanks a ton. :)
- kibwen 4y agoIs there some sort of licensing program available? Cool Bear As A Service?
- emptyparadise 4y agoCool Bear Cinematic Universe
- fasterthanlime 4y agoCool Bear has been making guest appearances in a couple places already! I do not intend to pay lawyers to pursue anyone who uses them without permission but I appreciate being asked first — it lets me keep track of where Bear travels. My only worry regarding Cool Bear is the licensing of the two pieces of artwork: I bought them a while ago on some stock image website but the terms weren't super clear, so I might need to revisit that. Since then I've commissioned drawings of bear and myself (5 variants each) but I haven't had a chance to use those yet — they're not monochrome, which makes dark mode awkward.
- 4y ago
- memorable 4y agoI legit thought this was a mini version of the Rust compiler. Not disappointed with what I read though.
- AndrewDucker 4y agoWouldn't it make most sense to focus this on MIR, which is in many ways a MiniRust already? https://blog.rust-lang.org/2016/04/19/MIR.html https://blog.rust-lang.org/2016/04/19/MIR.html
- kibwen 4y agoThat's happening separately, in the "mir-formality" project: https://github.com/nikomatsakis/a-mir-formality https://github.com/nikomatsakis/a-mir-formality The two projects are related, but have different objectives (mir-formality includes traits and borrow checking, while MiniRust focuses on operational semantics).
- ralfj 4y agoYes, MiniRust is basically a slightly extended MIR. But MIR is designed for borrow checking and MiniRust is designed for exploring semantics. And MIR doesn't have a precise operational semantics so it's not like this is duplicating much if anything.
- intelVISA 4y agoMy first thought when I saw MiniRust was "cool, a way to get the binaries small enough for embedded" but what I got was actually way cooler. Ralf is a great writer, even though I'm too slow for Rust he's got a talent of making all the arcane concepts seem accessible.
- ralfj 4y ago> "cool, a way to get the binaries small enough for embedded" lol, I didn't even realize the wrong associations I would create here. Glad you liked it anyway. :) I guess my choice of name was not great. I also considered pseudo-MIR but that didn't really capture it, either. And "formally specified fragment of Rust" isn't very catchy.^^ "CoreRust", maybe it should have been "CoreRust"...
- cestith 4y agoUsing "mini" to mean a subset of the language rather than a version for small systems has precedent. For example in the Perl community, miniperl is a subset of Perl. It's mostly used to bootstrap builds of the full language, but in theory can be used separately as a restricted programming language. It's also the name of a module, ExtUtils::Miniperl, for Perl (https://metacpan.org/pod/ExtUtils::Miniperl https://metacpan.org/pod/ExtUtils::Miniperl) that builds miniperlmain.c and perlmain.c files to bootstrap the compilation of the language system. This is not to be confused with the Raku project on Github called "miniPerl" (https://github.com/grondilu/miniPerl https://github.com/grondilu/miniPerl) which compiles subsets of Perl via the Lambda calculus to JavaScript output. I'd personally pretty much always expect "mini" or "r" (as in "rperl", a restricted subset of Perl with C++ connections) versions of a language to be restricted subsets for some purpose (rperl's is to give away flexibility for performance while maintaining a good portion of the original language). I've seen an "e" or "emb" prefix or a "small", "tiny", "micro" or "µ" (or "u") prefix to mean a small toolchain version several places, like SmallC or uclibc or Mikroe's mikroC (https://www.mikroe.com/mikroc https://www.mikroe.com/mikroc). It wouldn't surprise me to see a "nano" version of a language tool either. Sometimes these are subsets as well, but to fit the size constraints of the target rather than for constraining the input for its own sake.
- revskill 4y agoThe evolution is by removing/reducing unnessesary features, not by introducing more features. It's what the evolution should be.
- ArrayBoundCheck 4y ago
- PoignardAzur 4y agoYour comment is kind of a non-sequitur. This isn't a new feature, it's a formalization of existing semantics.
- deleted 4y ago[deleted]
- didip 4y agoRust in Rust is a fantastic idea. I loved it when Go went that direction post v1.4. Not only that the spec will be clearer but you can get more contributors on the core part of Rust.
- steveklabnik 4y agorustc has been written in Rust for a very, very long time now.