News for hackers. Stuff that matters.
Re:100 days with Rust: a series of brick walls by majewsky on Friday March 23, 2018 @01:02PM (#16660191)
I can see where the author comes from. I've been working with ^W^W fighting against Tokio this week, and the error messages are horrible. Representative example:

  error[E0271]: type mismatch resolving `<futures::AndThen<futures::Select<futures::stream::ForEach<futures::stream::MapErr<std::boxed::Box<futures::Stream<Error=std::io::Error, Item=(tokio_uds::UnixStream, std::os::ext::net::SocketAddr)> + std::marker::Send>, [closure@src/server/mod.rs:59:18: 59:74]>, [closure@src/server/mod.rs:60:19: 69:10 next_connection_id:_], std::result::Result<(), ()>>, futures::MapErr<futures::Receiver<()>, [closure@src/server/mod.rs:74:18: 74:74]>>, std::result::Result<(), ((), futures::SelectNext<futures::stream::ForEach<futures::stream::MapErr<std::boxed::Box<futures::Stream<Error=std::io::Error, Item=(tokio_uds::UnixStream, std::os::ext::net::SocketAddr)> + std::marker::Send>, [closure@src/server/mod.rs:59:18: 59:74]>, [closure@src/server/mod.rs:60:19: 69:10 next_connection_id:_], std::result::Result<(), ()>>, futures::MapErr<futures::Receiver<()>, [closure@src/server/mod.rs:74:18: 74:74]>>)>, [closure@src/server/mod.rs:78:34: 83:6 cfg:_]> as futures::Future>::Error == ()`
    --> src/server/mod.rs:85:15
     |
  85 |     return Ok(Box::new(server));
     |               ^^^^^^^^^^^^^^^^ expected tuple, found ()
     |
     = note: expected type `((), futures::SelectNext<futures::stream::ForEach<futures::stream::MapErr<std::boxed::Box<futures::Stream<Error=std::io::Error, Item=(tokio_uds::UnixStream, std::os::ext::net::SocketAddr)> + std::marker::Send>, [closure@src/server/mod.rs:59:18: 59:74]>, [closure@src/server/mod.rs:60:19: 69:10 next_connection_id:_], std::result::Result<(), ()>>, futures::MapErr<futures::Receiver<()>, [closure@src/server/mod.rs:74:18: 74:74]>>)`
                found type `()`
     = note: required for the cast to the object type `futures::Future<Item=(), Error=()>`
I have hope that things will improve on this front when `impl Trait` lands.

EDIT: After re-reading this, I want to add that I don't mean to hate on Tokio. I like the basic design very much, and hope that they can work out the ergonomics issues and stabilize the API soon.

Re:100 days with Rust: a series of brick walls by pimeys on Friday March 23, 2018 @02:11PM (#16660975)
That's nothing!

      |
  212 | /     fn call(&self, payload: Self::Request) -> Self::Future {
  213 | |         let request = self.create_request(payload);
  214 | |
  215 | |         let work = async_block! {
  ...   |
  254 | |         FutureResponse(Box::new(work))
  255 | |     }
      | |_____^
  note: ...so that the type `impl futures::__rt::MyFuture<<[generator@src/client.rs:215:20: 252:10 self:&client::Client,
request:hyper::Request for<'r> {futures::Async<futures::__rt::Mu>, (), fn(std::result::Result<hyper::Response, error::Error>) -> std::result::Result<<std::result::Result<hyper::Response, error::Error> as std::ops::Try>::Ok, <std::result::Result<hyper::Response, error::Error> as std::ops::Try>::Error> {<std::result::Result<hyper::Response, error::Error> as std::ops::Try>::into_result}, futures::MapErr<hyper::client::FutureResponse, [closure@src/client.rs:217:59: 217:85]>, hyper::Response, std::option::Option<std::string::String>, &'r hyper::Response, hyper::StatusCode, fn(std::result::Result<hyper::Chunk, error::Error>) -> std::result::Result<<std::result::Result<hyper::Chunk, error::Error> as std::ops::Try>::Ok, <std::result::Result<hyper::Chunk, error::Error> as std::ops::Try>::Error> {<std::result::Result<hyper::Chunk, error::Error> as std::ops::Try>::into_result}, futures::stream::Concat2<futures::stream::MapErr<hyper::Body, [closure@src/client.rs:234:49: 234:75]>>}] as std::ops::Generator>::Return>` will meet its required lifetime bounds
Re:100 days with Rust: a series of brick walls by vardump on Friday March 23, 2018 @03:43PM (#16661937)
I see. Rust is aiming to be closer and closer to C++ every day!

Anyways, I think it has still long way to go to match the length of even common C++ template related error messages...

Re:100 days with Rust: a series of brick walls by coldtea on Saturday March 24, 2018 @04:25PM (#16668715)
>I see. Rust is aiming to be closer and closer to C++ every day!

Or you know, it's aiming nothing of the short, and this is early, still unsorted, behavior, while the language has been simplifying things (e.g. the early sigils and lots of other stuff), and plans even more simplification and friendliness.

https://jvns.ca/blog/2018/01/13/rust-in-2018--way-easier-to-...

https://blog.rust-lang.org/2018/03/12/roadmap.html

Re:100 days with Rust: a series of brick walls by pimeys on Friday March 23, 2018 @03:59PM (#16662104)
I've definitely seen much worse with C++. These kind of errors you get though when you use Tokio and combine many different futures together, the future wanting to have static lifetimes and me using a reference to self inside an async block, hopefully solved this year.
Re:100 days with Rust: a series of brick walls by thowawayburnout on Friday March 23, 2018 @11:27PM (#16664665)
I have found while the C++ error messes can be very long, its surprisingly often in the first line of the error message that you see the problem.
Re:100 days with Rust: a series of brick walls by pjmlp on Saturday March 24, 2018 @04:31AM (#16665530)
Also since clang, at least using recent versions of clang, gcc and VC++ they use heuristics to try to present some kind of meaningful message.

And latest C++14 and C++17 changes also help library writers to error check the type parameters.

Of course those that have to use other compilers still need to face the sea of incomprehensible error messages.

And in any case, better stay away from template meta-programming libraries, at least until modules and concepts eventually land.

Re:100 days with Rust: a series of brick walls by kibwen on Friday March 23, 2018 @01:07PM (#16660266)
Coincidentally, `impl Trait` stabilization was just approved, meaning it should be in the next beta: https://www.reddit.com/r/rust/comments/86f3h6/impl_trait_sta... . It will be a crucial step forward for Tokio's error messages.
Re:100 days with Rust: a series of brick walls by gnode on Friday March 23, 2018 @01:08PM (#16660281)
The grievances you and the article's author mention seem less to do with Rust itself, and more to do with this seemingly horrible futures library. As far as I can tell, it's still in the rust-lang-nursery, which is an indication it's not ready for prime time yet.
Re:100 days with Rust: a series of brick walls by pimeys on Friday March 23, 2018 @02:12PM (#16660995)
Don't get me wrong, it's a great library! You can do pretty darn fast systems with it, all type-checked and correct. Just don't try to fit in too many things into one thread yet, wait for async/await and non-statical lifetimes in the core.
Re:100 days with Rust: a series of brick walls by tveita on Friday March 23, 2018 @08:25PM (#16663867)
I hope async programming doesn't become the standard in Rust. So much work has gone into allowing clean and safe threading, but people seem to be led towards the async libraries, which IMO solves a scaling problem only 1% of users will have. It's great that they exist, but if you're not expecting to have a c10k class problem, you can use threads and you'll probably have a better time.
Re:100 days with Rust: a series of brick walls by geofft on Friday March 23, 2018 @10:56PM (#16664524)
If you're a library, creating threads causes side effects for the host program, and doing async when called doesn't. For instance, in a single-threaded program, it's always safe to call malloc() after fork(). In a multi-threaded program, another thread might have called malloc() and picked up a global lock; since only the thread that called fork gets copied (since you don't want to do the other threads' work twice!), there's now a copy of that global lock being held by a thread that doesn't exist, so calling malloc() will deadlock.

My personal interest in Rust is as a C replacement, including as a replacement for existing libraries that are written in C. While I agree threads can be very efficient (after all, the kernel implements threading by being async itself, more or less), they're annoying for this use case.

Re:100 days with Rust: a series of brick walls by staticassertion on Friday March 23, 2018 @09:37PM (#16664224)
I just want to be able to say "do this thing or time out in 5 seconds", and that's like all the 'async' I need in rust. Everything else, nah.

But that's just me - many people need these 0 cost abstractions, this is Rust's focus, and I'll have to wait for the higher level stuff for my projects.

Re:100 days with Rust: a series of brick walls by paulddraper on Sunday March 25, 2018 @10:46AM (#16672383)
> less to do with Rust itself, and more to do with this seemingly horrible futures library

Doesn't almost every major programming language have Futures though? (C++, Java, Python, Ruby, JavaScript, Go).

It seems a fair criticism for so common a building block.

Re:100 days with Rust: a series of brick walls by gnode on Monday March 26, 2018 @08:00AM (#16678174)
For a long time C++ and Javascript did not have futures. Rust is relatively new, and futures aren't part of the language proper yet. The problem is that the author's criticism of Rust seems to all hinge around a bleeding edge feature.

I would agree with the author's criticism if it was "futures are in the lang nursery and still not ready to use," rather than: Rust is bad, because I got nasty errors when using this work-in-progress library.

Re:100 days with Rust: a series of brick walls by steveklabnik on Sunday March 25, 2018 @12:53PM (#16673054)
Rust's futures leverage the type system to have extremely minimal overhead; many of those languages don't try to do that. That's where the difficulty comes in.
Re:100 days with Rust: a series of brick walls by reaperducer on Friday March 23, 2018 @03:18PM (#16661684)
If we'd all start programming in stable, mature languages instead of letting peer pressure goad us into using betaware and worse, work would be a lot simpler.

It would also encourage organizations large and small to start releasing complete, polished products instead of the "move fast and break things" crap that has infected the industry.

Imagine if car makers worked the same way.

Re:100 days with Rust: a series of brick walls by arghwhat on Friday March 23, 2018 @07:47PM (#16663662)
Your "stable and mature" languages were the crazy research projects of old. No one is forcing you to do anything, but let us not forget the nature of our "mature" technologies and the process by which they form.
Re:100 days with Rust: a series of brick walls by majewsky on Friday March 23, 2018 @04:47PM (#16662500)
By that logic, programs written in C are the most polished. Yeah, that checks out. /s
Re:100 days with Rust: a series of brick walls by kpil on Friday March 23, 2018 @06:34PM (#16663210)
Ask a COBOL programmer about this...
Re:100 days with Rust: a series of brick walls by arghwhat on Friday March 23, 2018 @07:40PM (#16663621)
Ask an assembly programmer about this...
Re:100 days with Rust: a series of brick walls by evancox100 on Friday March 23, 2018 @08:14PM (#16663803)
Ask a machine code programmer about this...
Re:100 days with Rust: a series of brick walls by elcritch on Saturday March 24, 2018 @03:09AM (#16665289)
Ask a Minecraft machine programmer about this.... (errr, couldn’t resist)
Re:100 days with Rust: a series of brick walls by srdone on Friday March 23, 2018 @04:44PM (#16662490)
Isn't that what Uber is doing? :/
Re:100 days with Rust: a series of brick walls by insulanus on Friday March 23, 2018 @03:09PM (#16661579)
That is rough, but after looking at C++ template error messages a lot recently, that error message looks pretty sweet!
Re:100 days with Rust: a series of brick walls by alexeiz on Friday March 23, 2018 @01:56PM (#16660797)
Finally, a language that can compete with C++ on complexity and size of error messages!
Re:100 days with Rust: a series of brick walls by plandis on Friday March 23, 2018 @02:21PM (#16661098)
This is still an unstable library (futures and Tokio are both still 0.1 release) actively being developed, in general I tend not to see crazy compile errors working on synchronous projects. FWIF I’ve made a Chip8 emulator with Rust and am working on a Z80 emulator now.
Re:100 days with Rust: a series of brick walls by pimeys on Friday March 23, 2018 @04:03PM (#16662151)
Yeah, sync projects are just pure pleasure to work with. The language is ergonomic, errors are easy to read and tooling is the best ever.

The problems right now start when you want to go async. I follow the development because I want to see easy, safe and fast way of writing async programs, and there's lots of interesting development happening with Rust.

Re:100 days with Rust: a series of brick walls by xfer on Friday March 23, 2018 @04:09PM (#16662211)
Yeah, i have recently finished a tokio based server. Working with future combinators is very frustrating. I accidentally captured a variable in a closure(should be cloned and moved), and it didn't tell me where it happened, just an error saying requires 'static lifetime for the variable.
Re:100 days with Rust: a series of brick walls by steveklabnik on Friday March 23, 2018 @05:52PM (#16662899)
The new async/await stuff will help a lot with this; it'll enable borrowing across futures, which will remove this requirement and make things a lot simpler.
Re:100 days with Rust: a series of brick walls by xfer on Friday March 23, 2018 @09:25PM (#16664163)
Are there any plans to make them happen this year?
Re:100 days with Rust: a series of brick walls by steveklabnik on Saturday March 24, 2018 @02:02AM (#16665114)
Not just this year, but by the third quarter.
Re:100 days with Rust: a series of brick walls by saghm on Friday March 23, 2018 @10:57PM (#16664536)
I know this won't help you, but there is an issue tracking this: https://github.com/rust-lang/rust/issues/43353
Re:100 days with Rust: a series of brick walls by swfsql on Friday March 23, 2018 @03:56PM (#16662081)
The last tokio re-ergo really helped me and my classmate.. now we are getting stuff done, and we are enjoying it a lot, since we are combining our connections as instances of async state-machines (which, by the way, a given state may be a sub state-machine).

This is so awesome.