12 ms·
Announcing Tokio 0.1
- arthursilva 10y agoAmazing work from the contributors, kudos!
- JoshTriplett 10y agoI really look forward to the first production web framework based on futures.
- estsauver 10y agoScala's play framework is pretty good if you can live on the JVM. I've been pretty happy with it.
- JoshTriplett 10y agoTo clarify, I was specifically looking forward to the first production Rust web framework based on futures. I'd like to write web applications in Rust, to integrate with many other libraries and parts of the ecosystem, and I look forward to doing so via a futures-based framework that integrates well with other futures-based Rust code.
- hderms 10y agobeen meaning to check out Play. Akka-http leaves something to be desired, useful though it is
- gbersac 10y agoMe too ! I played with rust as a student, but I am much more productive with scala.
- deleted 10y ago[deleted]
- EugeneOZ 10y agoWould be interesting to read story about naming :)
- adwhit 10y agoIt's a little underwhelming: [0] I enjoyed visiting Tokio (Tokyo) the city and I liked the "io" suffix and how it plays w/ Mio as well. I don't know... naming is hard so I didn't spend too much time thinking about it. [0]https://www.reddit.com/r/rust/comments/4vzomj/announcing_tokio_a_finagle_inspired_network/d62svqf/ https://www.reddit.com/r/rust/comments/4vzomj/announcing_tok...
- steveklabnik 10y ago"Tokio" is one way to romanize 東京, the capital of Japan. [1] "Tokyo" is more accurate in a sense, and so is more popular today, but doesn't contain the I/O pun. The logo also references its metropolitan crest. [2]. 1: http://english.stackexchange.com/a/207016 http://english.stackexchange.com/a/207016 2: https://en.wikipedia.org/wiki/Symbols_of_Tokyo https://en.wikipedia.org/wiki/Symbols_of_Tokyo
- wccrawford 10y agoIt's a really odd way, though, since "kyo" is a single syllable in Japanese and not pronounced "kee oh" like most English speakers do.
- steveklabnik 10y agoI edited my post with a link to some history, you might want to check it out. As someone with very limited 日本語 skills, I find this stuff very fascinating. (And yes, un-learning kyo vs kee-ooh was tough...)
- wccrawford 10y agoYeah, I think I still say it wrong sometimes. To me, it's a word I learned in English, and so I think of it the English way. In that way, loan-words are troublesome in both English and Japanese for words from both languages. Don't even get me started about learning French words in either of them and then learning their pronunciation in the other, and then the actual French. As an example, the Atelier game series.
- z3ugma 10y agoI'm getting an SSL / certificate error...anyone else?
- steveklabnik 10y agoSomeone on Reddit is having the same issue. DNS was changed 12 hours ago, but possibly has not propagated to you yet? Sorry about that!
- pizzapill 10y agoGetting it too. When ignoring the issue I get an error that the bandwith limit has been exceeded.
- deleted 10y ago[deleted]
- koolba 10y agoAs someone who hasn't actually used Rust for anything yet, the example on the root of the site is surprising legible: https://tokio.rs/ https://tokio.rs/ Question for the more knowledgeable Rust folks: Does this code (the echo server example) not handle the situation where the port is already in use? What's the return type of the socket bind in that situation? EDIT: Wow six responses in as many minutes. I think I've created a new objective measure of how popular a programming language will be!
- hobofan 10y ago`let sock = TcpListener::bind(&addr, &handle).unwrap();` This line tries to bind the port and returns a `Result` type which is then unwraped, which will cause a panic when the port already is in use.
- steveklabnik 10y agoGlad to hear it, especially since this isn't really the code you'd write most often; this is a library that frameworks will use. So it can be even more ergonomic... > Does this code So let sock = TcpListener::bind(&addr, &handle).unwrap(); Here, the bind method [1] will return an error if it can't bind to the port. unwrap will cause a panic to happen. 1: https://docs.rs/tokio-core/0.1.3/tokio_core/net/struct.TcpListener.html#method.bind https://docs.rs/tokio-core/0.1.3/tokio_core/net/struct.TcpLi...
- yammajr 10y agoThis code does not handle the situation - the program will crash. TcpListener::bind(&addr, &handle).unwrap() Rather than raising exceptions, the paradigm in Rust is to return a Response item, which has an Ok and an Err subtype. unwrap() here assumes that the response is Ok and just gives that back the data returned, or crashes if its an error.
- eridius 10y agoNitpick: The program will print an error and abort. It won't crash. It's a "clean" shutdown.
- jononor 10y agoThat is a serious amount of documentation for a 0.1 release.
- bsaul 10y agoAgree. The documentation would make for a great talk. I'm going to spend a lot of time reading it, because the concepts it introduces are surely going to be useful no matter which tech i'll be using.
- wyldfire 10y agoThe rust community suffers here from humility and a modest default (`cargo new` puts you at 0.1.0 by default).
- akiselev 10y agoFutures-rs and Tokio were started by prolific Rust contributors so the community is gravitating towards making these crates the canonical async libraries for Rust. Since async primitives are so important and used in so many different ways, the maintainers are taking it slowly so that the community can provide as much feedback as possible. It may not be in the standard library but futures/Tokio will be the basis for most high level async in Rust so it's critical to get it right.
- JoshTriplett 10y agoThe Rust community also takes semver quite seriously. 0.1.0 can break API compatibility when it moves to 0.2.0, so prototypes that want to iterate on API stay pre-1.0 until they feel confident in their API. The Cargo ecosystem has shockingly few 2.x or 3.x versions.
- kzrdude 10y agoWhen you say this, what experience are you comparing to? Any particular package ecosystems, or a general rule? Thanks
- 10y ago
- anonyfox 10y agoI really want to know if the eventually arising full-blown web framework in rust still can claim "zero cost abstractions", and if this would translate into basically "the most performant/efficient way to write a web-app".
- leeoniya 10y agoprobably just to "serve" a web-app. until WebAssembly is a common thing.
- steveklabnik 10y agoSo, when what was to become tokio was first announced, we did a check to see how it compared to writing mio by hand. The two were within 0.3% (not a typo, one third of a percent) of each other. That was before any optimization work was done. One of the core premises of tokio is that this compiles down to the state machine you'd have to write by hand if you wanted to do asynchronous stuff. So yes, this is very much intended as a zero-cost abstraction.
- anonyfox 10y agoYes, I got that. So to build a "small" web framework like express.js, one could build a routing layer based on macros (like Phoenix/Elixir or rocket.rs do), plus JSON-serialization (Serde might do it) and a compile-time HTML-templating-engine, all of those leveraging zero-cost abstractions once Macros 1.1 land in stable, right? Then stuff like spinning up 1 OS-thread for every CPU core and scheduling requests in round-robin (?) style, and then wrap it all up into a developer-ergonomic thing. Since you probably have a way better insight into rust-dev and the ecosystem, can we stay tuned that this eventually will happen or are there still showstoppers somewhere?
- steveklabnik 10y agoYup! So for the next step up, see this example of using hyper with tokio: https://github.com/hyperium/hyper/blob/tokio/examples/server.rs https://github.com/hyperium/hyper/blob/tokio/examples/server... You could see how that match block functions as a router... I was literally playing around with this last night. There's a lot of experimentation going on in the server-side Rust web framework space right now, and I expect it to heat up even more now that tokio has had a release. > once Macros 1.1 land in stable, right? So to be clear, macros 1.1 gets you custom Derive, which is Serde/Diesel. It'll be stable in the next release in ~3 weeks. It won't get you the full ability to use any custom attribute, like https://rocket.rs/ https://rocket.rs/ uses. > Then stuff like spinning up 1 OS-thread for every CPU core This is not implemented in tokio yet, but in my understanding, it's coming.
- openasocket 10y agoThis is all very impressive, especially since AFAICT Tokio is only about 5 months old and consists of tens of thousands of lines of code spread across a half dozen different repositories. I'm anxious for the day when I can use Rust at work. All I'm really missing to justify using it is a bit more mature ecosystem. Especially a full featured, stable AWS SDK.
- steveklabnik 10y agoHave you tried https://crates.io/crates/rusoto https://crates.io/crates/rusoto ? I haven't, interested to hear what people say. It was announced roughly in August, so yeah, five months. Though some work had to happen for that initial release, of course. There was a joke though, about this rapid development. Someone said something like "That they keep re-writing tokio is really annoying as a user, but I guess if Rust is so productive that you can throw out huge chunks and re-build it that quickly, well, that says good things about the language." Of course, as the post says, things will be more stable now.
- curun1r 10y agoRusoto seemed like a good effort last time I looked, it didn't have very full coverage of the AWS API. Amazon just has so many APIs that it's a huge dev effort to implement it all and keep up with changes. This is a problem in other languages where Amazon doesn't contribute to keeping the client up-to-date. I'm hopeful that with macros 1.1, the situation will improve since it will enable compile-time code generation based on the official json files in botocore. Just add that repo as a git submodule and then: #[derive(Aws!("s3/2006-03-01/service-2.json"))] struct S3; Becomes up-to-date with the latest changes from Amazon the moment they're released (recompile required). Procedural macros are really exciting with regard to writing/consuming APIs as they enable both the client and the server interface to be implemented in an API specification language (Amazon uses custom JSON, but Swagger/RAML could work too) instead of Rust with zero performance penalty (gotta love those zero-cost abstractions :-)
- matthewkmayer 10y ago
- zimbatm 10y agoThe term "zero-cost abstraction" is a bit annoying. By definition an abstraction has an obfuscation and compilation cost even if it doesn't add to the runtime cost. Too much of these and the program is not understandable anymore and takes hours to compile.
- staticassertion 10y agoZero cost abstraction has never meant anything other than 0 cost at runtime, so I don't see why you would get annoyed at it being used accuratcly.
- p0nce 10y agoI wish the term wouldn't exist. I've measured "zero-cost abstraction" that weren't quite so when profiled. What it really means is "if the inlining goes like the programmer expects, then it should have no cost". The term expresses hope. But inlining is best left to the compiler, and hope is of little value until measurement is done with a profiler.
- stymaar 10y agoInrust you can tell the compiler to always inline a given function.[1] But you don't necessarily want to do that since you may not make the most efficient use of the CPU cache. [1] https://doc.rust-lang.org/reference.html#inline-attributes https://doc.rust-lang.org/reference.html#inline-attributes
- fooyc 10y agoAsynchronous programming is hard, even when hidden behind abstractions like futures or promises. It was cool and trendy when libevent and Nodejs came out, but now we should all have the experience and knowledge that tell us to stop doing asynchronous I/O. Go, Hakell, or Erlang do a great job at concurrency, without the async i/o craziness.
- steveklabnik 10y agoWhat specifically makes it so? Why do libevent and Node give us "the experience and knowledge to tell us to stop doing asynchronous I/O"? I can appreciate a polemic, but I also appreciate substance ;)
- fooyc 10y agoWhen the ecosystem is synchronous like the Rust ecosystem, you are basically going to rewrite everything. All your network code, all your client libraries. Async code can not use synchronous code because this would block it, and prevent it from returning to the event loop. This is a tedious task, and you end up with less tested, less complete code (at least during the first few years) compared to the sync libraries provided by vendors and std libs. Event Nodejs still doesn't have ported the world to async yet, and still uses a thread pool under the hood for a number of things (e.g. name resolving), which defeats the promises of async I/O. Synchronous code can not use asyn code either because, well, in order to get anything from async code you have to be async yourself. Async code is also more difficult to reason about compared to classical blocking code. The idea behind async code is to avoid the cost of context switches and the memory usage of OS threads. But they are not the only way to avoid these costs. Go, Erlang, Haskell do a great job at this, without forcing the world into async. And since this guy is way better than me at writing, I'm going to leave this url here : http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...
- pcwalton 10y agoI really dislike the "what color is your function" article, because it pushes the idea that Go's userspace M:N threading is somehow different from everything just being synchronous and using threads. It isn't. Go just doesn't have async I/O, with a particular idiosyncratic implementation of threads.
- shmerl 10y agoInteresting usage of Serbian domain (.rs).
- steveklabnik 10y agoThey're pretty common in Rust, since that's the filename extension.
- wildchild 10y agoInstead of adding concurrency to rust adding javascript-like hell to it. Brilliant.
- fooyc 10y agoThey don't want to add abstractions to the language (e.g. Green threads). So, they are doomed to add abstractions to the libs instead, and one way to do cheap concurrency without the help of the language is to use async I/O. And by cheap I mean cheaper than OS threads. The reactor pattern still adds a lot of CPU overhead to each I/O operation. What's interesting is that Rust had green threads at one point. They implemented that by making std::io async-capable under the hood. But they didn't like it: too much abstraction cost, and it was preventing to add more native i/o features easily. So they ditched it and now they are doing exactly the same thing to I/O, just in user space, and without green threads.
- mercurial 10y ago> And by cheap I mean cheaper than OS threads. The reactor pattern still adds a lot of CPU overhead to each I/O operation. You need to pay for concurrency one way or another, there is always going to be some bookkeeping overhead. Whether you pay the price in your language's runtime (like Go) or in a library doesn't mean you're getting for free. However, it looks like the design of Rust's futures will let it reach very throughput.