These are chat archives for rust-lang/rust

8th
Oct 2017
VJ
@00imvj00
Oct 08 2017 06:50
let framed = socket.framed(MyCodec::new());
      let (writer, reader) = framed.split();
      let handle_clone = handle.clone();

      let fut = reader.for_each(move |data|{
               println!("Data arrived : {:?}", data);
               Ok(())
            }).then(|_| {
                    println!("Then is coming here." );
                   // let sender = Sender::new(handle_clone,writer);
                   // sender.send("Hello world".to_string());
                Ok(())
            });
     handle.spawn(fut);
here, after for_each, then block is not calling, am i doing something wrong.
Denis Lisov
@tanriol
Oct 08 2017 07:19
AFAIU, it should work after you close the socket... doesn't it?
VJ
@00imvj00
Oct 08 2017 07:20
nope, so, i figured out. for_each returns Item = (), error = Some error., so after for_each only combinators with error will be called.
VJ
@00imvj00
Oct 08 2017 07:48
let sender = Sender::new(handle_clone, writer);

      let fut = reader
                    .then(move |data|{
                     println!("Data came {:?}", data);
                     Ok(())
                }).and_then( |_|{
                    sender.send("Hello".to_string());
                    Ok(())
                }).for_each(|_|{Ok(())});
     handle.spawn(fut);
throwing
let sender = Sender::new(handle_clone, writer);
   |           ------ captured outer variable
...
48 |                     sender.send("Hello".to_string());
   |                     ^^^^^^ cannot move out of captured outer variable in an `FnMut` closure
how to solve this ? should i implement clone for sender ?
Denis Lisov
@tanriol
Oct 08 2017 07:51
Better to implement Sink for the sender and use forward
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 10:19
Guys. Realistically, does it really make sense to use rust for web development? In which situation would it be fine, and when wouldn’t it be?
I’m talking about the server sided part with the likes of rocket etc. I know you can compile to wasm but that’s not what I’m talking about
Ashley Mannix
@KodrAus
Oct 08 2017 11:37
@JenteVH I quite like Rust for web development, because the language works nicely for large/complex codebases. Where it's 'fine' vs not I guess depends on your constraints. It is a complex language and although tooling has infinitely improved this year it's still not as slick as C# with R#. There also doesn't seem to be a lot of info out there about how people are building real web apps with Rust, so there's some exploration to be done. Pragmatically you might find yourself gravitating towards a more established language for web dev if those things are a concern, but in the next few years I think Rust will have an even more solid story in this space. If you're happy to bet on that then I think it's a good time to get your feet wet with it. Although I'm not sure if we're going to see some kind of asyncpocalypse in the future... I think we'd do our best for that not to happen though. Anyway, those are my random thoughts. If you don't get the kind of info you want here maybe throw the question out on twitter?
@killercup might also have some better insight
killercup @killercup has been summoned and will now dispense knowledge
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 11:40

@KodrAus I can see rust growing big in the future. That’s why I’m dedicating some time every week to learn a bit more of it.

Problems I have with the web side of things right now are mostly the fact that ‘established’ web frameworks don’t seem to be production ready. Iron seems to be dead, rocket requires nightly

The thing is that I don’t really have that much time to put into learning things right now so I wouldn’t want to spend a bunch of time on something that will be entirely different in 6 months time either
Pascal Hertleif
@killercup
Oct 08 2017 11:43
so, web dev in rust, an interesting question. i'd say that if you want to be productive writing a typical CRUD app tomorrow, choose something else. if you want to solve a hard problem (high perf, small memory footprint, embeddable in other systems without overhead), spend some time with rust, and, after a month or so, I bet you'll have something working, and have also probably published a crate or two for things that you need but were missing in the ecosystem
unrelated to actually producing production code, learning rust will most likely make you a better programmer in other langs as well
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 11:45
Oh definitely. Working on that part regardless of the web part
For some reason though I feel like rust as a language won’t really ever be mainstream for web development work. There’s so many ‘get-by’ programmers in web development that wouldn’t ever want to touch anything ‘as hard as rust’ (in their eyes). Fair assumption?
Pascal Hertleif
@killercup
Oct 08 2017 11:53
@JenteVH let me answer with an assumption of my own ;) rust really shines when it comes to maintainability IMHO, but that only matters in larger code bases. only a few web projects i've been part considered "it needs to be maintainable in 3 years" a priority. at the same time, micro services are a great way to sound cool while only dealing with small "isolated" components…
i personally hope that async/await and an easier tokio design will lead to more adoption, but i doubt rust'll ever be 'mainstream' for web dev
(and that's totally fine)
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 11:57
So you don’t see the likes of java(spring) being replaced by rust(rocket(?)) kind of ever?
Diggory Blake
@Diggsey
Oct 08 2017 11:59
One of the most non-obvious benefits for me using rust in production has been the tiny docker image sizes: we use kubernetes and with our python app we have a ton of issues due to the huge size of the docker images (many image pull failures) and it makes deploying with zero downtime a somewhat stressful experience. Our rust-musl docker image is literall 1000x smaller, and deploys so quickly you can't even observe the incremental rollout!
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 12:00
@Diggsey Good point. Although this leans the same direction as @killercup ’s comment in regards to rust being fine for large code bases and maintainability
Diggory Blake
@Diggsey
Oct 08 2017 12:01
true, although the difference is very noticeable even at the level of small isolated microservices
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 12:02
So did you create your own webservice or are you on something like rocket?
Diggory Blake
@Diggsey
Oct 08 2017 12:02
we just use iron
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 12:03
Any concerns about the fact that it seem iron development has slowed down a lot?
Diggory Blake
@Diggsey
Oct 08 2017 12:04
I preferred to stay on stable, and there was actually very little glue code to get a iron/juniper/diesel starting point - not really, iron provides the "obvious" interface if we really needed to it would be no real issue to swap it out
I think using rocket is a much more risky proposition right now
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 12:04
I guess so, but it does look promising doesn’t it
Diggory Blake
@Diggsey
Oct 08 2017 12:06
I definitely see the value in providing an easy to use path for people moving from python, ruby etc. but I generally prefer to stay away from frameworks as opposed to libraries - that said I think rocket is sufficiently opinionated to provide some useful abstractions that may influence other libraries too
I think the efforts it goes to to prevent security issues that are common in other web frameworks are very impressive too
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 12:09
I hope we get some stable release some time soon though
Diggory Blake
@Diggsey
Oct 08 2017 12:11
rocket does rely on a lot of unstable features though :P
Jente Van Heuverswyn
@JenteVH
Oct 08 2017 12:12
Unfortunately