Live data from Hacker News

Rocket, Rust Web Framework, v0.2: Managed State and More

rocket.rs

21–30 of 62 posts

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#21

Earlier quoted context omitted.

It is readable, but you are right it is terribly formatted with a lot of not-very-important information in huge fonts. I think rustdoc needs quite a lot of work in general. For example it doesn't even give a list of methods at the start of each type's page. Want to know which methods you can call on a `String`? Enjoy scrolling... https://doc.rust-lang.org/std/string/struct.String.html

The +/- button will do that for you. It's one of the first things I do once I read the top example.

We've discussed flipping the defaults; it was decided before I started writing so many docs and examples. Very different today!

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#22

Earlier quoted context omitted.

It is readable, but you are right it is terribly formatted with a lot of not-very-important information in huge fonts. I think rustdoc needs quite a lot of work in general. For example it doesn't even give a list of methods at the start of each type's page. Want to know which methods you can call on a `String`? Enjoy scrolling... https://doc.rust-lang.org/std/string/struct.String.html

The +/- button will do that for you. It's one of the first things I do once I read the top example.

Ah I never noticed that. Yeah that is quite nice but I expect 99% of other people don't notice it either.

I definitely think the defaults should have everything except the description at the top collapsed.

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#23
If there's anyone here with experience using both Rocket and Iron, would you be willing to share your thoughts on the differences between them?

I've got an API server started in Iron, but I have to say the claims of productivity and less code overhead that Rocket is proclaiming seem pretty nice right about now.

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#24
post #5

Just curious, I really want to like Rust but take a look at the State API documentation for managed state feature: https://api.rocket.rs/rocket/struct.State.html (screenshot: http://c.ekin.io/3c2q112x1p0y ) Is this readable to Rust people? I mean, can you look at this and say, "ah ok, I'm gonna call this and that then I'll have the state" directly? I'm lost but I have zero Rust knowledge so this is a sincere question…

There shouldn't be methods without examples in any documentation.

Unfortunately Rust is not as revolutionary in this regard as in others :/ but other languages/ecosystems/tools are just as bad :(

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#25
post #5

Just curious, I really want to like Rust but take a look at the State API documentation for managed state feature: https://api.rocket.rs/rocket/struct.State.html (screenshot: http://c.ekin.io/3c2q112x1p0y ) Is this readable to Rust people? I mean, can you look at this and say, "ah ok, I'm gonna call this and that then I'll have the state" directly? I'm lost but I have zero Rust knowledge so this is a sincere question…

My initial instinct is to ignore all of that documentation in your screenshot.

Specifically, the first thing, inner(), says that you generally don't have to call it because there's a Deref implementation. Deref is a trait that lets you implement things that loosely resemble smart pointers or similar wrapper types: for instance, CString, which tracks a Rust-owned C-compatible string (null-terminated), has a Deref implementation to an array of bytes. So I know that I can usually use a State when a function seems likely to want an &T or Box or similar, and I can carry on and not care very much more until I need to.

The rest are trait implementations of common traits (Debug is like Python's repr, PartialEq and Eq are comparisons, etc.), and the documentation is from the trait. I think this is a rustdoc weakness, but I know about it, so I can ignore reading the docs.

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#26
post #5

Just curious, I really want to like Rust but take a look at the State API documentation for managed state feature: https://api.rocket.rs/rocket/struct.State.html (screenshot: http://c.ekin.io/3c2q112x1p0y ) Is this readable to Rust people? I mean, can you look at this and say, "ah ok, I'm gonna call this and that then I'll have the state" directly? I'm lost but I have zero Rust knowledge so this is a sincere question…

The first time I went on a Rust doc page I felt exactly like you: «what the hell is this mess ! I understand nothing».

But a few weeks in, it started to make total sense, and now I see the page you link to and I'm like «That's pretty clear, no problem here». It just takes a little time to get used to the documentation syntax and formatting I guess.

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#27
post #5

Just curious, I really want to like Rust but take a look at the State API documentation for managed state feature: https://api.rocket.rs/rocket/struct.State.html (screenshot: http://c.ekin.io/3c2q112x1p0y ) Is this readable to Rust people? I mean, can you look at this and say, "ah ok, I'm gonna call this and that then I'll have the state" directly? I'm lost but I have zero Rust knowledge so this is a sincere question…

I find rustdoc's default layout to be suboptimal. Javadocs[0] give you the method summary table right below the prose and they are screen-filling like wikipedia, so the prose does not take up too much space.

With rustdoc you have to click on the [-] in the top right to get an overview of the available methods.

But yes, once I have that overview I can usually pick out the methods I need. The type signatures can be a little complex, but so are C++ templates.

[0] http://download.java.net/java/jdk9/docs/api/java/util/Option...

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#28
post #5

Just curious, I really want to like Rust but take a look at the State API documentation for managed state feature: https://api.rocket.rs/rocket/struct.State.html (screenshot: http://c.ekin.io/3c2q112x1p0y ) Is this readable to Rust people? I mean, can you look at this and say, "ah ok, I'm gonna call this and that then I'll have the state" directly? I'm lost but I have zero Rust knowledge so this is a sincere question…

The "traits" feature of Rust's type system provides a lot of nice polymorphism and general ergonomics, but one consequence of its existence is that you see a lot of trait-related noise in the docs and it's maybe emphasized more than it should be by the styling.

If you know Rust, it's pretty easy to cut through it if you know what you're looking for, and sometimes it's actually useful.

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#29
I tried to build a simple Rust "hello world" + database web app the other day (edit: not with Rocket) and after four hours I had nothing to show for it. I had a simple static app in just a few minutes, but I could not for the life of me figure out how to maintain state like a database connection pool and make it available to request handlers in any sane and maintainable way. (There are ways to do it insanely and unmaintainably for sure.) Has anyone else had this experience?

Re: Rocket, Rust Web Framework, v0.2: Managed State and More

#30
post #18
post #7

Earlier quoted context omitted.

Are reverse proxies always the way to go?

No. Usually web application would be exposed through FastCGI or similar protocol. Insisting that either your tiny web application that can do next to nothing is the thing that owns 80/tcp (and/or 443/tcp) or runs behind a HTTP proxy is stupid. Proxying HTTP requests properly is harder than it sounds, which is surprising every now and then and thus is easy to screw up (what happens to Host: header? who is the TCP clie…

Interesting.

I only met FastCGI in PHP. All NodeJS apps I saw used HTTP.

Is there any benefit of doing it that way?

How does it work with WebSockets?

Post reply on HN