ERRATA - 1:01 We miss you Aaron, we need you now more than ever ua-cam.com/video/9vz06QO3UkQ/v-deo.html - 6:15 This is correct: map_err() takes a function, and InternalServerError() IS a function, albeit a confusingly-named one. docs.rs/poem/1.3.57/poem/error/fn.InternalServerError.html
6:15 map_err should take a closure. Also prefer returning the raw error and mapping it externally with the framework so the actual error could be logged.
Thank you for the tribute and mention of Aaron. I get so mad at people who trample on the things he's created; he was a good dude who only wanted what was supposed to be free information to actually be .. free.
@@NoBoilerplate Seconded. My daily notes are in markdown and RSS is how I get my podcasts. His story really reads like a classic tragedy in a modern setting. While trying to not make things too melodramatic: In a bittersweet way, among the many things wrong in our current culture, he is a reminder that there are good people out there. And, even if they get overwhelmed or screwed over, their good deeds can still go a long way.
His legacy is tainted by what Marak did with Faker.js and Colors.js - distributing malware through open source channels is not an effective form of political protest
I don't really get a chance to use Rust, but learning it made me a better TS developer. My codebases now use deeply immutable objects and zod for runtime validation. When it comes to making API calls its like the KGB. "Trust, but verify" I return errors instead of throwing them too.
Me too! I've started using generics much more than overloads. I use the rust naming conventions (such as snake_case) for custom vars, and camelCase for stuff that behaves like built-in JS stuff. I've learned to use some FP constructs to avoid using `let` instead of `const` (such as IIFEs, while we wait for `do` expressions). I've learned to modularize my code, and I even write "boilerplate" to make my code safer and more readable (such as implementing a basic `range` generator, to do for-loops like in Rust and Python. Of course, I only do this for "small projects" where importing a whole lib is inconvenient). And more! Learning Rust literally changed my way of reasoning about programs, and it changed my life (not in a *EXTREME RADICAL* way, but considerably enough)
I think they're not known or consumed as much as they should be; needs more exposure. However, I think they're rated very highly by the community. All the top Rust voices seem to speak very highly of this content, as they should.
5:00 Wow! Congratulations and respect on taking that step, and best of luck to you in the future. Your content stands out to me for being both unique and high in quality: A distinct style with a clear structure that shows technical expertise and practicality in the matter, while still integrating your personal (occasionally uncommon, yet intriguing) preferences.
Yes! I’d love to hear your thoughts on Leptos. I love it, I’ve been using it for a product that I plan to launch later this year, I think it’s plenty stable!
@@JOHNDATGOONV2 That's the thing with Rust code - it's pretty much all stable! XD Joking aside, I think it's a great tech choice for a project you'd launch a bit later on, perf!
My main problem with picking a stack is that it should be easier to make your own. A reasonably good async framework should be possible without unsafe using only the standard library. And my brain almost broke trying to convert Pin to Pin (I accept that this one might need some unsafe).
Thanks! A few people don't like it, but most do! I like to always know how far through a video I am, and touching/clicking on the screen all the time doesn't do it for me!
I make stacks by planning their acronyms. like the FAST stack (F)lutter (A)ctix (S)velte (T) ypeScript I never used it, but I have to say its my favourite to look cool.
Hah, I did some work a few years back on what-would-become the activej framework :) Yes the uber-optimization down to writing specific java code that would get JIT-ed to specific machine code was something that they did - not me, I was a student, too dumb for that part of the thing, at least at the time - ok one thing I worked on was the dependency injection thing, that part I'm proud of lol Also the magic specializer which converts DSL code into handwritten-like bytecode at startup, essentially getting those sweet zero-cost abstractions in Java 🙃
@@NoBoilerplate honestly from what I remember, it's relatively not bad, and I really liked the highlevel APIs and DSLs, imo (still) they are close to the best thing you can get in Java (ew, Java) However, there was a moment when I committed something to master that broke the tests (yes we rebased-and-committed straight to master) and the guy was almost yelling at me for not running them before pushing (I forgor 💀) and I was trying to suggest "um we can setup like an automated thing that would run the tests whenever you push something [to master]" - not yet knowing at the time what CI is or what are the better practices of it omg - and they didn't have that, and I just looked at the activej repo - they still don't
@@necauqua to be fair, most companies just started investing into CI/CD in the last few years, as it only started to proliferate with stuff like gitlab. I know the more wealthy java houses I worked with decades ago had their own build pipelines already with CVS and SVN, but testing was still often done with manual processes or only around releases.
1:30 out of curiosity: why colour-eyre over something like error-stack? Error stack preserves the underlying type used in the error and still has all the niceities of color-eyre with a few extra features. I personally don't see why somebody would use eyre over error-stack if they are focusing on correctness
Interesting! I wasn't aware of error-stack, probably because it's just a year old. I trust anyhow a LOT, it's the #1 results handler in Rust, and so Eyre being a fork I don't have to think too much about before recommending. I will follow error-stack with great interest, thank you!
@@NoBoilerplate btw, error-stack has full support for Eyre and anyhow! You just need to enable the feature. It's based around the same idea of building up a report from context, except the context is fully typesafe so you can use e.g. enums as errors
I just started learning Rust, and even the configs and basic boilerplate looks intimidating. I'm defiantly not going to be leaving my SvelteKit safe space in the front end for a long time, but the Rust ecosystem for backend looks like it's worth my time.
Totally understand, it is a bit intimidating! Whenever you want to learn, here's my video for teaching yourself Rust: ua-cam.com/video/2hXNd6x9sZs/v-deo.html
I'm blown away what rust can to again and the reason I am is that you can get across what's special about it really well. You are great at simplifying things. Maybe you someone outside the field of web dev could have benefited from this skill by you explaining a little more of the server client structure of the web upfront? Just a thought. Having experience in this field it was really pleasant to follow. PS: I still would wish for chapter marks.
4:17 should also be considered that requests/sec doesnt tell the whole story with performance as any framework written in java or js will have greater memory usage and most likely latency even if it is able to achieve greater throughput
While I'm impressed by all the amazing backend support that rust is getting, I haven't really seen a satisfyingly complete frontend rust crate on par with js/ts alternatives like React, Svelte, Vue, Lit, etc. I find that libs like egui or iced are pretty cool, but they're not made for the web, and yew seems promising, but I haven't been able to get it to work with the stability and ease of development that the js/ts ones have, let alone something like Next, Nuxt or SvelteKit (I see rocket, but it really seems to be more of an HTTP framework/backend web framework than a frontend/fullstack framework that I'm looking for). This has really been the only thing preventing me from getting into rust. I'd love to see a video that delves into the web frontends and web frameworks that rust has to offer.
What happened to Aaron was a great injustice & it honestly set the tone for what'll become of the internet I had this thought, since we can use BASH-scripting to automate video editing with FFMPEG Can we do it with RUST & what about Picture-editing ?? (E.g: making thumbnails)
I can't get over of sqlx accessing the DB at COMPILE TIME. This feels so wrong. All my programmer instincts are screaming that this is a path of madness.
Oh it would be TERRIBLE to do this in any other language. But Rust is so comprehensive that it can do these impossible things, see my video: ua-cam.com/video/MWRPYBoCEaY/v-deo.html
@@NoBoilerplate I understand, but what happen if I don't have a local database? it wont compile? so if I'm working at a large company with a large app/db, and I don't have access to replicate a local database (because there's a highly confidential layer of security and you can only do a query to a sandbox limited db where you need to access via website), I wont be able to code? It may be an edge case, but it's based on the company I'm currently working on, it's a pain in the ass to work with sql queries.
@@LuisCassih It's not an edge case - CI would suck if you had to have a db in there right? SQLx has this covered, I talk about it in detail here in the video I pinned when I introduced sqlx, here: ua-cam.com/video/JIvKgSyvtxI/v-deo.html
You are very kind! I have practised public speaking a lot, starting when I was at university - practice makes perfect! I also practised making a little weekly fiction podcast for 3 years before starting this channel. I talk about this all in this video, if you're interested: ua-cam.com/video/fzNk_1xLIKI/v-deo.html
Why didn't YOU do this comparison before making this comment? I gave you the link in the video! Both Fastify and Hono are extremely mediocre: web-frameworks-benchmark.netlify.app/result?asc=0&f=fastify,hono,express,poem
Nice! There's no warp first-party openapi plugin, but people have told me about docs.rs/utoipa/latest/utoipa/ It's less DRY than poem-openapi, but should be a good starting point!
I love your videos! I came across Poem when looking for a Rust web framework that had good OpenAPI support, and seeing your “endorsement” of it makes me more confident in choosing it.
First time on your channel. I do love your concise, informative and pleasant style so far. Could you consider doing a video for startups? You see, for example, we're writing an app with a Flutter front end, which relies heavily on a geographical map component and on webrtc for video calls. The great void in UA-cam is found, for us, in choosing our backend stack and opting for the cheapest possible hosting (cloud vs our own hardware) to allow ramp up until profitability or proof of concept is achieved. Thereafter funding would, one would hope, come elegance in design and scale. There's very few people with the expertise to talk about how to initially scale up fast, cheap and inevitably dirty to a degree. It could be a fun video I believe. Anyway, thank you for your videos, I'll sub now!
*in my opinion* we should rally around Axum as our web framework. its built on top of the tokio stack by the tokio people and its super ergonomic and powerful
I like axum not because of speed or ergonomics but because it's under tokio's development team and therefore I don't fear the framework will fall behind and will be updated even if some dependency introduces breaking changes (ehm ehm looking at you hyper 1.0.0)
How does the sqlx compiler handle CI builds, does he just skip the checks then? This sounds like the build-step would need access to a database, which feels kind of unintuitive.
Already did, they do this with the WILDLY powerful macro system, my deep dive is here ua-cam.com/video/MWRPYBoCEaY/v-deo.html I also talked specifically about how SQLx works in this video ua-cam.com/video/JIvKgSyvtxI/v-deo.html
I just listened to the Oxide and Friends podcast, where they are using their own Dropshot HTTP server to generate OpenAPI from their code, and how that boundary has helped them craft a reliable frontend. Poem looks super interesting!
I don't use Rust daily, but have interest in learning it deeper. Do you think doing Leetcode problems in Rust is a good option? I heard that lifetimes and other features can make simple problems harder.
I actually have a whole video explaining my tips on how to learn Rust, and it centres around Rustlings, a code kata system like leetcode problems! Do watch (and check out the other videos in the playlist if you have time ua-cam.com/video/2hXNd6x9sZs/v-deo.html
Your explanations are so fantastic. I echo the request for a video with html templates with HTMX for interactivity (look mom, no JavaScript). Just exploring Rust, but it seems like the front end story would be greatly helped with a "just return html templates, with tailwind css and htmx for get / post behavior," similar to Jinja, Chameleon in Python.
I checked out poem thanks to you! I loved it and I want to use it in my next project. But I see that I have fears on frameworks like this about their futures, can I get your opinions about it please? What do you think about community-made frameworks and their futures, because we have an example like Rocket. I'm sure that I'll not use these frameworks in billion dollar startups ;) Yet, do you have any trick on understanding which library will stay long enough?
That'd be a good trick! Here's how I evaluate rust crates, I use lib.rs: lib.rs/crates/poem Note the statistics right at the top of the page: - latest release July 23rd 23 (before then, Feb 23, Dec 22, Nov 22 etc) - #9 in 'http server' - 48k downloads/month - used in 116 crates lib.rs surfaces exactly what I need to know, and all without javascript! Rust and the Rust community make STAGGERINGLY stable software - even 0.0.2 crates I trust more than 2.0.0 npm packages!
Appreciate your video. Definitely nice that OpenAPI is built into poem. If I was going to bet on a rust api framework, to me it would be Axum. I enjoyed working in Axum and seems as closest as expressjs as I could find so far.
when you bind your db and your rest api, don't you tie your user facing api to what you store. which is probably ok for something simple, but IMHO for something more complex you want to be able to evolve the API independently from your business layer and DB layer
An excellent point. Yes, especially for API versioning, you'd want that decoupled, which is easy enough, just make another struct. The strict typing of your API, and the compiler keeping you safe when making changes, still applies after this useful weakening of the relationship between DB and API.
OMG! POEM is exactly what I'm looking for, seems to be a god send for HATEOAS. Add htmx to mix and its a win. Your recommendations are solid ;-D I'm actually trying to slay the Excel Makromonster my uncle created... Meaning I finally begun work on it, after procrastinating literally for years now. First step is writing software to analyze the thing for data and app logic. Trying that with pest, egui and calamine. Just managed to get some life-signs today. After that is finished I want a proper custom build lightweight ERP and *"THE STACK"* seems to be a good starting point for that.
I just can't get too excited for htmx, it's easy to get going but suffers from the same unsafety that js does. Try Yew.rs, it's very simple and will give you huge confidence in your frontend!
@@NoBoilerplate nah it's internal tools only nothing exposed for the web. Well you could completely go the SSR HATEOAS route but htmx reduced the boilerplate/templating a lot.
the mention of Jane Eyre gave me a flashback, goddamn that book was long my D:\ drive has the writing on the tombstone of her friend as its namesake - Resurgam
Fair, though isn't memorisation writing, of a sort? Only writing to the medium of your mind, rather than paper - Dijkstra didn't mean the physical act of writing, really, he meant the act of creation. Consider the sentence "I wrote a song", you might physically write the lyrics, but the tune is in your head.
@@NoBoilerplate No, I really never used it. I've seen it a long time ago, but I always thought, I don't want to know that much. I was rather expecting critique on not using Serde :)
Apologies! This isn't targeted at beginners to Rust, however I do have a whole playlist that IS! Here's the exact video in that playlist where I talk about bacon ua-cam.com/video/dFkGNe4oaKk/v-deo.html
Nice video, I'm still trying to learn how to organize projects on Rust, as I'm switching from a OOP type of language (Java), I'm not really used to rust that feels a lot more functional oriented like. I was wondering if you had any tips for that. Also, any tips for Desktop applications with GUIs ? I can't find anything really reliable, I don't feel like it's mature enough yet
Come ask those questions on my discord in #newbie-advice, folks will have great suggestions! I have answers: 1. Enums: ua-cam.com/video/z-0-bbc80JM/v-deo.html 2. wasm inside Tauri (or electron) ua-cam.com/video/P4LMfkFLRsI/v-deo.html
Looks like miette is on the `thiserror` side - creating good library errors, not handling good library errors. I don't write libraries, but if I did, I'd check it out!
@@NoBoilerplatemiette is on all sides: it has guides for using it in either libraries, applications or as the main() return. it's main claim to fame is ultimately very nicely formatted errors, akin to rust compiler errors, which are desirable in applications too.
My main problem with creating backends has been the fact that I don't know databases. I tried taking the databases course at my university, but the lectures were extremely dry and the setup process tedious enough that my ADHD brain gave up (I was also taking my university's Rust course and it was far more interesting, since static analysis is so cool). Since understanding databases seems essential if I want to have any hope of success as a software engineer, do you have any recommendations for a way I could learn how to work with databases that will be manageable? While sqlx looks nice, the fact that you need to use strings to build up the queries means that there likely isn't any intellisense for it (which would make things quite challenging for me).
I too used to feel like this. You could try Diesel, a very popular rust ORM. Here's why I now prefer to write SQL: In every large project I've worked with, we've EVENTUALLY had to write SQL. ORMs don't scale, and the bigger your app gets, the more hand-crafted SQL you have to write. This is the same problem as Javascript, it STARTS OFF nice and simple, but by the end, you wish it weren't so simple, because the edge cases break you. Use SQL with SQLx, and don't be afraid, because the compiler is holding your hand :-)
@@NoBoilerplate that makes sense, but an ORM definitely sounds like a much nicer starting point. Maybe I'll also look and see if there's a kata-like course for SQL! I used Tom Kunc's MacroKata to learn Macros in Rust and it was awesome
Awesome video! I've been using the majority of these and the rest have been on my list to tackle next. Absolutely love the channel and the quality of the videos you put out! Regarding Poem - I actually recently discovered the library/ecosystem after I'd started my first project using Actix & Utoipa for OpenAPI. I had a few concerns and wondered if you have hit any of these? The first was the much much smaller following for this library, and I (probably naively) perceived that the library had less activity. As well as this, I found that the docs aren't as good, as they're mostly just API docs & examples (but the examples are high quality). And my last issue was that I was having some major headaches with converting between error types in the handlers, which was much easier in Actix.
What about graphql with rust? I fall in love with graphql since it gives me output validation on the frontend and really would be awesome to combine Graphql + Rust
I've used async-graphql and juniper. I slightly prefer Juniper, although I think async-graphql may have more features/be more active. Both have been more pleasant to work with than their Typescript counterparts.
What do you use for i18n? I've been trying to get people at work to try Rust, but that's one thing I'm not sure about, because it's so easy to do in the language we currently use (C#), and I don't know if there is an equivalent in Rust yet.
@@NoBoilerplate That's nice, but I mostly write desktop applications. I just found a crate named i18n-embed-fl that looks promising. I'll try to understand how it works and if it does what I need.
Hi Triss How come you write SQL by hand rather than using an object-relational mapper for Rust? Is there a performance benefit? Finer control over database operations?
Two reasons: 1. compile time verification, 2. optimisation. 1. Only SQLx (I believe) with the query_as! macro can check your queries at compile time. Though it'd be more ergonomic to write in an ORM, I happily give it up to get compile time verification. 2. Every project that uses an ORM eventually has to hand-optimise their queries at scale. Universally, with no exceptions. I am fully bought-in to Rust's "upfront the work" mentality, and writing queries in sql, rather than sometimes writing orm and sometimes writing sql is MUCH cleaner. Also, it's very likely you'll write your own functions to abstract both the ORM or the raw SQL, so you might as well get compile-time guarantees!
I really like Nix, and have NixOS on a laptop for testing. However... This whole stack is pure Rust, even using RusTLS, no external dependencies other than rustup.rs. Nix is ESSENTIAL in other languages, but I've found since switching to Rust, I can just choose pure Rust dependencies and never trip up. As Cargo is extremely deterministic, I don't miss Nix there either. The Rust Editions system guarantees anything that compiles today will compile in 40 years time!
Diesel, like all ORMs I've tried so far, does not connect to your real sql database at compile time and validate your queries. Just incredible, check out ua-cam.com/video/MWRPYBoCEaY/v-deo.html
@@NoBoilerplate but you can provide file with sql commands so you will have structures of tables, so you will have some compile time checks like for types
Axum is great! They're all great really. As I said in the intro to poem, axum doesn't have a first-party openapi plugin, and I've heard that those it does have are not ideal.
@@NoBoilerplate The reason I like axum is its well integrated in tokio stack. So I think it will be maintained for a long time. Also having OpenAPI is not important to me, that's just my prespective, its a developer feature mostly and they usually use Postman or something similar. Again great video and I hope you find success now that you are doing rust videos full time. I would love a detailed video on tracing, not a gloss I think basics everyone can get.
@@AbhishekBajpaiHere Thank you so much! Axum's great too, of course. You can't go wrong with the Rust frameworks! What's to know about tracing? The readme's very comprehensive - what value could I add?
I am curious, what is anyone's opinion of Leptos? I've been playing with it and am enjoying it for both frontend and backend. I will have to give Poem a try so I have have no comparison at this time.
Yeah, if you check the link there are some nim and cpp webservers that punch a bit higher than ActivJ, but as I said, you'll never persuade a team to use them, so I feel safe discounting them XD I'm here talking about Rust not just because it's a WILDLY great language, with alien magic in, but that, somehow, despite all this, it's already the #19th most popular language redmonk.com/sogrady/2023/05/16/language-rankings-1-23/
@@user-du9ch3tn2v popularity doesn't matter comparing the top languages, they're all popular enough, but if you see where nim (for instance) is on that graph, it really does matter.
Search and ye shall receive crates.io/crates/axum-swagger-ui Of course, they're not first-party, which was my delight when finding poem, but I bet there's others!
If you're talking about the development experience, SQLx has you covered, I explain their 'offline' feature in this video: ua-cam.com/video/JIvKgSyvtxI/v-deo.html
Ah, so do I. Nim was my gateway from Python to Rust, igniting my passion for single-binary deployment and static typing! Popularity matters, as I always say, so I looked at three mainstream languages that I stood a chance at writing professionally: Go, Haskell, and Rust. Go is ruthlessly practical, but with no beauty, Haskell is beautiful but not practical, and Rust has the best of both, and is somehow greater than the sum of its parts! I wrote this comment on a hackernews nim v rust comment thread last month, perhaps it's useful to read: Nim is too timid. Most languages are too timid. My context: I'm a maintainer of iNim, creator of the Rust channel, No Boilerplate, and a professional python web developer for 15 years. The features you are excited about in Nim are compromised for the sake of simplicity: - Macros can't change syntax, - There's a limit to how real-time the standard language is, - Compiling to javascript is a nice trick, but if it didn't rely on GC it could compile to webassembly, which is better, - Ask any advanced python developer: Indentation for syntax is a bad idea at scale. Hell, have you ever used YAML? What Rust does is a revolution because they solved the problem of memory safety without garbage collection with the Borrow Checker. The knock-on effects are GARGANTUAN. This was a hard problem to solve, and it makes the language more complex to learn, but it unlocks all the language's superpowers. If you 'cheat' with a GC, you get nothing. Nim started its life, just as most languages did with a GC, and the efforts to keep the syntax the same while offering alternatives are greatly compromised. It's far easier to add GC/RC to a low-level language than it is to remove it from a high-level one, where the whole ecosystem relies upon this behvaviour. Of COURSE I know about Nim's plugabble GC options. That doesn't impress me at all (though Araq's effort is to be commended). In Nim they are compiler options, in Rust they're libraries. The difference is vital. For example, at a per-variable level, I can choose to reference count with doc.rust-lang.org/std/sync/struct.Arc.html if I so wish (I rarely need to because the borrow checker is magic). If you want python, you can have it inside a Rust macro, sort of like this crates.io/crates/inline-python because rust macros CAN change syntax. With Macros and no GC, you can rebuild ANY FEATURE inside Rust, the floor of the abstraction is the metal, and the ceiling is the sky. This is what Rust is all about: full power to the developer, no compromises. My video on this topic for those interested is: ua-cam.com/video/PuMXWc0xrK0/v-deo.html I love both languages, but I can only see one language being the standard next 40 years, and demonstrably so can Linux, Microsoft, Cloudflare, Discord, and many others.
@@NoBoilerplate Thank you for the response, and thank you for making it a wonderful response! I feel like I've met a celebrity! I've been loving your videos and sharing them wherever I can. ☺️ The way you reference Nim just caught me off-guard because I had just discovered it and was really liking it. I'm primarily a Python developer, so it was really nice to see similar syntax and I appreciate this simplicity over the very verbose Rust I've been trying to learn. And have you seen the Uniform Function Call Syntax? ♥️♥️♥️
@@LoganVanCuren UFC is SO fun isn't it! Look, learn nim, do it without any guilt, it's a great language. Rust will be here when you want more ;-) BTW Rust has something that feels a bit UFC - you can attach methods to any struct using `impl`. It feels like much looser coupling than classes (though less loose than UFC) doc.rust-lang.org/beta/std/keyword.impl.html
It's because it's actually a frontend for C++, it bypasses all of nodejs and replaces them with native wrappers. SOME might call this cheating ;-) Sifrr is based on github.com/uNetworking/uWebSockets.js You find this a lot at the top of the benchmarks - artificial frameworks that are designed to 'win' framework competitions, but don't actual use your language in a normal way, so you'd never choose them (as you have to throw away much)
Great video! Thanks for the recommendations! Does anyone have experience with generating rust code from an existing openapi spec? I'm just starting on my rust journey and could use sth like that for a side project. Recommendations would be appreciated!
Yeah, sorry Rust just isn't ready yet for web development. I tried it in the past, there isn't a major established web framework that has been tried and tested in enterprise, the ones that exist are underdocumented or undermaintained. Axum doesn't even have a website and is barely documented. I couldn't find a good e2e testing solution in the level of playwright. The orms feel incomplete, nothing like entity framework or prisma. Still, I hope it does get there someday cause rust is a good language. I do think it will with the performance Rust is offering A good alternative to get away from JS in the server is C#. Better performance, has a good ecosystem and tons of jobs. The only downside to it is Microsoft.
Rust is indeed an excellent language, and though you're right that the web frameworks are still being developed, I would trust a 0.2.0 Rust framework over a 5.0.0 JS framework in production every day of the week. Note I say 'trust' not 'use', there are many cases where the downsides of a JS framework (say, react or express) are overwhelmed by the benefits you get from popularity and longevity: If you want gmaps in react you can choose between several plugins. If you want it in rust wasm (leptos or yew, say), you'll have to write that plugin yourself. Some people will be fine with that, others will have to wait, and use React or similar in the meantime. But this doesn't mean that you should write off the whole language, as your comment suggests. That's too blunt. The web stack I feature in this video: poem-openapi coupled with SQLx, TODAY, is better than any other option in any language for building a lightweight API in production. This combination of rust/poem/sqlx gives you features you simply can't have in any other popular language or framework. compared to rails-api or express or django-restful etc etc, the stack I show in this video is more reliable, safer (both memory and high-level) and faster than them all. As a senior web dev, there's one thing above all else that I care about these days: that you can actually finish your project with this stack. It will sit in production, reliably, being upgraded as the compiler improves without a single line of code that needs porting, for decades to come. My team and I can move on to other projects. There's enormous momentum in the Rust ecosystem, I'm testing out leptos for replacing js in my frontend projects, and I'm extremely excited by what I'm finding, for instance. But unlike poem, I don't recommend laptos for everyone just yet, perhaps in a year. What I do recommend is that for people who are sold on Rust, this is a good stack for building an API, which is the vast majority of backend web projects. For now, I recommend to most people to stick a react app or a swift UI on the frontend. But not for long! :-D
Seems like they reimplemented everything from ground up. On the other hand I don't know that framework and it may just be one time show off for benchmarks
Oh, Java's not, Nim and Cpp are the fastest, but they're weird, so I didn't include them. ActiveJ extremely clever, but it's not popular, which is a problem for me, www.statista.com/statistics/1124699/worldwide-developer-survey-most-used-frameworks-web/
@@NoBoilerplate Heh I was being facetious. Watched all your vids, and love them. Does feel though that you love the aspects of Rust that are actually stronger in Haskell than Rust (imo). I wonder if a more FP, and less systems would be ideal
@@dombou70 I adore haskell, learned it 15 years ago and it made me a better programmer in OTHER languages! However, Popularity Matters. I evaluated go, haskell, and rust in 2020 and found go was very practical, but not beautiful, haskell beautiful but not practical. Rust is a wonderful blend of haskell and lisp, all in syntax that doesn't scare people away!
@@NoBoilerplate That's fair. Fwiw, I went through my Haskell phase, and i've also moved on as the community was just too small. I now use TS and it's mostly good enough. I'd love proper ADT's like Rust has, and a std lib built around Result/Option types
@@dombou70 TS is great if you have no option, yeah, I dig it for sneaking in some safety into frontend teams! Yes, this is the exact problem - you can TELL when a language wasn't built around sum types, like TS, if it gets bolted on later, you have deep compromises that you can't remove from the language. RUST IS SO EXCITING FOR THIS
ERRATA
- 1:01 We miss you Aaron, we need you now more than ever ua-cam.com/video/9vz06QO3UkQ/v-deo.html
- 6:15 This is correct: map_err() takes a function, and InternalServerError() IS a function, albeit a confusingly-named one. docs.rs/poem/1.3.57/poem/error/fn.InternalServerError.html
6:15 map_err should take a closure. Also prefer returning the raw error and mapping it externally with the framework so the actual error could be logged.
@@nathan44u Thank you so much - wild that that example is from the official docs and compiles fine!
in 6:15 , the map_err isn't an error, it's a function so you can pass it instead of creating a closure
@@netfri25 oh great! Good to know the poem exmapl WAS right!
what is the http cli you are using to test the apis
Sqlx tapping into the compiler to validate SQL is deep magic. You're making me want to write web apps just to get a look at all this witchcraft.
All apps probably need a little db, dive in!
It’s a powerful macro system
@@azaleacolburn Sure is! My video on the macro system is here, if you're interested ua-cam.com/video/MWRPYBoCEaY/v-deo.html
@@NoBoilerplateI know, I've seen it multiple times. Love your content, keep up the good work!
@@azaleacolburn thank you so much! 🙂
Thank you for the tribute and mention of Aaron. I get so mad at people who trample on the things he's created; he was a good dude who only wanted what was supposed to be free information to actually be .. free.
Markdown and RSS literally run my life. it's been 10 years already! We need him now more than ever.
@@NoBoilerplate Seconded. My daily notes are in markdown and RSS is how I get my podcasts.
His story really reads like a classic tragedy in a modern setting.
While trying to not make things too melodramatic:
In a bittersweet way, among the many things wrong in our current culture, he is a reminder that there are good people out there. And, even if they get overwhelmed or screwed over, their good deeds can still go a long way.
Who is aaron? I dont want to be disrespectful, just have no clue.
@@fumano2679 boingboing.net/2013/01/12/rip-aaron-swartz.html
His legacy is tainted by what Marak did with Faker.js and Colors.js - distributing malware through open source channels is not an effective form of political protest
I don't really get a chance to use Rust, but learning it made me a better TS developer. My codebases now use deeply immutable objects and zod for runtime validation. When it comes to making API calls its like the KGB. "Trust, but verify" I return errors instead of throwing them too.
YES! This is how I felt after learning Haskell at the start of my python career!
Me too! I've started using generics much more than overloads. I use the rust naming conventions (such as snake_case) for custom vars, and camelCase for stuff that behaves like built-in JS stuff.
I've learned to use some FP constructs to avoid using `let` instead of `const` (such as IIFEs, while we wait for `do` expressions).
I've learned to modularize my code, and I even write "boilerplate" to make my code safer and more readable (such as implementing a basic `range` generator, to do for-loops like in Rust and Python. Of course, I only do this for "small projects" where importing a whole lib is inconvenient).
And more! Learning Rust literally changed my way of reasoning about programs, and it changed my life (not in a *EXTREME RADICAL* way, but considerably enough)
I'm slowing getting into rust using your videos, these rust videos are so underrated!
You're too kind!
I think they're not known or consumed as much as they should be; needs more exposure. However, I think they're rated very highly by the community. All the top Rust voices seem to speak very highly of this content, as they should.
@@theherk that's so wonderful to hear!
@@theherk No untruthful words here. The content is great!
5:00 Wow! Congratulations and respect on taking that step, and best of luck to you in the future.
Your content stands out to me for being both unique and high in quality:
A distinct style with a clear structure that shows technical expertise and practicality in the matter, while still integrating your personal (occasionally uncommon, yet intriguing) preferences.
Thank you so much! You're very kind to say
Please make more videos on the frontend side. Rust options vs react,svelte etc vs htmx or any combination
I think it would be really cool to cover Leptos in the UI stack talk. It’s a very interesting framework that and I think you’d enjoy it
Oh I'm familiar, it's not mature enough for me to recommend yet. But you bet I'll talk about it when it is!
Yes! I’d love to hear your thoughts on Leptos. I love it, I’ve been using it for a product that I plan to launch later this year, I think it’s plenty stable!
@@JOHNDATGOONV2 That's the thing with Rust code - it's pretty much all stable! XD
Joking aside, I think it's a great tech choice for a project you'd launch a bit later on, perf!
My main problem with picking a stack is that it should be easier to make your own. A reasonably good async framework should be possible without unsafe using only the standard library. And my brain almost broke trying to convert Pin to Pin (I accept that this one might need some unsafe).
There are so many, but one of the things I LOVE about your videos is the blue line at the bottom to indicate slide progress. **chef's kiss**
Thanks! A few people don't like it, but most do! I like to always know how far through a video I am, and touching/clicking on the screen all the time doesn't do it for me!
I make stacks by planning their acronyms.
like the FAST stack
(F)lutter (A)ctix (S)velte (T) ypeScript
I never used it, but I have to say its my favourite to look cool.
Hah, I did some work a few years back on what-would-become the activej framework :)
Yes the uber-optimization down to writing specific java code that would get JIT-ed to specific machine code was something that they did - not me, I was a student, too dumb for that part of the thing, at least at the time - ok one thing I worked on was the dependency injection thing, that part I'm proud of lol
Also the magic specializer which converts DSL code into handwritten-like bytecode at startup, essentially getting those sweet zero-cost abstractions in Java 🙃
SOUNDS LIKE A NIGHTMARE XD
@@NoBoilerplate
honestly from what I remember, it's relatively not bad, and I really liked the highlevel APIs and DSLs, imo (still) they are close to the best thing you can get in Java (ew, Java)
However, there was a moment when I committed something to master that broke the tests (yes we rebased-and-committed straight to master) and the guy was almost yelling at me for not running them before pushing (I forgor 💀) and I was trying to suggest "um we can setup like an automated thing that would run the tests whenever you push something [to master]" - not yet knowing at the time what CI is or what are the better practices of it omg - and they didn't have that, and I just looked at the activej repo - they still don't
@@necauqua to be fair, most companies just started investing into CI/CD in the last few years, as it only started to proliferate with stuff like gitlab. I know the more wealthy java houses I worked with decades ago had their own build pipelines already with CVS and SVN, but testing was still often done with manual processes or only around releases.
1:30 out of curiosity: why colour-eyre over something like error-stack? Error stack preserves the underlying type used in the error and still has all the niceities of color-eyre with a few extra features. I personally don't see why somebody would use eyre over error-stack if they are focusing on correctness
Interesting! I wasn't aware of error-stack, probably because it's just a year old.
I trust anyhow a LOT, it's the #1 results handler in Rust, and so Eyre being a fork I don't have to think too much about before recommending.
I will follow error-stack with great interest, thank you!
@@NoBoilerplate btw, error-stack has full support for Eyre and anyhow! You just need to enable the feature. It's based around the same idea of building up a report from context, except the context is fully typesafe so you can use e.g. enums as errors
@@suya1671 oh INTERESTING! Well thank you I'll take a look 🙂
I just started learning Rust, and even the configs and basic boilerplate looks intimidating. I'm defiantly not going to be leaving my SvelteKit safe space in the front end for a long time, but the Rust ecosystem for backend looks like it's worth my time.
Totally understand, it is a bit intimidating! Whenever you want to learn, here's my video for teaching yourself Rust: ua-cam.com/video/2hXNd6x9sZs/v-deo.html
@@NoBoilerplate thank you :)
Sqlx compile time checking is pure dark magic and I love it
SO good right!
I'm blown away what rust can to again and the reason I am is that you can get across what's special about it really well. You are great at simplifying things. Maybe you someone outside the field of web dev could have benefited from this skill by you explaining a little more of the server client structure of the web upfront? Just a thought. Having experience in this field it was really pleasant to follow.
PS: I still would wish for chapter marks.
Adding rust to my resume to become one among the elite
This is amazing, also congrats on 100k+! You blew past that milestone
THE PLAY BUTTON IS ARRIVING NEXT WEEK :-D
@@NoBoilerplate WOOOOO!!
Really love your videos! The perfect length and information density!
Thank you!
Me: axum is the clear winner.
Also Me: what's this POEM all about now????
Rust library selection is the ultimate ADHD time sink. lol
Yeah, there's a 'winner' but they're ALL wildly fast, that's why I put the normal frameworks down the bottom for context :-D
4:17 should also be considered that requests/sec doesnt tell the whole story with performance as any framework written in java or js will have greater memory usage and most likely latency even if it is able to achieve greater throughput
Thank you for being chill XD yes indeed! This video isn't about how rust is the best (see my others for that!) but just putting Poem in context.
While I'm impressed by all the amazing backend support that rust is getting, I haven't really seen a satisfyingly complete frontend rust crate on par with js/ts alternatives like React, Svelte, Vue, Lit, etc. I find that libs like egui or iced are pretty cool, but they're not made for the web, and yew seems promising, but I haven't been able to get it to work with the stability and ease of development that the js/ts ones have, let alone something like Next, Nuxt or SvelteKit (I see rocket, but it really seems to be more of an HTTP framework/backend web framework than a frontend/fullstack framework that I'm looking for). This has really been the only thing preventing me from getting into rust.
I'd love to see a video that delves into the web frontends and web frameworks that rust has to offer.
Oh for sure javascript has a big headstart. HOWEVER we're all getting very excited by leptos.dev - have you tried it?
@@NoBoilerplate I haven't. I'll be sure to check it out when I have time. Thanks for sharing!
What happened to Aaron was a great injustice & it honestly set the tone for what'll become of the internet
I had this thought, since we can use BASH-scripting to automate video editing with FFMPEG
Can we do it with RUST & what about Picture-editing ??
(E.g: making thumbnails)
the only limit is your imagination! For example crates.io/crates/silicon
I can't get over of sqlx accessing the DB at COMPILE TIME. This feels so wrong. All my programmer instincts are screaming that this is a path of madness.
Oh it would be TERRIBLE to do this in any other language. But Rust is so comprehensive that it can do these impossible things, see my video: ua-cam.com/video/MWRPYBoCEaY/v-deo.html
@@NoBoilerplate I understand, but what happen if I don't have a local database? it wont compile? so if I'm working at a large company with a large app/db, and I don't have access to replicate a local database (because there's a highly confidential layer of security and you can only do a query to a sandbox limited db where you need to access via website), I wont be able to code?
It may be an edge case, but it's based on the company I'm currently working on, it's a pain in the ass to work with sql queries.
@@LuisCassihthere's sqlx offline mode where it checks and save the result to a metadata
@@LuisCassih It's not an edge case - CI would suck if you had to have a db in there right?
SQLx has this covered, I talk about it in detail here in the video I pinned when I introduced sqlx, here: ua-cam.com/video/JIvKgSyvtxI/v-deo.html
oh, that's a nice feature, I can even create schemas without even accessing the db. Thanks both of you for the insight.
Your English and your voice are wonderful, I am learning English and I will try to imitate you, you have the most beautiful English I have ever heard
You are very kind! I have practised public speaking a lot, starting when I was at university - practice makes perfect!
I also practised making a little weekly fiction podcast for 3 years before starting this channel.
I talk about this all in this video, if you're interested: ua-cam.com/video/fzNk_1xLIKI/v-deo.html
"I am going to shave a yak" is probably most interesting debug message I've seen
Express is known to be slow. Compare it to Fastify or Hono, and there wouldn't be much difference.
Why didn't YOU do this comparison before making this comment? I gave you the link in the video! Both Fastify and Hono are extremely mediocre:
web-frameworks-benchmark.netlify.app/result?asc=0&f=fastify,hono,express,poem
I’m currently learning how to use Warp, I’d try to implement this using warp
Nice! There's no warp first-party openapi plugin, but people have told me about docs.rs/utoipa/latest/utoipa/
It's less DRY than poem-openapi, but should be a good starting point!
Was binging your videos and this came up fresh from the oven!! Thanks for all the quality, time-respecting content.
My pleasure, thanks for your nice comment :-)
Dang this is thorough af.
Thank you!
I love your videos! I came across Poem when looking for a Rust web framework that had good OpenAPI support, and seeing your “endorsement” of it makes me more confident in choosing it.
it's SO lovely to work with!
First time on your channel. I do love your concise, informative and pleasant style so far. Could you consider doing a video for startups? You see, for example, we're writing an app with a Flutter front end, which relies heavily on a geographical map component and on webrtc for video calls. The great void in UA-cam is found, for us, in choosing our backend stack and opting for the cheapest possible hosting (cloud vs our own hardware) to allow ramp up until profitability or proof of concept is achieved. Thereafter funding would, one would hope, come elegance in design and scale. There's very few people with the expertise to talk about how to initially scale up fast, cheap and inevitably dirty to a degree. It could be a fun video I believe. Anyway, thank you for your videos, I'll sub now!
You could literally use Poem-openapi for that, as I say in this video, Rust is Cheap: ua-cam.com/video/4dvf6kM70qM/v-deo.html
*in my opinion* we should rally around Axum as our web framework. its built on top of the tokio stack by the tokio people and its super ergonomic and powerful
1. I don't think we need to
2. Good luck herding the cats XD
@@NoBoilerplate hahah fair enough
I like axum not because of speed or ergonomics but because it's under tokio's development team and therefore I don't fear the framework will fall behind and will be updated even if some dependency introduces breaking changes (ehm ehm looking at you hyper 1.0.0)
no such thing as breaking changes with Cargo, right? Human error, sure XD
How does the sqlx compiler handle CI builds, does he just skip the checks then? This sounds like the build-step would need access to a database, which feels kind of unintuitive.
Ooh, you're gonna love the solution: It's got a built in cache mode for CI. Check my explanation here ua-cam.com/video/JIvKgSyvtxI/v-deo.html
Could you do an video on how things like sqlx and leptos achieve their compile time checking?
Already did, they do this with the WILDLY powerful macro system, my deep dive is here ua-cam.com/video/MWRPYBoCEaY/v-deo.html
I also talked specifically about how SQLx works in this video ua-cam.com/video/JIvKgSyvtxI/v-deo.html
I just listened to the Oxide and Friends podcast, where they are using their own Dropshot HTTP server to generate OpenAPI from their code, and how that boundary has helped them craft a reliable frontend. Poem looks super interesting!
Same - I'm curious about the differences between Poem and Dropshot, I'll have to try them both at some point I guess
1:01 wow, what a portfolio. RIP
We need him now more than ever
I don't use Rust daily, but have interest in learning it deeper. Do you think doing Leetcode problems in Rust is a good option? I heard that lifetimes and other features can make simple problems harder.
I actually have a whole video explaining my tips on how to learn Rust, and it centres around Rustlings, a code kata system like leetcode problems! Do watch (and check out the other videos in the playlist if you have time ua-cam.com/video/2hXNd6x9sZs/v-deo.html
Your explanations are so fantastic. I echo the request for a video with html templates with HTMX for interactivity (look mom, no JavaScript). Just exploring Rust, but it seems like the front end story would be greatly helped with a "just return html templates, with tailwind css and htmx for get / post behavior," similar to Jinja, Chameleon in Python.
Since this video, the community has rallied around dioxuslabs.com/
I checked out poem thanks to you! I loved it and I want to use it in my next project. But I see that I have fears on frameworks like this about their futures, can I get your opinions about it please? What do you think about community-made frameworks and their futures, because we have an example like Rocket. I'm sure that I'll not use these frameworks in billion dollar startups ;) Yet, do you have any trick on understanding which library will stay long enough?
That'd be a good trick! Here's how I evaluate rust crates, I use lib.rs:
lib.rs/crates/poem
Note the statistics right at the top of the page:
- latest release July 23rd 23 (before then, Feb 23, Dec 22, Nov 22 etc)
- #9 in 'http server'
- 48k downloads/month
- used in 116 crates
lib.rs surfaces exactly what I need to know, and all without javascript!
Rust and the Rust community make STAGGERINGLY stable software - even 0.0.2 crates I trust more than 2.0.0 npm packages!
Appreciate your video. Definitely nice that OpenAPI is built into poem. If I was going to bet on a rust api framework, to me it would be Axum. I enjoyed working in Axum and seems as closest as expressjs as I could find so far.
No betting needed - there's different frameworks for different purposes! Axum is indeed very good.
What font are you using on the code snippets? The ligatures for #[..] is really cool!
That's Fira Code! Though there's a few ligature nerd fonts around
@@NoBoilerplate thanks I’ll have to check it out. I’m using a custom NF font with ligatures but it doesn’t have that ligature
when you bind your db and your rest api, don't you tie your user facing api to what you store. which is probably ok for something simple, but IMHO for something more complex you want to be able to evolve the API independently from your business layer and DB layer
An excellent point. Yes, especially for API versioning, you'd want that decoupled, which is easy enough, just make another struct.
The strict typing of your API, and the compiler keeping you safe when making changes, still applies after this useful weakening of the relationship between DB and API.
Thanks for another amazing video, I wanted to know if there was something that specifically caught your eye with poem over say axum or actix?
the first-party openapi plugin - it's lovely!
Bacon is amazing!!!!! 🤯 Thanks 🙂
SO good right! cargo-watch is fine, too, though it flickers when refreshing.
Amazing videos! They slowly got me into rust
Wonderful!
OMG!
POEM is exactly what I'm looking for, seems to be a god send for HATEOAS.
Add htmx to mix and its a win.
Your recommendations are solid ;-D
I'm actually trying to slay the Excel Makromonster my uncle created...
Meaning I finally begun work on it, after procrastinating literally for years now.
First step is writing software to analyze the thing for data and app logic.
Trying that with pest, egui and calamine. Just managed to get some life-signs today.
After that is finished I want a proper custom build lightweight ERP and *"THE STACK"* seems to be a good starting point for that.
I just can't get too excited for htmx, it's easy to get going but suffers from the same unsafety that js does. Try Yew.rs, it's very simple and will give you huge confidence in your frontend!
@@NoBoilerplate nah it's internal tools only nothing exposed for the web.
Well you could completely go the SSR HATEOAS route but htmx reduced the boilerplate/templating a lot.
0:25 Can you explain what you mean by correctness here?
the mention of Jane Eyre gave me a flashback, goddamn that book was long
my D:\ drive has the writing on the tombstone of her friend as its namesake - Resurgam
Amazing!
Congrast for going fulltime with what you enjoy
Thank you so much, it's so wonderful to be, effectively, teaching professionally, I've always wanted to!
Well, you were right. I looked up what happened to Aaron Swartz, and I'm now angry and sad. I hope we can one day create that kinder world.
In regards to the quote on the thumbnail
Jay-Z, Biggie, Kanye west & other rapper don't write their poems/raps. They just memorize their best lines
Fair, though isn't memorisation writing, of a sort? Only writing to the medium of your mind, rather than paper - Dijkstra didn't mean the physical act of writing, really, he meant the act of creation.
Consider the sentence "I wrote a song", you might physically write the lyrics, but the tune is in your head.
2:28 I never used Tokio and I don't want to use Serde anymore.
you MUST have used tokio! really?
@@NoBoilerplate
No, I really never used it. I've seen it a long time ago, but I always thought, I don't want to know that much.
I was rather expecting critique on not using Serde :)
Hey, you didn't explain what Bacon/Clippy is :(
Apologies! This isn't targeted at beginners to Rust, however I do have a whole playlist that IS! Here's the exact video in that playlist where I talk about bacon ua-cam.com/video/dFkGNe4oaKk/v-deo.html
@@NoBoilerplate Ooh, thank you! Love your podcast too btw!
@@tiagomacedo7068 oh thank you so much! I started planning Lost Terminal season 14 just today! Drops on the first Monday of November 😀
Nice video, I'm still trying to learn how to organize projects on Rust, as I'm switching from a OOP type of language (Java), I'm not really used to rust that feels a lot more functional oriented like. I was wondering if you had any tips for that.
Also, any tips for Desktop applications with GUIs ? I can't find anything really reliable, I don't feel like it's mature enough yet
Come ask those questions on my discord in #newbie-advice, folks will have great suggestions!
I have answers:
1. Enums: ua-cam.com/video/z-0-bbc80JM/v-deo.html
2. wasm inside Tauri (or electron) ua-cam.com/video/P4LMfkFLRsI/v-deo.html
You're incredible, thank you for your videos they are so good!
You're too kind, thank you so much!
Why choose postgres over other options when given a choice?
It's the stand-out best SQL database on the planet, and has been for my entire 15 year career.
i personality like using seaql query builder with my sqlx
Thank you to the tribute to the internet's own boy
We need Aaron more than ever
Have you tried leptos for front end?
We're all very excited for leptos! Not quite mature enough for me to be recommending just yet, though.
Did you try miette ? It's great for error reporting too
Looks like miette is on the `thiserror` side - creating good library errors, not handling good library errors.
I don't write libraries, but if I did, I'd check it out!
@@NoBoilerplatemiette is on all sides: it has guides for using it in either libraries, applications or as the main() return. it's main claim to fame is ultimately very nicely formatted errors, akin to rust compiler errors, which are desirable in applications too.
@@laundmo it's very exciting! Thanks both for bringing it to my attention!
My main problem with creating backends has been the fact that I don't know databases. I tried taking the databases course at my university, but the lectures were extremely dry and the setup process tedious enough that my ADHD brain gave up (I was also taking my university's Rust course and it was far more interesting, since static analysis is so cool). Since understanding databases seems essential if I want to have any hope of success as a software engineer, do you have any recommendations for a way I could learn how to work with databases that will be manageable? While sqlx looks nice, the fact that you need to use strings to build up the queries means that there likely isn't any intellisense for it (which would make things quite challenging for me).
Working with an ORM - like Diesel in the Rust ecosystem - might be a good fit if writing SQL seems too daunting at first.
Diesel is a very good ORM, but it doesn't do compile time verification, and its runtime errors are not very nice.
I too used to feel like this. You could try Diesel, a very popular rust ORM.
Here's why I now prefer to write SQL: In every large project I've worked with, we've EVENTUALLY had to write SQL.
ORMs don't scale, and the bigger your app gets, the more hand-crafted SQL you have to write. This is the same problem as Javascript, it STARTS OFF nice and simple, but by the end, you wish it weren't so simple, because the edge cases break you.
Use SQL with SQLx, and don't be afraid, because the compiler is holding your hand :-)
Planetscale has a good intro to SQL. They also have a free tier for hobbyists.
@@NoBoilerplate that makes sense, but an ORM definitely sounds like a much nicer starting point. Maybe I'll also look and see if there's a kata-like course for SQL! I used Tom Kunc's MacroKata to learn Macros in Rust and it was awesome
Awesome video! I've been using the majority of these and the rest have been on my list to tackle next. Absolutely love the channel and the quality of the videos you put out!
Regarding Poem - I actually recently discovered the library/ecosystem after I'd started my first project using Actix & Utoipa for OpenAPI. I had a few concerns and wondered if you have hit any of these?
The first was the much much smaller following for this library, and I (probably naively) perceived that the library had less activity.
As well as this, I found that the docs aren't as good, as they're mostly just API docs & examples (but the examples are high quality).
And my last issue was that I was having some major headaches with converting between error types in the handlers, which was much easier in Actix.
Also, forgot to say that the Poem openapi was much nicer than Utoipa as the schema was defined as code instead of alongside the code 👍
That's the big difference, poem-openapi is extremely DRY
Yeah, the docs could use some work (maybe you or I should do that!) but the examples are great, that's how I learned.
What about graphql with rust?
I fall in love with graphql since it gives me output validation on the frontend and really would be awesome to combine Graphql + Rust
there are 423 crates on crates.io that mention graphql - Go forth!
I've used async-graphql and juniper. I slightly prefer Juniper, although I think async-graphql may have more features/be more active. Both have been more pleasant to work with than their Typescript counterparts.
What do you use for i18n? I've been trying to get people at work to try Rust, but that's one thing I'm not sure about, because it's so easy to do in the language we currently use (C#), and I don't know if there is an equivalent in Rust yet.
Poem has built-in i18n support, check the readme! crates.io/crates/poem
@@NoBoilerplate That's nice, but I mostly write desktop applications. I just found a crate named i18n-embed-fl that looks promising. I'll try to understand how it works and if it does what I need.
@@yondaime500 I think you've got it - the standard seems to be crates.io/crates/rust-i18n
Trying out bacon now. I knew cargo-watch was no longer being worked on, and it turns out the author actively recommends bacon.
Hi Triss
How come you write SQL by hand rather than using an object-relational mapper for Rust? Is there a performance benefit? Finer control over database operations?
Two reasons: 1. compile time verification, 2. optimisation.
1. Only SQLx (I believe) with the query_as! macro can check your queries at compile time. Though it'd be more ergonomic to write in an ORM, I happily give it up to get compile time verification.
2. Every project that uses an ORM eventually has to hand-optimise their queries at scale. Universally, with no exceptions. I am fully bought-in to Rust's "upfront the work" mentality, and writing queries in sql, rather than sometimes writing orm and sometimes writing sql is MUCH cleaner.
Also, it's very likely you'll write your own functions to abstract both the ORM or the raw SQL, so you might as well get compile-time guarantees!
Have you considered making a nix with your stack?
I really like Nix, and have NixOS on a laptop for testing. However... This whole stack is pure Rust, even using RusTLS, no external dependencies other than rustup.rs.
Nix is ESSENTIAL in other languages, but I've found since switching to Rust, I can just choose pure Rust dependencies and never trip up. As Cargo is extremely deterministic, I don't miss Nix there either.
The Rust Editions system guarantees anything that compiles today will compile in 40 years time!
what about diesel rs? (why sqlx...)
Diesel, like all ORMs I've tried so far, does not connect to your real sql database at compile time and validate your queries. Just incredible, check out ua-cam.com/video/MWRPYBoCEaY/v-deo.html
@@NoBoilerplate but you can provide file with sql commands so you will have structures of tables, so you will have some compile time checks like for types
@@danyldavidiuk9507 That is not good enough
thanks Tom
You're welcome Dennis
Great video, why not axum though ?
I'm uninterested in closed source silos.
Axum is great! They're all great really. As I said in the intro to poem, axum doesn't have a first-party openapi plugin, and I've heard that those it does have are not ideal.
@@NoBoilerplate The reason I like axum is its well integrated in tokio stack. So I think it will be maintained for a long time. Also having OpenAPI is not important to me, that's just my prespective, its a developer feature mostly and they usually use Postman or something similar. Again great video and I hope you find success now that you are doing rust videos full time. I would love a detailed video on tracing, not a gloss I think basics everyone can get.
@@AbhishekBajpaiHere Thank you so much! Axum's great too, of course. You can't go wrong with the Rust frameworks!
What's to know about tracing? The readme's very comprehensive - what value could I add?
I am curious, what is anyone's opinion of Leptos? I've been playing with it and am enjoying it for both frontend and backend. I will have to give Poem a try so I have have no comparison at this time.
Leptos looks really good, and I look forward to it maturing!
excluding C++ based ones is kinda funny
Yeah, if you check the link there are some nim and cpp webservers that punch a bit higher than ActivJ, but as I said, you'll never persuade a team to use them, so I feel safe discounting them XD
I'm here talking about Rust not just because it's a WILDLY great language, with alien magic in, but that, somehow, despite all this, it's already the #19th most popular language redmonk.com/sogrady/2023/05/16/language-rankings-1-23/
There are other metrics than popularity (but rust for http stuff is good)
@@user-du9ch3tn2v popularity doesn't matter comparing the top languages, they're all popular enough, but if you see where nim (for instance) is on that graph, it really does matter.
Ok tried to use poem and liked it but this is my first API and there is no community or material for support. Will try axum
wait what no leptos on the frontend?
Now I looked up Aaron Swatz or whatever. I read something about downloading MIT documents but dont exactly get how its related? Anyone?
Watch "The Internet's Own Boy", linked in the pinned ERRATA comment.
Sad that Fasterthanthine was the first to go...
Solid name honestly. I learned Rust from Amos at fasterthanli.me :-)
the OpenAPI one looks really nice, i wish axum did something like this
Search and ye shall receive crates.io/crates/axum-swagger-ui
Of course, they're not first-party, which was my delight when finding poem, but I bet there's others!
@@NoBoilerplate LETS GOO, I will check it out
I’m using utoipa with axum in a project. It is framework agnostic and have similar macros as shown in this video.
@@jakobankarhem6281 that sounds interesting. especially since axum-swagger-ui seems to only adding swagger ui, but utoipa allows decorating the views.
Why postgresql > mysql ?
though mysql has a large legacy install base, postgres has beaten it in features and performance my entire career.
what if the database connection breaks
If you're talking about the development experience, SQLx has you covered, I explain their 'offline' feature in this video: ua-cam.com/video/JIvKgSyvtxI/v-deo.html
"fasterthanthine" 😂😂
I learned Rust from Amos's amazing posts!
@@NoBoilerplate I'm a big fan too :)
Awwwwww, I really like Nim!
Ah, so do I. Nim was my gateway from Python to Rust, igniting my passion for single-binary deployment and static typing!
Popularity matters, as I always say, so I looked at three mainstream languages that I stood a chance at writing professionally: Go, Haskell, and Rust. Go is ruthlessly practical, but with no beauty, Haskell is beautiful but not practical, and Rust has the best of both, and is somehow greater than the sum of its parts!
I wrote this comment on a hackernews nim v rust comment thread last month, perhaps it's useful to read:
Nim is too timid. Most languages are too timid.
My context: I'm a maintainer of iNim, creator of the Rust channel, No Boilerplate, and a professional python web developer for 15 years.
The features you are excited about in Nim are compromised for the sake of simplicity:
- Macros can't change syntax,
- There's a limit to how real-time the standard language is,
- Compiling to javascript is a nice trick, but if it didn't rely on GC it could compile to webassembly, which is better,
- Ask any advanced python developer: Indentation for syntax is a bad idea at scale. Hell, have you ever used YAML?
What Rust does is a revolution because they solved the problem of memory safety without garbage collection with the Borrow Checker. The knock-on effects are GARGANTUAN.
This was a hard problem to solve, and it makes the language more complex to learn, but it unlocks all the language's superpowers. If you 'cheat' with a GC, you get nothing. Nim started its life, just as most languages did with a GC, and the efforts to keep the syntax the same while offering alternatives are greatly compromised. It's far easier to add GC/RC to a low-level language than it is to remove it from a high-level one, where the whole ecosystem relies upon this behvaviour.
Of COURSE I know about Nim's plugabble GC options. That doesn't impress me at all (though Araq's effort is to be commended). In Nim they are compiler options, in Rust they're libraries. The difference is vital. For example, at a per-variable level, I can choose to reference count with doc.rust-lang.org/std/sync/struct.Arc.html if I so wish (I rarely need to because the borrow checker is magic).
If you want python, you can have it inside a Rust macro, sort of like this crates.io/crates/inline-python because rust macros CAN change syntax. With Macros and no GC, you can rebuild ANY FEATURE inside Rust, the floor of the abstraction is the metal, and the ceiling is the sky.
This is what Rust is all about: full power to the developer, no compromises. My video on this topic for those interested is: ua-cam.com/video/PuMXWc0xrK0/v-deo.html
I love both languages, but I can only see one language being the standard next 40 years, and demonstrably so can Linux, Microsoft, Cloudflare, Discord, and many others.
@@NoBoilerplate Thank you for the response, and thank you for making it a wonderful response! I feel like I've met a celebrity! I've been loving your videos and sharing them wherever I can. ☺️
The way you reference Nim just caught me off-guard because I had just discovered it and was really liking it. I'm primarily a Python developer, so it was really nice to see similar syntax and I appreciate this simplicity over the very verbose Rust I've been trying to learn. And have you seen the Uniform Function Call Syntax? ♥️♥️♥️
@@LoganVanCuren UFC is SO fun isn't it! Look, learn nim, do it without any guilt, it's a great language. Rust will be here when you want more ;-)
BTW Rust has something that feels a bit UFC - you can attach methods to any struct using `impl`. It feels like much looser coupling than classes (though less loose than UFC) doc.rust-lang.org/beta/std/keyword.impl.html
The channel that is worth to turn off AdBlock. Greetings from Poland! I love your approach to technology and not only. That's make me moriveted.
Thank you so much!
Hi can sqlx support clickhouse too?
I've amaized how slow and sluggish JS outperform Rust ? You can expalin Java .. it snor really interpreted...and has JIT thing..but JS..
It's because it's actually a frontend for C++, it bypasses all of nodejs and replaces them with native wrappers. SOME might call this cheating ;-)
Sifrr is based on github.com/uNetworking/uWebSockets.js
You find this a lot at the top of the benchmarks - artificial frameworks that are designed to 'win' framework competitions, but don't actual use your language in a normal way, so you'd never choose them (as you have to throw away much)
Omg GjengStack has me rolling
Gotcha!
RIP Aaron Swartz
We need him now more than ever
Great video! Thanks for the recommendations!
Does anyone have experience with generating rust code from an existing openapi spec? I'm just starting on my rust journey and could use sth like that for a side project. Recommendations would be appreciated!
What about leptos
Not quite mature enough yet, but it's very exciting!
crablang for life
crablang until it's merged, maybe. I remember the node/io.js split - history is cyclical XD
Yeah, sorry Rust just isn't ready yet for web development.
I tried it in the past, there isn't a major established web framework that has been tried and tested in enterprise, the ones that exist are underdocumented or undermaintained. Axum doesn't even have a website and is barely documented. I couldn't find a good e2e testing solution in the level of playwright. The orms feel incomplete, nothing like entity framework or prisma.
Still, I hope it does get there someday cause rust is a good language. I do think it will with the performance Rust is offering
A good alternative to get away from JS in the server is C#. Better performance, has a good ecosystem and tons of jobs. The only downside to it is Microsoft.
Rust is indeed an excellent language, and though you're right that the web frameworks are still being developed, I would trust a 0.2.0 Rust framework over a 5.0.0 JS framework in production every day of the week.
Note I say 'trust' not 'use', there are many cases where the downsides of a JS framework (say, react or express) are overwhelmed by the benefits you get from popularity and longevity: If you want gmaps in react you can choose between several plugins. If you want it in rust wasm (leptos or yew, say), you'll have to write that plugin yourself. Some people will be fine with that, others will have to wait, and use React or similar in the meantime.
But this doesn't mean that you should write off the whole language, as your comment suggests. That's too blunt. The web stack I feature in this video: poem-openapi coupled with SQLx, TODAY, is better than any other option in any language for building a lightweight API in production.
This combination of rust/poem/sqlx gives you features you simply can't have in any other popular language or framework. compared to rails-api or express or django-restful etc etc, the stack I show in this video is more reliable, safer (both memory and high-level) and faster than them all.
As a senior web dev, there's one thing above all else that I care about these days: that you can actually finish your project with this stack. It will sit in production, reliably, being upgraded as the compiler improves without a single line of code that needs porting, for decades to come. My team and I can move on to other projects.
There's enormous momentum in the Rust ecosystem, I'm testing out leptos for replacing js in my frontend projects, and I'm extremely excited by what I'm finding, for instance. But unlike poem, I don't recommend laptos for everyone just yet, perhaps in a year.
What I do recommend is that for people who are sold on Rust, this is a good stack for building an API, which is the vast majority of backend web projects.
For now, I recommend to most people to stick a react app or a swift UI on the frontend. But not for long! :-D
RIP Aaron, he messed with the wrong kind of people
We need him now more than ever
RIP Aaron, reddit died with him
We need him now more than ever
LETS GOOOOO
new rust video!!!!!!!!1
Wait, I thought everyone was choosing their stack based on some meme name.
I'm as surprised as you
ActiveJ team are geniuses. How in the world Java is the fastest. ActiveJ is only reason I can comeback to Java.
Seems like they reimplemented everything from ground up. On the other hand I don't know that framework and it may just be one time show off for benchmarks
Oh, Java's not, Nim and Cpp are the fastest, but they're weird, so I didn't include them.
ActiveJ extremely clever, but it's not popular, which is a problem for me, www.statista.com/statistics/1124699/worldwide-developer-survey-most-used-frameworks-web/
@@NoBoilerplate nim is kind of cool from what I saw. But popularity is an important factor, especially to learn.
@@romankoshchei Nim got me from python to rust, but I don't need it anymore 😅
RIP Aaron
We need his help now more than ever.
Wait till you discover Haskell :P
Wait till you discover my other videos XD (specifically this one ua-cam.com/video/2hXNd6x9sZs/v-deo.html)
@@NoBoilerplate Heh I was being facetious. Watched all your vids, and love them. Does feel though that you love the aspects of Rust that are actually stronger in Haskell than Rust (imo). I wonder if a more FP, and less systems would be ideal
@@dombou70 I adore haskell, learned it 15 years ago and it made me a better programmer in OTHER languages! However, Popularity Matters.
I evaluated go, haskell, and rust in 2020 and found go was very practical, but not beautiful, haskell beautiful but not practical. Rust is a wonderful blend of haskell and lisp, all in syntax that doesn't scare people away!
@@NoBoilerplate That's fair. Fwiw, I went through my Haskell phase, and i've also moved on as the community was just too small. I now use TS and it's mostly good enough. I'd love proper ADT's like Rust has, and a std lib built around Result/Option types
@@dombou70 TS is great if you have no option, yeah, I dig it for sneaking in some safety into frontend teams! Yes, this is the exact problem - you can TELL when a language wasn't built around sum types, like TS, if it gets bolted on later, you have deep compromises that you can't remove from the language. RUST IS SO EXCITING FOR THIS
Please do chapters for your videos