1. 26
  1. 24

    I’m a little conflicted on this article. On one hand it covers a lot of ground in terms of features. On the other, Rust on Nails doesn’t provide “batteries included” and “conventions over configuration” of even the earliest versions of Rails. Even though author calls it a framework, they start by choosing a web server and a router, and keep doing it for all the components. Amount of boilerplate will shock any RoR developer unfamiliar with Rust, too.

    So, A for effort but it’s kinda false advertising. Don’t get me wrong, I’m excited it’s possible to cover that much and piece together a semblance of a framework but there’s a RoR comparison is a little premature.

    1. 8

      Kinda is gracious. This felt like a write up of “things I used”.

    2. 10

      If you’re going to pitch this as a Rust thing, using the go tool dbmate is definitely cheating

      1. 4

        I think dbmate is great but sqlx already provides migrations so there’s at least an explanation missing as to why dbmate is better suited.

      2. 5

        I initially came to this article thinking more or less, “there’s way too much manual choice and wiring involved here to call this ‘batteries-included’.” After sleeping on it, I’ve decided that while that is true, it’s actually more reflective of how I think work tends to get done with Rust. This is also where its strengths lie: i.e., wiring up just enough of other people’s code to speak a few common trait protocols (serde, tower, log/trace facade, etc.) while picking the actual providers based on your specific needs.

        Django, Rails, Next.js, et. al. generalize patterns for most applications and let folks deal with highly-unoptimized paths (e.g., N+1 queries) later. That’s a good tradeoff because even those degenerate cases are cheap for most applications relative to any drag on iteration loops. They’re written in languages and supported by ecosystems that value rapid development, access to a huge collection of libraries, and high-level plugin APIs above all else. Performance, type safety, and low-level access to native APIs for I/O, FFI, or even database backends are less important in that context.

        Rust OTOH really comes into its own when you have particular needs those very high-level languages and frameworks can’t meet. Static binaries, fixed/tunable memory usage, copy-free sharing, etc. are all “dark magic” for most Python or Node developers, but more or less the defaults for idiomatic Rust.

        It might actually be more informative to look to Java/J2EE and .NET for inspiration when it comes to Rust framework design. Both have a strong community of practice who understand and teach norms for library selection, overall project architecture, and application bundling. Both are commonly applied to tasks with fairly tight performance and resource usage constraints. Neither actually gives developers straightforward tools to do e.g. manual memory management and other “data lifecycle” tasks without resorting to C++.

        1. 3

          I would like a convention-over-configuration framework for Rust.

          Also, don’t have have time to take a real look at it right now.

          But wow, that name is super cute.

          1. 4

            The blog post is posted now and locked in time now. Time continues forward always. This article diverges starting now.

            Frameworks sometimes have upgrade guides going from version to version. Unless someone packages this blog post as a tool, with generators and CLIs, it’s copy-and-paste which is forking and bit-rot start.

            Even generators have a tricky problem of revisiting vs heirloom configs. If I generate a project using the FooFramework on 1.0, follow the upgrade path from 2.0 -> 3.0 -> 4.0. What do I expect to happen? I generated 1.0. Now the world is on 4.0. Who tells me where I’m at with my mix of libraries and decisions? Deprecation warnings along the way? Even the most battle-hardened frameworks, docs and communities have bit-rotted comments in this situation.

            I would not want to be running “stuff from a blog post 0.0.0”. However, that doesn’t mean this blog post is bad. It’s got the steps and recommendations (which are valuable). Next step, make a script or a template for people to use. But now it’s heading towards a framework.

            It’s like script iteration:

            • Write down the steps, curate things, collect knowledge
            • Put those steps in scripts
            • Polish the scripts into programs
            • Apply software rigor etc

            I like all the Rails copycats. It’s good for everyone. Next, Redwood, Blitz, Remix are all very familiar. Would be great to see a low level language pull this off. My current thoughts are that it can’t be done for whatever reason or I’m wrong and it just hasn’t been done yet. Very hard to do tippy-top abstractions in assembly. Rocket and Buffalo (Go) are the nearest I’ve tried.

            Someone on twitter said something like

            rails for rust? be careful what you wish for

            I think if the idea is solid, implementations will converge.

            1. 5

              As an aside, there is one generator/template-builder/cookiecutter alternative that actually supports updates: https://copier.readthedocs.io/en/stable/updating/

              1. 1

                Very cool. Bookmarked.

                When updating, Copier will do its best to respect your project evolution by using the answers you provided when copied last time. However, sometimes it’s impossible for Copier to know what to do with a diff code hunk. In those cases, you will find *.rej files that contain the unresolved diffs. You should review those manually before committing.

                Mac does this on updates. It makes a directory on the desktop called Relocated Items full of files it doesn’t know what to do with. Redhat/CentOS does .rpmsave (iirc), debian/ubuntu does .dpkg-old.

                Note that this is only a problem with code comments (not annotations) that don’t execute. There’s a way to verify you don’t have regressions on upgrades: testing on many levels. And deprecation warnings (annotations). But not docs and comments (without some hoops).

                I tried to update my PC bios recently (excuse the example) and I tried to go from A -> C. It said my .zip was corrupted. I had to go from A -> B -> C. And it worked. Same file. It can’t even error cleanly. A has no idea what the file C from the future is. B had a breaking change.

                1. 1

                  Interesting. I have my own Cookiecutter clone. Maybe I should start dumping answers to interactive questions to the user cache directory so that it can be rerun easily.

              2. 3

                I tried building one years ahead, but wasn’t able to find collaborators. Had a good name though: gerust.

              3. 2

                Now make it to where I don’t have to do any of this setup work!

                1. 2

                  I laughed at the play on Ruby on Rails