3 ms·
Can't we write and read Rust like Python instead?
by bmacho 3y ago
Can't we write and read Rust like Python instead?
- mrweasel 3y agoThat would be better, I dislike much of the syntax in Rust, but I do love many of the concepts and the overall goals. I don't know, typing in Python is something I do to get code completion to work in VSCode. Mostly I don't care for it, because I frequently find myself using duck typing to solve problems. Python is really good at doing what I mean and not bothering me with "technically you're wrong"... I don't care, the function does what's it's suppose to, I have tests.
- JodieBenitez 3y agoRust is not pretty, but it's not that bad: use actix_web::{get, web, App, HttpServer, Responder}; #[get("/hello/{name}")] async fn greet(name: web::Path<String>) -> impl Responder { format!("Hello {name}!") } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().service(greet) }) .bind(("127.0.0.1", 8080))? .run() .await } Of course, anything with brackets can be improved ! ;-) from sanic import Sanic from sanic.request import Request from sanic.response import text, HTTPResponse app = Sanic("MyHelloWorldApp") @app.get("/hello/<name>") async def hello_world(request: Request, name: str) -> HTTPResponse: return text(f"Hello, {name}")