Introducing Laravel Rust

15 points by ajeetdsouza 13 hours ago on lobsters | 7 comments

chuck | 12 hours ago

I've been professionally writing Laravel for 6 years.

At some point in that period I think that the framework was completed. Volt and Folio were the first round of features that seemed to be searching for a problem. This is a whole 'nother level of searching for a problem.

tclancy | 9 hours ago

Is it? I have no dog in the fight (Django person here), but huge performance improvements with stronger types and (theoretically) memory guarantees are pretty compelling. If you’re committed to continuing to write things by hand then yes, this is pointless. But if someone said “here are all the idioms from Django except in a different language that has some real advantages”, I’m all ears.

ssokolow | 7 hours ago

Agreed.

I use Rust everywhere it's practical for the strong compile-time guarantees which make it easier for me to work on a project I haven't touched in a while without feeling I'm going to burn myself out either writing or manually imitating a high-coverage test suite to achieve confidence that I haven't subtly broken something.

I still use Python with mypy --strict (and beyond) for SQL-y things and anything I'd use Django for because, so far, Rust has lacked an ORM with South/Alembic-style migrations, abstraction over "For this install, we want something other than SQLite", abstraction over SQLite's limited ALTER TABLE, and Django's ecosystem of reusable apps with cross-cutting integration. (And all without the assumption that the end-user will have JavaScript enabled. "Do unto others..." and I consider it a deal breaker whenever I land on a vendor's website and they're not even competent enough to produce a website that can render and navigate properly without being whitelisted in my uMatrix.)

3 pages of procedural macros—55 files as of posting—in just the main framework (to say nothing of intertia-laravel-rust) is a lot to consume, maintain, and extend. My understanding is and experience has been that proc-macros are one of the sharper-edged tools in the Rust toolbox, and should usually only be reached for as the last'est of last resorts.

Problems for which I've reached for macros too soon have tended to end up being better solved by rethinking whatever my implementation was to more gracefully "swim with the current" of Rust's design of structs and traits. And like most composition-over-inheritance-style problems (which tend to rear their heads when ones tries to do OOP-flavor stuff in Rust), the optimal solution is usually the inversion of the current implementation: eg. reverse the structure of the data/logic, facts/intents, etc.

jak2k | 3 hours ago

The first lines of code shown are these:

// src/routes/web.rs
use laravel::prelude::*;

use crate::http::handlers::posts;
use crate::models::User;

pub fn routes(route: &mut Router) {
    route.get("/greeting", async || "Hello World");

    route.get("/users/{user}", async |user: User| user.name);

    route.get("/posts", posts::index);
    route.get("/posts/{post}", posts::show);
    route.post("/posts", posts::store);
}

I wouldn't call this good Rust code. Router is included in the prelude for everything despite only being relevant fot router stuff. The other imports are a bit convoluted too. You end up having an http, models and routes module all importing from each other. It would he cleaner to have a posts module with submodules for handlers (including the router) and models.

Looking into the repo, it seems be completely slop. Why should I use this over a battle tested crate like axum?

mitsuhiko | 33 minutes ago

Looking into the repo, it seems be completely slop

I only read a bit of the code but it looks pretty good. What in your mind makes it slop?

I'm kind of fascinated by this and how it is being presented. I watched the announcement video, and it pretty quickly turns into a coding demo where the guy is demonstrating how to use it, what the API looks like and how nice it is (he says).

But then the whole thing is vibe-coded, he keeps talking like it's just going to be used by agents, why does a nice API or framework even matter at all? Why all these macros that are just bound to complicate things and confuse the agents, they seem aimed at making the API appeal to humans?

I just don't get what the thinking is here. Are the agents supposed to watch the video and go "ah yeah I'll reach for laravel-rust instead of axum" or are the care-taking meat proxies supposed to watch the video and and go "oh my agents will absolutely love this"?

I just feel like if you are going to write the code by hand (which I would recommend), you would prefer to use crates that have, also, been hand-written over a vibe-coded macro slopfest.

If you are vibe-coding, why would you care about the framework? Just go with whatever the agent decides to use, some established framework that has a lot of examples in the training data already, right?