9 ms·
Announcing Rust 1.14
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- anuragsoni 10y agoGreat to see Rustup reach 1.0 release. I like how easy it makes to test out different versions of rust and its toolchains. I like the '..' addition for structs. It definitely improved the pattern matching over structs. let p = Point { x: 0, y: 1, z: 2 }; match p { Point { x, .. } => println!("x is {}", x), } Congrats to the Rust Team for another good release!!
- petters 10y agoQuestion from someone who don't know Rust: Why two dots instead of an ellipsis (three)?
- kryptiskt 10y agoThree dots doesn't look like an ellipsis in a monospaced font, it's far too wide.
- echelon 10y agoIt can if you use a monospaced font with ligatures. Take a look at Fira Code [1]. I use it in Vim and IntelliJ, and it looks great with Rust and other functional languages. [1] https://github.com/tonsky/FiraCode https://github.com/tonsky/FiraCode
- petters 10y agoWell, I'm sure you know what I meant.
- swsieber 10y agoI'm pretty sure he did know what you meant, and offered a serious response. I think he's suggesting that perhaps the aesthetics of the ellipsis is what prevented it from being selected.
- deleted 10y ago[deleted]
- belovedeagle 10y agoIt's already a keyword or operator (not sure which) used in range notation (1..2); why add a new operator when an old one will do?
- iopq 10y agoThree dots are for inclusive ranges, two for exclusive
- cannam 10y agoThere must be some interesting reason why ".." and not the more common "..." - I wonder what?
- the_duke 10y agoThey probably 'copied' Haskell here, which also uses "..".
- pdexter 10y agoHaskell doesn't have this feature though. I mean it does, but you can just leave out the ones you don't want matched, you don't have to put in any dots.
- echelon 10y agoIt's less to type. The double period is already used for lots of other things in the language, so it feels like the correct choice.
- swsieber 10y agoReading through, they treat a range (like 1 .. 10 ) as pattern matching 1 2 3 4 5 6 7 8 9 10, with .. representing 2 3 4 5 6 7 8 9. In that light, it actually makes sense.
- cannam 10y agoAh of course, that is quite widely used (e.g. Perl). If you already have that, I can see why you'd reuse the same token. (edit: ok, I see from other replies that it's not that simple)
- anuragsoni 10y agoMinor correction, to match a range the syntax would be 1 ... 10
- tatterdemalion 10y agoNo particular reason. `..` and `...` both exist in the language, `..` is exclusive range and `...` is inclusive range. `..` is only in expressions right now, whereas `...` is only in patterns. Eventually, both will be available everywhere, possibly. At very least, `..` in patterns is getting added soon. Since this is a pattern thing, probably `..` was chosen when `...` was the only range available in patterns, to distinguish this from that range pattern more. However, `..` will now be available in patterns, so its just historical. (This is a longstanding feature, what's changed is just making it apply to more patterns.)
- echelon 10y agoThis is such a win for pattern matching! I tried using this exact syntax last month and I was sad to see it didn't exist. It feels so natural to see it now. Rust is such an awesome language. Every design decision feels so right. Go, Rust, go!
- deleted 10y ago[deleted]
- the_duke 10y agoAnyone know if macros 1.1 will be in 1.15?
- steveklabnik 10y agoThat is the plan, yes. It's not in the beta yet, but will be backported. (For those of you who don't pay super close attention to Rust development, that means libraries like Serde and Diesel will be as convenient to use on stable as they are on nightly, today.)
- Perceptes 10y agoIs this the first time a feature stabilization has been made to a version that has already moved into the beta phase? My understanding was that beta was pretty much frozen except for bug fixes.
- steveklabnik 10y agoYes. It's a perfect storm of coincidences, basically. It's a combination of timing + a tiny feature. Let's take a step back. Macros 1.1 is RFC 1681: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md https://github.com/rust-lang/rfcs/blob/master/text/1681-macr... See the section saying "The initial implementation of librustc_macro is proposed to be incredibly bare bones:" it really is very, very small. So it landed, and while there was some questions that came up, people migrated to it, and it works well. 22 days ago, it was to be reviewed: https://github.com/rust-lang/rust/issues/35900#issuecomment-264022584 https://github.com/rust-lang/rust/issues/35900#issuecomment-... However, two things happened: one, the Mozilla all-hands in Hawaii, which shook things up, but secondly, that meant a lot of people, including one of the reviewers, took PTO around that time, to actually see some of the islands. That includes someone who was on the reviewers list. So in general, "oh hey this is waiting on one person who forgot to check a box but isn't reachable now" is awkward. Luckily, in this case, we know that it was just forgetting to check the box; Felix did not have any objections that we were aware of. So we decided to sign off for him, and put it into FCP. This happened so that FCP technically passed the deadline for 1.15, but given how important it is to ship, we're planning on nominating it for a backport, and don't anticipate complaints. So: tiny feature, code wise. Big win for being stable. Procedural mishap involving awkward scheduling. All these things played into it. Make sense?
- wyldfire 10y agoI'm psyched to try wasm. Are there any crates which provide interfaces to things like a canvas object?
- steveklabnik 10y agoThere were some experiments long ago: https://www.reddit.com/r/rust/comments/2yfsi9/rust_to_js_with_emscripten/?st=ix0spbxl&sh=13e1e707 https://www.reddit.com/r/rust/comments/2yfsi9/rust_to_js_wit... but it looks like SDL2 has an official port: https://github.com/emscripten-ports/SDL2 https://github.com/emscripten-ports/SDL2 So you'd use regular Rust SDL2 libraries, and it Just Works (hopefully...)
- CryZe 10y agoDepending on the cargo version, wasm might not actually work in 1.14 (couldn't check which version it uses yet). It's definitely broken in the next release, which is quite unfortunate :/
- andrewchambers 10y agoWhy the heck do all the platforms have 'unknown' in them? It seems stupid. > mips-unknown-linux-gnu > wasm32-unknown-emscripten > arm-unknown-linux-musleabi What value does that garbage add to it?
- steveklabnik 10y agoHistorically, that part of a target triple is used to indicate a specific "vendor," so you have "mips-unknown-linux-gnu" vs "mips-debian-linux-gnu", where the former is for all linuxes, but the latter is specific to Debian. See here: http://clang.llvm.org/docs/CrossCompilation.html#target-triple http://clang.llvm.org/docs/CrossCompilation.html#target-trip...
- andrewchambers 10y agoSo a target triple is really a target quad (makes perfect sense). Tbh, leaving it out would or using the word "generic" would be far better than unknown.
- steveklabnik 10y agoLeaving it out means that it's harder to parse, which isn't the worst thing in the world, but the explicitness is helpful, IMO. "generic" would work too, but this is a long-standing convention, so that ship has probably sailed.
- glandium 10y agoHarder to parse is one thing, but if it could match the output of config.guess, and/or allow to skip the "unknown" part so that the triples match what's used for GCC prefixes and clang's --target, that would be way nicer. https://github.com/rust-lang/rust/issues/33147 https://github.com/rust-lang/rust/issues/33147
- Manishearth 10y agoYou already leave out the ABI for some kernels (e.g. x86_64-apple-darwin), so it would be ambiguous otherwise.
- adwhit 10y agoWrite your Rust app. Compile to a binary on the backend, wasm on the frontend, using asyncio to communicate transparently between the two. Update the DOM directly from wasm, with 60fps rendering from Servo's WebRender. Totally typesafe and lightening fast. It could all be so beautiful.
- oblio 10y agoAnd it will never happen (ok, maybe "never" is too strong - it will happen 10-15 years from now, at best and even then it will be unstable/unreliable/slow/half baked on some platforms, because reasons). The best we've got is the piece meal approach of HTML/Javascript/CSS. And before you blame those standards, blame the Unix vendors^W^W, pardon me, the platform owners (Microsoft, Apple, Google).
- wtetzner 10y agoWhy won't it happen? If wasm can talk to the DOM, then you'll still be using HTML and CSS, and wasm in place of JS. There's no reason this couldn't be done already by just compiling to JS, and plenty of languages already do that. You could also render everything to a canvas to avoid HTML and CSS, but at that point there are a lot of things to re-implement, especially around accessibility.
- oblio 10y agoWell, first of all wasm needs to be implemented in all major browsers on all major platforms for it to be widely adopted. Since the major browser vendors are backing it, that should happen quite soon. But that's just the initial implementation. It needs to be implemented fully, debugged, optimized and then it needs to trickle down to user devices, including those sold 3-4-5 years ago and still in use. And then, in the second stage, wasm needs to get DOM access (as far as I know v1 won't have it). See stage 1, all over again. I'd say that the mass adoption cycle for 1 stage is roughly 5 years (where 80%+ of the browsers out there support a major feature well). So 2 stages x 5 years = 10 years. Maybe I'm too pessimistic...
- libria 10y ago> experimental support for WebAssembly as a target, wasm32-unknown-emscripten [...] check out Tim’s example of the classic TodoMVC project. On one hand this is really cool and potential for client-side Rust. On the other hand: let id = node.parent().unwrap().parent().unwrap().data_get("id").unwrap().parse::<usize>().unwrap(); Eh, no thanks. :) If I could get a macro or shorthand for that, I'd welcome all the other benefits of a large scale client-side platform with strong typing.
- deleted 10y ago[deleted]
- bbatha 10y agoWhen the carrier trait lands this becomes: let id = node.parent()? .parent()? .data_get("id")? .parse::<usize>() .ok()?; I'd also expect that someone will write higher level libraries so that you aren't doing raw DOM manipulation. A rust vdom wasm library would probably be blazing fast.
- libria 10y agoSwell! I was hoping that existed in this language. The rest of the code looks concise FWIW, https://github.com/tcr/rust-todomvc/blob/master/src/main.rs https://github.com/tcr/rust-todomvc/blob/master/src/main.rs
- leeoniya 10y ago> A rust vdom wasm library would probably be blazing fast. Most of the cost of vdom is the resulting DOM ops and reflow/restyle the browser needs to do. It may be faster than the fastest today, but you're unlikely to see any kind of performance leap or even anything noticeable.
- steveklabnik 10y agoSmall note, we don't _technically have to stabilize Carrier to land this, just implement it for Option. (yay standard library types) However, ? for Option is a bit controversial, so we'll see...
- EugeneOZ 10y ago"feature request": please announce what is new in beta also. Maybe I'm not alone on beta and if I would knew about web-assembly in beta, I'd test it 6 weeks ago :)
- steveklabnik 10y agoWe used to do this, but it made release announcements feel redundant, and part of the beta process is making sure that we don't need to back anything out, so we can't even 100% guarantee that beta is absolutely going to have whatever feature.
- oblio 10y agoI have a question for Rust users: let's say I'd want to write a system tool that has to run on multiple platforms (Windows/Linux/Mac) and that would integrate with all sorts of command line utilities. I'm interested in using Rust, but would Rust be a good fit for this? The tool would be long lived so I'd want a statically typed language with a modern type system and as many safety guarantees as possible. But I'd also want a high level programming language and also libraries that would help with that integration (launching processes, capturing output, monitoring progress, parsing output: text, JSON, XML, etc., etc.). I'd also want a tool that runs quickly but I figure there's no point in mentioning that in a thread about a language that compiles to native code and that has no garbage collector :)
- steveklabnik 10y agoThis should be an area of strength in Rust, at least conceptually. If a systems language can't write system utilities, well... There is at least some degree of support for everything on your list, though it's kinda hard to tell with some of the ways in which you're being vague (not that that's bad, mind you, just recognizing that this answer is also kind of generic because of it.)
- dochtman 10y agoI'm not quite sure what you mean when you say "integrate with all sorts of command line utilities", but based on the other things you write I could not think of a better language than Rust. Since I started to write some Rust code about 6 months ago, Rust has replaced Python as the language I think in. Static typing with a modern typing system is awesome, and not having to think about a GC is also awesome (see also the recent Medium article about all the ways GC's need to be tunable).
- nekohacker 10y agoRust sounds perfect for what you want to do. It takes a bit of practice to get used to its parsing, since it's extremely safe, but when you get things running, they run very well. As for cross-platform capabilities, it has fairly mature support across all the mainstream OS platforms, and developing support for others such as ARM. Check out this page (https://forge.rust-lang.org/platform-support.html https://forge.rust-lang.org/platform-support.html) for more information on Rust's platform support.
- Perceptes 10y agoCongratulations and thank you to the Rust team! As always, I've updated my Rust Docker image[0] for 1.14 (both the latest and 1.14.0 tags) for anyone who has Docker installed and wants to try Rust out quickly. Although with how easy Rust is to install via Rustup now, the value of this image is diminished somewhat. :} [0] https://hub.docker.com/r/jimmycuadra/rust/ https://hub.docker.com/r/jimmycuadra/rust/
- corndoge 10y agoLove Rust. That said, I have not figured out the following, and I'm sure that there has to be a canonical solution for this: I have a Rust application that depends on 1 crate from crates.io. I want to build it on an embedded device over serial that has no networking capabilities. Does Cargo have an 'offline mode' or something that I can use to say "I don't want to depend on the Internet to build this, just fetch this version of the crate and keep it?" Because I have not been able to find anything like that. I'm sure there's a good solution for it because Rust is billed as a systems language.
- steveklabnik 10y agohttp://doc.crates.io/faq.html#how-can-cargo-work-offline http://doc.crates.io/faq.html#how-can-cargo-work-offline is a TL;DR. You'll possibly also want to look at https://github.com/alexcrichton/cargo-vendor https://github.com/alexcrichton/cargo-vendor and https://github.com/alexcrichton/cargo-local-registry https://github.com/alexcrichton/cargo-local-registry
- corndoge 10y agoI read the first and last link, had not seen the second. Looks like what I need, thank you. Surprised that Rust seems to expect people to have Internet access to build.
- steveklabnik 10y agoAs the FAQ says, it only expects it when it needs to get something from the internet, which is a pretty reasonable default. I am biased, though ;)
- flukus 10y agoIs this similar to nuget, if your familiar with that? Ie, do you have "pinned" versions in a project and only need to access the internet when a package is missing?
- dorfsmay 10y agoAny plan to integrate rusti (or another REPL) in the basic tool kit, the way cargo is part of it?
- steveklabnik 10y agoIf one comes along, it's very possible. rusti describes itself as experimental still, as far as I know.