8 ms·
What about things that Rust shipped without that should have been included?
by andrepd 11y ago
What about things that Rust shipped without that should have been included?
- luibelgo 11y agoHigher kinded types https://github.com/rust-lang/rfcs/issues/324 https://github.com/rust-lang/rfcs/issues/324
- jpgvm 11y agoThat concerns us less. Rust ships again every 6 weeks.
- moonchrome 11y agoThey do have a constraint of not being able to break backwards compatibility between releases.
- jpgvm 11y agoThis is true. I guess you could say it shipped and is still shipping with many unstable APIs because they so cautious about shipping things they can't take back. I don't see that as a bad thing though, it's not great if you are trying to write Rust programs/libraries -right- now as sometimes you will have to jump through some hoops to only use stable Rust APIs but it will be worth it in the long term.
- Sir_Cmpwn 11y agoIncremental compilation and a non-braindead module system. Breaking changes will be required to fix both, which is why Rust was released too early if you ask me.
- pcwalton 11y agoWhy does incremental compilation require a breaking change? We just sketched a fully compatible design for it last week. I'd also question why the module system is "braindead", of course.
- Sir_Cmpwn 11y agoI haven't looked at Rust since I came to these conclusions a few months ago, so add a grain of salt. I don't recall why incremental compilation requires a breaking change, maybe it doesn't. I shouldn't have looped it into that statement without being certain. The module system _is_ braindead, though. Last time I brought this up, I made a proof of concept that compiled the exact same program two ways - one by using the module system, and one by running the code through the C preprocessor and literally #include-ing other rust files. The purpose of this PoC was to point out that Rust modules are functionally identical to #include-ing C files would be in C, which is a well known antipattern. Rust is very close to C when you consider the guts of the toolchain. C has solved several problems with respect to linking and I feel like Rust could have taken several more hints from C. This is probably a consequence of the Rust devs inherently disliking C and wanting to distance themselves from it.
- pcwalton 11y ago> The purpose of this PoC was to point out that Rust modules are functionally identical to #include-ing C files would be in C, which is a well known antipattern. But they trivially aren't. lib.rs: mod foo; mod bar; foo.rs: fn f() {} bar.rs: fn f() {} No name conflict. foo::f and bar::f happily coexist. In C: lib.c: #include "foo.c" #include "bar.c" foo.c: void f() {} bar.c: void f() {} Name conflict; fails to compile. > Rust is very close to C when you consider the guts of the toolchain. C has solved several problems with respect to linking and I feel like Rust could have taken several more hints from C. This is probably a consequence of the Rust devs inherently disliking C and wanting to distance themselves from it. No, it's that header files are are a big problem in C (DRY violation, hostile to code inlining, slow compilation) and it was felt that a real module system would be an improvement.
- Sir_Cmpwn 11y agoThe PoC did this: mod foo { #include "..." } Which is barely enough to say that Rust is hugely different than just #include-ing C files. I was talking more about linking objects incrementally and the consequences of that design, rather than singing the praises of headers (though I do rather like headers). I understand C from the compiler's perspective as well, having written my own linker and assembler from scratch myself, and I really appreciate the elegance of the design. >slow compilation That's objectively untrue. It's much faster to compile with something like headers. As far as inlining and DRY are concerned, back before Rust shipped I spoke with many Rust maintainers about solutions to all of these problems, but it was dismissed because "we're trying to ship". Maybe you shouldn't sail a boat when you need to replace the hull later?
- amelius 11y agoCoroutines, Go style.
- steveklabnik 11y agoThere is https://github.com/rustcc/coroutine-rs https://github.com/rustcc/coroutine-rs, though I haven't personally used it yet.
- pcwalton 11y agoM:N threads didn't work for Rust, and they don't have that many advantages anyway even in languages where they do work. There has been a lot of discussion on this over the years and this has been the conclusion everyone came to.
- tomp 11y ago> they don't have that many advantages anyway even in languages where they do work. Are you sure about that? One of the main advantages of coroutines/greenlets IMO is writing simple and straightforward blocking code (e.g. an echo server); without them, you either need to use threads (which are slower and much more heavyweight) orcallbacks or related constructs (async/await, futures, ...).
- pcwalton 11y agoThreads aren't that slow on Linux. The main advantage of M:N threading as implemented in Go over 1:1 is that spawning is fast and doesn't use much memory, because you can avoid the syscall and only a small (initial) stack is required. Rust can't do the latter because it's not GC'd. Even if it could, many real-world servers actually do non-trivial work in their threads, so the cost of spawning a thread is dwarfed by the actual work the thread ends up doing. There are serious drawbacks to M:N: complexity, fairness, problems in interoperability with the 1:1 world (including essentially unavoidable performance problems with the FFI), etc.
- agentS 11y ago
- riquito 11y agoTail call optimization https://mail.mozilla.org/pipermail/rust-dev/2013-April/003557.html https://mail.mozilla.org/pipermail/rust-dev/2013-April/00355... https://github.com/rust-lang/rust/issues/217 https://github.com/rust-lang/rust/issues/217 > I'm sorry to be saying all this, and it is with a heavy heart, but we tried and did not find a way to make the tradeoffs associated with them sum up to an argument for inclusion in rust. > -Graydon
- steveklabnik 11y agoNote that a lot has changed since April of 2013. Rust does have TCO, we just can't guarantee it. And, LLVM has come a long way, so we probably can support guaranteed TCO now, and have 'become' as a reserved keyword for this purpose. https://github.com/rust-lang/rfcs/issues/271 https://github.com/rust-lang/rfcs/issues/271 is a better link today.
- riquito 11y agoThat's really a good news! Thank you for pointing that out.
- hamstergene 11y agoI praise the idea of making TCO explicit and guaranteed, but wonder if whole new keyword is necessary? It could be avoided by modifying `return` with another keyword which is currently impossible at that place, for example return as foobar(x, n-1) return in foobar(x, n-1) override return foobar(x, n-1) final return foobar(x, n-1) It's a little surprising to see entirely new construct invented for something that is just a different implementation of `return`, after all, the end result of computation with tail-return is the same as with normal return, only performance differs.
- steveklabnik 11y agoIn theory, we could have done that too, and I guess we still could.
- blaenk 11y agoAbstract Return Types.
- nwmcsween 11y agoAn effects system. A safe stdlib - aborting on malloc failure is not safe.
- kzrdude 11y agoThen you are using a different meaning for safe than what Rust usually does. Abort occurs on oom, that's right and also on double panic (most frequently found if a destructor panics during unwinding).
- Manishearth 11y agolibcore and no_std is what you want to use if you want finer-grained malloc-free control over things.
- gnuvince 11y agoI'd need to recheck my vocab, but I'm pretty sure aborting is always safe.
- ajb 11y agoNot if you want to write an OS.
- rcxdude 11y agoThen you won't use the stdlib anyway.
- steveklabnik 11y agoRust's usage of 'unsafe' refers to a very specific thing: memory safety. Aborts are always safe, though they may not be what you want, of course.
- simoncion 11y agoThe ability to provide a default implementation of a function in a trait that can be inherited and used by "classes" that extend that trait. In C++, this would look like: #include <iostream> class B { public: int get_id() { return id; }; int id; }; class C : public B { }; int main() { C c; std::cout << c.get_id() << "\n"; return 0;} Maybe I'm ignorant, and there's an easy way to do this. I was screwing around with Rust a few months before 1.0 and didn't see any mention of it in the docs, though. (Everything I saw required me to provide an impl for functions defined in an interface for every class that implemented that interface.)
- dragonwriter 11y ago> The ability to provide a default implementation of a function in a trait that can be inherited and used by "classes" that extend that trait. Rust provides this. E.g., the "talk" method in the "Animal" trait below: [0] trait Animal { // Static method signature; `Self` refers to the implementor type fn new(name: &'static str) -> Self; // Instance methods, only signatures fn name(&self) -> &'static str; fn noise(&self) -> &'static str; // A trait can provide default method definitions fn talk(&self) { // These definitions can access other methods declared in the same // trait println!("{} says {}", self.name(), self.noise()); } } [0] From Rust By Example, http://rustbyexample.com/trait.html http://rustbyexample.com/trait.html
- simoncion 11y agoMan. The documentation did not make that clear at all. Was this added in 1.0? A question (In C++ syntax, as I'm not a Rust programmer): How would one call Animal::talk inside Dog::talk? The obvious thing (commenting out the println and adding Animal::talk(self) ) causes infinite recursion. The other vaguely obvious thing ( Animal.talk(self); ) is a syntax error, which makes sense. Edit: I'm referring to the code at the linked Rust By Example page.
- heinrich5991 11y agoThe feature was added way before 1.0, if you're talking about the documentation, then I have no idea. There is no way to call the overwritten `Animal::talk`.
- IsTom 11y agoNon-lexical lifetimes/borrows. This is a dealbreaker IMO.
- ewillbefull 11y agoDealbreaker? This just means you need to play with let bindings a little bit until they improve it at some point. (Same goes for SEME regions.)
- IsTom 11y agoIt makes array use really awkward in my experience.
- notriddle 11y agoNon-lexical scope won't help with that. Remember that Rust does not allow mutable aliasing, so this code can never be allowed: let mut arr = [1, 2]; let a = &mut arr[0]; let b = &mut arr[0]; This code could be allowed: let mut arr = [1, 2]; let a = &mut arr[0]; let b = &mut arr[1]; And it gets Hard once variable indexes are involved. And since the whole point of using arrays is to get variable indexing, the Rust developers choose to only implement reborrowing for structs and tuples.
- theseoafs 11y agoFor those who are not so Rust inclined, can we have an example of what this means?
- steveklabnik 11y agoCurrently, lifetimes are based entirely on lexical scope. So for example, this doesn't work: fn main() { let mut x = 10; let y = &mut x; *y = 11; println!("{}", x); } This will complain error: cannot borrow `x` as immutable because it is also borrowed as mutable This is because an `&mut` borrow is exclusive: while `y` is alive, we cannot use `x`. We can fix this by making a new scope for `y`: fn main() { let mut x = 10; { let y = &mut x; *y = 11; } println!("{}", x); } This works, and will print `11`. Non-lexical lifetimes would allow the compiler to demonstrate that these two things are the same, and allow the first one to compile with the behavior of the second. It's an interesting tradeoff, because right now, the rules are very simple and conservative. Scope is fairly easy to reason about. Non-lexical lifetimes would make certain things easier, but also a bit harder to reason about, because the rules are more complex.
- yazaddaruvala 11y agoI really wish Rust/stdlib had been built around a good async io story. Right now it just feels neglected "because the crates ecosystem can deal with it". I might be wrong here but it always seemed to me that Rust was built to replace C/C++ in critical infrastructure like Firefox, Nginx, Redis, etc. Basically critical network dependent infrastructure. With respect (because I understand the difficulties that come with time constraints/resourcing/building an efficient async API), currently I'm not sure how Rust expects itself to be a viable replacement (let alone the best replacement) language for any of those types of applications.
- steveklabnik 11y agoWell, and again, it doesn't implement the entire web platform, but Servo is already showing significant speed gains, even without AIO. It's really more useful for servers than clients. It's important to remember that IO is truly a library concern in Rust. 1.0 means the language is stable, but there's still tons of libraries to build on top of that language. Holding back the language itself for a library that, while important, is only needed for certain applications wouldn't make a whole lot of sense.
- yazaddaruvala 11y agoIn this particular context I believe using Servo as an argument is misleading. And actually its not just about "doesn't implement the entire web platform". Servo gains all of its performance wins from parallel rendering. A very effective but entirely orthogonal optimization. Just because one optimization far outweighs the performance wins of another optimization doesn't mean the other should be neglected entirely. Also, Servo's benchmarks run a relatively light workloads, i.e. one page at a time. The argument might be similar to using benchmarks for a parallel web rendering engine (a Servo-like) in Go. It would probably have similar median latencies to Servo. And Go may even scale out better if tabs were sandboxed in goroutines instead of processes. However, ofcourse unlike Servo it would have a higher variance/p90/p99 latencies because of the GC. P.S. I'm not a big fan of Go I was just using it to try and bolster my argument that Servo's current benchmarks shouldn't be used as an argument against async io prioritization. Actually, side note, I would love to hear more flaws about building a Servo-like in Go.
- phaylon 11y agoOr to continue the train of thought, what about things that it did ship with that could have been excluded? :) Personally I'm starting to dislike index operations since they can panic (and are the shortest way to access), and I rather use the explicit Option based APIs. Though I'm not too worried about those, since a lint disallowing them shouldn't be too hard.
- sparkie 11y agoA requirement to stick #version 1.0 at the top of code files so we know which version they were intended to be compiled with, such that in future we can introduce breaking changes into version 2.0 and still have support for compiling legacy 1.0 applications. Seriously, nearly all data storage formats we use today have some kind of version number in them - why are we treating code as dumb text rather than interesting data?
- Rusky 11y agoThat probably fits better in Cargo.toml, where it's also a lot less work to add later.