Great start. Instead of numeric codes, perhaps use an enum for all the acceptable status codes? As Jane Street Says, make illegal state unrepresentable.
This is a good slogan, but there's some subtleties when it comes to HTTP status codes. That is, there are the defined ones, but any number is legit, so you end up with an enum with a member that's basically "anything we don't know about", so it's not as clear-cut as it is in other situations.
Pencil: A Microframework Inspired by Flask for Rust
41–50 of 58 posts
Re: Pencil: A Microframework Inspired by Flask for Rust
#42Earlier quoted context omitted.
Go's networking library actually does call epoll/kqueue/etc on the backend, so it is using nonblocking io. Using nonblocking IO will provide better performance because it will increase the number of concurrent requests it can serve. It's not a silver bullet, and can be very difficult to implement at the application layer to avoid blocking, but it will give markedly better performance.
> Go's networking library actually does call epoll/kqueue/etc on the backend, so it is using nonblocking io. I know, of course. If you reread my comment, you'll notice that it wasn't focusing on the particular syscall that the system uses. > Using nonblocking IO will provide better performance because it will increase the number of concurrent requests it can serve. Because of (a), (b), and/or (c), which I addressed i…
Re: Pencil: A Microframework Inspired by Flask for Rust
#43Earlier quoted context omitted.
>But one of the reasons you're able to process more with async I/O is bypassing the costs of the thread-per-connection model. One reason, not the only, or the most important. The primary advantage of non blocking IO is that the CPU isn't sitting idle while waiting for an IO operation to complete. We aren't wasting an entire core to write the response.
That's not how blocking I/O works! Sitting in a busy loop on the CPU burning power polling the I/O device was, like, how the Apple II may have worked, but it hasn't worked like that on any major OS since at least 1990. Operating systems perform context switches on I/O.
which are very cheap :)
Re: Pencil: A Microframework Inspired by Flask for Rust
#44Earlier quoted context omitted.
> Go's networking library actually does call epoll/kqueue/etc on the backend, so it is using nonblocking io. I know, of course. If you reread my comment, you'll notice that it wasn't focusing on the particular syscall that the system uses. > Using nonblocking IO will provide better performance because it will increase the number of concurrent requests it can serve. Because of (a), (b), and/or (c), which I addressed i…
Right, so Hyper would be faster if it used true asynchronous I/O, right? That was my whole point. I just brought up Go so I had something to compare it to.
Are we willing to wait 6x longer for rust to catch up? Some people are, most people aren't.
Re: Pencil: A Microframework Inspired by Flask for Rust
#45Earlier quoted context omitted.
Right, so Hyper would be faster if it used true asynchronous I/O, right? That was my whole point. I just brought up Go so I had something to compare it to.
Hyper may very well be much faster, but it isn't. Which is the whole issue with the Rust vs Go debates: one is possibly much better, but the other one gets all the code written for it in 1/6th of the time (Rust came out the same time Go did, to great fanfare). Are we willing to wait 6x longer for rust to catch up? Some people are, most people aren't.
Re: Pencil: A Microframework Inspired by Flask for Rust
#46Earlier quoted context omitted.
That's not how blocking I/O works! Sitting in a busy loop on the CPU burning power polling the I/O device was, like, how the Apple II may have worked, but it hasn't worked like that on any major OS since at least 1990. Operating systems perform context switches on I/O.
> Operating systems perform context switches on I/O. which are very cheap :)
Re: Pencil: A Microframework Inspired by Flask for Rust
#47Earlier quoted context omitted.
Hyper may very well be much faster, but it isn't. Which is the whole issue with the Rust vs Go debates: one is possibly much better, but the other one gets all the code written for it in 1/6th of the time (Rust came out the same time Go did, to great fanfare). Are we willing to wait 6x longer for rust to catch up? Some people are, most people aren't.
I don't know whether you're talking about a 6x development speed differential or a 6x performance difference between Rust and Go HTTP stacks or what, but I am pretty sure that by making up numbers like that you're language warring for no reason.
Re: Pencil: A Microframework Inspired by Flask for Rust
#48I've found that whenever I start a small web project in a new language, I always look for the "Flask" of that language. I love using a framework that gives the bare essentials and nothing else. I don't use Rust, but your code examples look great! I understand that Rust has less opportunity for "magic" to clean things up (for example, in Python you can use a decorator to specify a route for a function), but otherwise…
Rust is that thing exactly.
Re: Pencil: A Microframework Inspired by Flask for Rust
#49Copying my comment on this from Reddit: Great, I'll definitely have to try this! I've used several Rust web frameworks, including Iron[1], Nickel[2], and Rustful[3]. Each of them has their own strengths and weaknesses, so I've been launching new web sites using all of them to see what fits me best. (Until now, Rustful felt the most comfortable. But I like the others too!) Now I have one more thing to evaluate! Before…
Re: Pencil: A Microframework Inspired by Flask for Rust
#50I've found that whenever I start a small web project in a new language, I always look for the "Flask" of that language. I love using a framework that gives the bare essentials and nothing else. I don't use Rust, but your code examples look great! I understand that Rust has less opportunity for "magic" to clean things up (for example, in Python you can use a decorator to specify a route for a function), but otherwise…