|
|
|
|
|
by sergiotapia
1312 days ago
|
|
With all due respect does anyone else find Rust's syntax just horrible? #[get("/")]
#[actix_web::main]
std::io::Result<()>
HttpResponse::Ok().body("Hello world!")
I mean, blegh! Anyway, just making conversation please don't take offense, some people think Ruby looks like ass. |
|
There's (at least) three things going on in the snippet you posted. One is that actix, like most (all?) Rust frameworks, is macro based; that code would look pretty similar if it were written in Flask, but with different syntax.
Another is that the strict type system can lead to some heavy verbosity, eg having to populate the generic in `std::io::Result<()>` with unit (`()`) just to say you're not returning anything.
Regarding `HttpResponse::Ok().body("Hello world!")`, the builder pattern is also pretty verbose and some people don't like it, but it's friendly to the type system and you can use it to provide really cool guarantees (like not being able to call `build()` until you've fully populated the builder).
Generally I'm of the mind that computers should conform to the needs of people and not the other way around, but programming language are a place where I'm willing to make many concessions, since as a rule humans are smarter than compilers.