My main interest in Rust, so far, has been for doing bare-metal embedded development. So it's quite fascinating to see you doing web-backend stuff in Rust (that's my day-job). The idea of using one language for low-level, high-level and everything-in-between-level is quite refreshing in this day and age where I jump from PHP to Python to C and fiddle-faddle with some other stuff too (although I'm still stuck with Kotlin for now if I'm doing anything Android). I am very taken with the idea of *"One language to rule them all... and in the crab shell bind them".*
Yeah I do think Rust is under appreciated for webapp development and other things conventional wisdom says you should use a "higher level" language for. It seems like it's been unfairly pigeonholed as a "systems language" in that sense. Love the LOTR adaptation haha
I am an Android developer as well. If you’re willing to endure some pain, try using the Java native interface along with Rust foreign function interfaces. It’s quite fun, way more exciting than building a CRUD backend with a web app!
Having never really coded much in Rust before, trying to introduce Postgres, to make this a little more portable and less cloud-dependent, has proven to be quite the exercise! Definitely went down the rabbit hole on this one haha. I really like how you laid everything out with this project. This all seems right. Most demos, tutorials, and other things out there are just kind of the bare-minimum code necessary to get something to compile and run. I've been trying to get some good insight into how Rust devs actually structure their projects, split things out, et cetera. Hoping I can adapt this to leverage Postgres! (Or maybe even Diesel, somehow)
Also, the editing seemed pretty spot on! I had to do lots of pausing and whatnot, though, so the only suggestion would be to maybe keep a few more frames in between jumping around, just so that those who need to can pause the video and don't have to back track much.
Thanks Joseph! Would be awesome if you could share your experience integrating with Postgres/Diesel - I believe I'm going to make a video about this in a few weeks. Re: pacing, thanks so much for the feedback! I'll make an effort to pause a bit more in future videos!
Jee Dude, I watch you code in rust and I am amazed at your skills and the language. I love rust and for the first time, I wish there was a magic pill that could get me there fast. I am a Senior Java guy and do that all day for now. But man! What an awesome language. Keep these examples coming. Please!
Thanks so much for the kind words Seba! I actually have a similar background - was a die-hard Java fan up until a few years ago. Was really into Java Swing back in the early 2000s. Rust can seem intimidating, but once you internalize the tricky parts it's all downhill from there. Check out the "Rust Demystified" video if you haven't already!
I'm a new developer in RUST and this was an awesome tutorial. I came from PHP and Typescript and I was looking for a new language to build fast REST API Backends. Thanks for this tutorial. One question: Between Actix and Rocket do you se any big difference? Do you recommend to use Actix-Web? Thanks again for this quality material.
I really appreciate your videos! Thanks for the time and effort you put into them! For us that are visual and helicopter learners (meaning we need visual reenforcement between topics and a wide scope of view down to details) I could use a bit more space in-between topics with maybe a bullet-list of where we are going. The speed of this particular video is perfect language-wise, but you have a tendency to speed up in some of your other videos. You have a good resonant voice, a good dialect, and speak clearly - which is awesome! Keep up the great work!!
Thanks so much for the kind words and for the feedback!! I think spacing out the topics and maybe using a bullet list as the "roadmap" for the video is a fantastic idea - I'll likely incorporate something like this in future videos!
thanks for the amazing video!, im currently starting out with rust as my first "proper" attempt at learning a language. i heard programming a website is really good for learning so im going to try and build an entire site with just rust and some mysql as apparently you can code the front and back end in rust! thanks again
Nice Zorba! I've actually never heard of anyone learning Rust as their first programming language. There are quite a few folks that might try to talk you out of it, but I think you'll be fine! It is indeed very versatile.
Hello, You're producing really good content. i have watched other rust related video, Keep it up. One suggestion, consider shrinking down your video little bit, currently it feels bit overwhelming. Like almost 1/4th of the screen so reading code becomes bit difficult.
Thanks for the kind words! and thanks for letting me know about the video being too large, that's just the sort of feedback I'm looking for! Will make it smaller in the next one.
Thanks for this video. clear, concise, and good pacing (for me at least). I love Actix's perf characteristics but being new to Rust it feels a bit more intimidating than some of the other frameworks but I think you've talked me into it. Now I just need to get my head around when to use the Actix web framework versus the actor framework ... and I see now they have a broker too?
Glad you found it valuable! I actually haven't delved into the actix actor framework yet - apparently (at least according to actix.rs) Actix web doesn't use the actix actor framework under the hood anymore. Seems like it has been at least partially replaced by language features...
I like the style of your videos - they're to the point and concise. Would it be possible to turn off the VSCode pop-ups whilst you're doing them though? There's a lot of time where I'm slightly behind you in comprehending what you just did, but the pop-up is covering the code now.
Thanks Neil! and great feedback, I generally intend to turn off the hints / autocomplete before recording a video, but there are several videos where I neglected to do so, including this one T_T
@@codetothemoon YW, I like your videos so being able to help make them better is awesome, terminology can be weird and inconsistent :p. You have functions, associated functions, anonymous functions & methods (I think that's it?).
Thanks for this awesome tutorial, loved the way you explain rust🙌. do you have any plans on making a tutorial for actix or so. since there are fewer or not useful videos on this framework. Thanks.
@@codetothemoon Tutorial for actix v4, i don't know about actix in actor framework but it have been 2 months i have stated learning rust and now i love to code in rust and use actix with PostgreSQL for web backend.
I personally would like to see you flesh out the repository code even if you think it's not worth it. Also don't feel insecure about your code!! Not sure why you didn't show it but I appreciate your videos even if you think the code is "hairy" here and there.
I would have loved to explain it but was worried the lengthy explanation would dilute the "value per watch second" folks get out of the video, especially for those that don't plan to use DDB.
thanks for the pointer (pun intended?) there were a few places where I was trying to pass a borrowed value but couldn't get it to work, I'll revisit this one!
Great videos! Didn't see the dynamo setup video on your channel. Perhaps a "suggested video" card could be helpful for people to reference your previous videos easier
thank you and great idea! did a video on dynamoDB here th-cam.com/video/_TQ3UTyKdJ8/w-d-xo.html more of an overview of what its capable of than a tutorial though, for the latter you might try the aws docs here docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html
Very interesting and good paced video! One small thing I'd have found interesting is starting the program a few times inbetween and look at the current progress. Also the compiler error at 13:15 would have been interesting. But overall very high quality content! Can't believe you don't have more subscribers
Thanks Fabian! This is fantastic feedback. Next time I do something like this i'll try to run it after each sort of "milestone" so it's easier to see the progression
Hi! Great video, just a question. How does one learn all these stuff? Not only related to rust (like the libraries, and such), but web applications in general? I find it extremely overwhelming considering the amount of stuff related. If you had any advice, that would be awesome.
thanks Pedro! I wish I had a good recommendation for a one-stop resource for learning about REST services and webapps. My advice would be to take a course on Next.js (well established framework) or SvelteKit (the up and coming framework that appears to be favored over Next by many people) - those should cover all aspects of webapp development as they encompass both the frontend and the backend.
What's interesting to me is actually how slow a lot of those requests ended up being. I assume it's probably network latency to DDB, but 221ms to do a single lookup on a tiny table and return it as JSON seems like a lot. For reference, a brand new Ruby on Rails app hitting a local mysql takes about 50ms for me, and Ruby/Rails is considered bloated and slow by many.
You're absolutely right - I actually didn't notice the latency until you pointed it out! 200+ms does seem really slow. I'll have to dig in and find out where the bottleneck is - my guess is that it's not the Actix framework though.
Great video. A quick thought: (hot take, don’t take too seriously, and I know the video is old.) Writing out all the dependencies early on is typically not how I develop. I usually start fresh and then I add dependencies one at a time as I need them by looking at the relevant docs. Until I work with them enough to know them by heart. My thought is that maybe it would be clearer to present it that way. But maybe it isn’t. Do you usually program like this or is it for presentation purposes?
thank you - and this is great feedback! I did it this way just for presentation purposes - to your point, when I'm actually developing I add them as needed. After thinking about it for a minute, I think you're right - if I add dependencies as I need them, it would probably make it easier for the viewer to mentally connect the implementation with the specific dependency required for that logic.
Do you think is it good for web development. Like i have a strong foundation in rust. But I don't know should i do web development in rust or not ? Or should i stick to typescript for web development?
it's tough to say - if you're building a mission critical application under a tight deadline in 2024, typescript is probably the more pragmatic / less risky choice. If you can afford to take a bit of risk and have a little more leeway in terms of completion time, Rust can be a viable choice. Definitely check out Leptos if you haven't already.
@@codetothemoon i have started to implementing a server in Rust. I think it's avery good thing now I m feeling it's better to write server code in Rust rather than node.js etc Will sure see Leptos.... Thanks brother 👍👍
Hi! Awesome video. Which language, out of the following three, would you say that makes web dev easier/faster without sacrificing speed? Rust, Go or Elixir?
As a basic proof of concept for a larger idea I've been sitting on, I'm trying to find a backend framework that will efficiently receive input data with specifications for a Vue component (template element types, selected style properties, a specified set of variables, and a limited set of methods to perform on these variables) and respond with a properly formatted text file that can be mounted to a code element on the front end. Do you think Actix is a good choice for a gizmo of that nature?
Followed the tutorial, made an AWS account but now I'm not sure what to set the primary and sort keys in the table as. Anything I seem to try just results in "One or more parameter values were invalid: Missing the key" and a TaskCreationFaliure.
Just took a look - as written my code expects there to be a partition key called "pK" and a sort key called "sK". The contents of the partition key is an arbitrary "user" uuid, and the sort key is an arbitrary "task" uuid.
thanks, glad you got something out of it! re: Tokio - I think most developers won't have to interact with it directly (it's likely a transitive dependency of the crates you might use). Re: Diesel, it should work great with actix-web!
Thanks Alvaro! I do plan on creating just such a video. Will also likely be creating ones for productionizing such an app, including things like auth, CI/CD, deployment to AWS, etc.
9:41 what is that phenomonen called because I've made that same mistake so many times and it fascinates me how our brain even though it knows what we meant to write we still write what we were saying with our mouth instead
Damn, stopping/going back a couple of time I managed to catch like 10 ads for 30 mins video.. Even when one tries to use yt for some useful/productive purpose, it's still such a terrible platform.. Great video though, as always! :)
Yikes that’s so frustrating! TH-cam Premium is amazing… had it for the past 4 years or so, tried living without it for a week or so at one point and quickly realized it’s the most important subscription I have 😎
@@codetothemoon Damn, somehow I didn't even consider it.. I heard it's a thing quite some time ago, but it just slipped through the cracks, seems like no-brainer at this point I guess :D Keep up the awesome work! :)
This is good stuff, its a bit confusing coming from a Model,view,controller framework do you have any other tid-bits on how to get started with Actix Web and incorporating front end elements like html files or do you suggest using this for the API and other methods for working with views? I have been using codeigniter but I think I am about to move away from it, because they broke their codebase with the new version, so rather than learn relearn the changes in v4 I was considering to switch to something else. Completely new to Rust though.
Hi thatonesnowboarde - maybe check out the "Build A Rust Frontend" video! This particular video is about the backend - MVC is more of a frontend abstraction. Then There is another video called "Full Stack Rust" that ties everything together.
Hey! What are the extensions you are using for this video? For a moment I started adding a lot of additional keywords to the script, until I realized that those were generated by your VSCode extensions. But they seem pretty cool!
I use rust-analyzer. it's the second most popular extension when you search for "Rust" in VSCode's extension marketplace. Heard somewhere it's better than the first one, but I haven't personally done a rigorous comparison.
Hi! What would you personally recommend as the best Rust project for a beginner to start working on? I've been dabbling with Ruat since getting into Wasm a while ago but want to dive in and properly learn. Not sure where to start though...
Great question - I actually think a simple webapp is a good place to start - either the frontend, backend, or both. Or if you're into making games, it seems like there are a few Rust game frameworks that have garnered a substantial following. You mentioned WASM - some of them support browsers as a build target. I haven't tried any of them yet, but it seems like a fun place to start. Check out the TH-camr "Tantan" if that side of things sounds interesting! In terms of approach - I generally dive headfirst into the project, get stuck, read the Rust Book and watch "Let's Get Rusty" videos to get myself unstuck, then repeat over and over...
Bro, your camera window is definitely too small😂 tbh, make it smaller who cares about your appearance rather than the code. Btw great material, appreciate your work!
I was using nodejs and non but updating deprecated dependencies has been a real hassle and I'm developing on an arm x64 device 😭 Is this a better alternative? Can I switch my stack to Python and Rust?
Might need more details to give a fully informed answer, but I suspect that if it's able to run nodejs it can be targetted by Rust. If you're going to use Rust on the frontend it might make sense to use Rust on the backend as well, especially if you're trying to get away from NodeJS. This video is a bit old now, and I think Leptos is now a much better place to start than Yew. It allows you to write backend code in the same project as your frontend, similar to what Next.js would give you.
@@codetothemoon Thanks bro, I just started the app so now I don't mind scrapping everything and starting from scratch with a better solution long-term. I'm building an open source platform that would allow filmmakers to create and deploy their own interactive films. Similar to RenPy, but with a focus on interactive video rather than visual novels. I was going to switch to a full python stack and use flask, but do you think I'd be better off dedicating to a Rust stack instead?
Hi, Simple question. Can we create e-commerce, airbnb like websites using Rust? How can we handle its front end part without touching react or vue at all? I think we need more clone projects from stretch! Thank you!
yep there's nothing preventing you from doing that 100% in Rust! On the frontend you can use something like Yew or Leptos (the latter feels a bit more like the future but the former is more mature). Though you could argue that if the project is business critical something like react/vue/svelte would be a "safer" choice
Do I actually need an aws account for this? Cause trying to run the code it complains about not having configuration for aws. Anyways, awesome content!
Yep! Apologies, I should have made this clearer in the video. Create an AWS account, a DynamoDB table with the name and fields used in the program, and an IAM user with DynamoDB read/write permissions for that table. Then run `aws configure` on the machine you're running this app on, paste in the access key id and secret for the IAM user that you created. Then the app should work! Separate but related topic - would you like to see more videos about AWS?
Thank you for tNice tutorials video! I just got soft softs today, and even with the guidebook, I was lost. TNice tutorials video taught even better than
re: postman, we first create a task by doing POST to the create task API, which accepts a JSON body where we specify various attributes of the task. This returns the task id of the newly created task, which we can pass to the other task APIs via a URL path parameter. re: user id and blender file, these are just dummy values that we store in the database, as written in this video they don't have any functional effect. So you can just use any random values for those.
it's the start of something that could be used in production, i think in most cases you'd also want to have some kind of authorization/authentication as well. let me know if you'd find a video on that valuable!
should be! Maybe some of the APIs have changed slightly but afaik this is still valid. Though it's worth pointing out that now we have Leptos which is a great full stack webapp solution that actually uses Actix for the backend - so you can have your frontend and backend in one project ala SvelteKit or Next.js. It's quite nice - video to come soon hopefully
are there any IDEs with proper syntax highlighting and intelligent code inspection/suggestions for rust? looking for basic things like automatically importing the right object when trying to use it in the file, or suggestions for overriding methods that are missing, or intelligent suggestions for idiomatic uses. i'm currently trying to IntelliJ + clippy but it's really lacking compared to something like Java
Great tutorial! Unfortunately I am quite stuck at the last step with the testing. I have ensured my code is just like yours, but when I submit the post request in Postman I get a TaskCreationFailure from the middleware logger, and haven't been able to make much progress on debugging this. Help would be appreciated!
I think choosing an ORM is sort of orthogonal to choosing a backend framework - the only Rust ORM I've used is Diesel, which many find to be too complicated. I've heard good things about SeaORM but I haven't used it myself.
@@codetothemoon Is diesel asynchronous? Meaning, the SQL queries will not block the thread? I wonder how it plays out with Actix which is uses on Tokio
Hey, great tutorial, but I've run into a problem with the dependency injection part, I hope someone here can help me with that. So what I have is a setup similar to this, except instead of dynamodb I have a connection to a postgres database via Diesel. I'm only working with a single table called "Student" for now with id, name, email and dob.I use this connection to construct a PostgresStudentRepository struct that is responsible for all of my data access operations (get, get_all, insert etc) So far so good, but I'd like to abstract this away so that my api doesn't depend on a specific implementation so that I can swap it out easily if I want, or use a mock implementation or maybe some in-memory db for testing. For this I have created a StudentRepository trait that my PostgresStudentRepository implements. (I know this is still not the most optimal solution as I could generalize the Repository pattern even more to be able to use it for other tables as well, but this is what I'd like to get working for now.) And in my API I accept Data instead of Data. However when I try to call my endpoints, I get an error saying "Failed to extract `Data`. I have found this SO question with a very similar problem: stackoverflow.com/questions/65645622/how-do-i-pass-a-trait-as-application-data-to-actix-web Here they suggest to wrap my struct in an Arc before injecting it, so like Data::from(Arc::new(blahblah)), I've tried this but I still get the same error. I've also tried using static dispatch to get the same effect but it didn't compile, said it couldn't infer the type, which is why I'm using dyn in the first place. I suspect there is something I'm missing, so in general how should I go about injecting traits with App::app_data? Thanks.
Does anyone have a simple example of using awc or reqwest within an actix handler, awaiting a request to an external api and parsing the response and returning as a Result or similar?
I don't have an example handy, I'm assuming you're stuck on converting the results of the reqwest into something that you can return from the actix handler?
@@codetothemoon that’s pretty much it yes. I think part of the issue is that it doesn’t like the error of request/awc, probably need to update the error_response implementation.
@@codetothemoon you have to go via multipart class, which si basicaly stream of values names and bytes, and you have to reconstruct that form by yourself. In python flask form is just almost dictionary,…
Greetings! Thanks for the wonderful video and explanations. But now I'm trying to run a completely identical code and I get an error at the first POST request, there is such a moment with the region in the logs, but I do not know how to fix it... Can you please help? Log: ..... [2024-11-18T16:58:29Z INFO aws_smithy_http_tower::parse_response] send_operation; message=timeout: error trying to connect: HTTP connect timeout occurred after 1s [2024-11-18T16:58:29Z INFO aws_smithy_http_tower::parse_response] send_operation; status="construction_failure" [2024-11-18T16:58:29Z INFO aws_smithy_http_tower::parse_response] send_operation; message=Failed to load session token: timeout: error trying to connect: HTTP connect timeout occurred after 1s [2024-11-18T16:58:29Z WARN aws_config::imds::region] failed to load region from IMDS err=Failed to load session token: timeout: error trying to connect: HTTP connect timeout occurred after 1s
I appreciate the time you put into these videos. However, one can easily conclude that Rust does offer security, a fast and efficient application if done right but the developer experience is not good so far at least for me. I mean look at your own example it took so much time and code just to have a simple CRUD API for tasks. I'll stick with the Go for now. Go > Rust 🦾
I also made the experience that Rust is completely overkill for creating backend APIs, just go with Golang if you want to learn something new or keep to Java, most companies have written their Applications in Java
My main interest in Rust, so far, has been for doing bare-metal embedded development. So it's quite fascinating to see you doing web-backend stuff in Rust (that's my day-job).
The idea of using one language for low-level, high-level and everything-in-between-level is quite refreshing in this day and age where I jump from PHP to Python to C and fiddle-faddle with some other stuff too (although I'm still stuck with Kotlin for now if I'm doing anything Android).
I am very taken with the idea of *"One language to rule them all... and in the crab shell bind them".*
Yeah I do think Rust is under appreciated for webapp development and other things conventional wisdom says you should use a "higher level" language for. It seems like it's been unfairly pigeonholed as a "systems language" in that sense. Love the LOTR adaptation haha
@@codetothemoon zero cost abstractions make it all worthwhile.
I am an Android developer as well. If you’re willing to endure some pain, try using the Java native interface along with Rust foreign function interfaces. It’s quite fun, way more exciting than building a CRUD backend with a web app!
Having never really coded much in Rust before, trying to introduce Postgres, to make this a little more portable and less cloud-dependent, has proven to be quite the exercise! Definitely went down the rabbit hole on this one haha.
I really like how you laid everything out with this project. This all seems right. Most demos, tutorials, and other things out there are just kind of the bare-minimum code necessary to get something to compile and run. I've been trying to get some good insight into how Rust devs actually structure their projects, split things out, et cetera. Hoping I can adapt this to leverage Postgres! (Or maybe even Diesel, somehow)
Also, the editing seemed pretty spot on! I had to do lots of pausing and whatnot, though, so the only suggestion would be to maybe keep a few more frames in between jumping around, just so that those who need to can pause the video and don't have to back track much.
Thanks Joseph! Would be awesome if you could share your experience integrating with Postgres/Diesel - I believe I'm going to make a video about this in a few weeks.
Re: pacing, thanks so much for the feedback! I'll make an effort to pause a bit more in future videos!
Jee Dude,
I watch you code in rust and I am amazed at your skills and the language.
I love rust and for the first time, I wish there was a magic pill that could get me there fast. I am a Senior Java guy and do that all day for now. But man! What an awesome language. Keep these examples coming.
Please!
Thanks so much for the kind words Seba! I actually have a similar background - was a die-hard Java fan up until a few years ago. Was really into Java Swing back in the early 2000s. Rust can seem intimidating, but once you internalize the tricky parts it's all downhill from there. Check out the "Rust Demystified" video if you haven't already!
I totally enjoyed watching this video. Learning by doing at its best! Thank you so much!
I'm a new developer in RUST and this was an awesome tutorial. I came from PHP and Typescript and I was looking for a new language to build fast REST API Backends. Thanks for this tutorial.
One question: Between Actix and Rocket do you se any big difference? Do you recommend to use Actix-Web? Thanks again for this quality material.
I really appreciate your videos! Thanks for the time and effort you put into them!
For us that are visual and helicopter learners (meaning we need visual reenforcement between topics and a wide scope of view down to details) I could use a bit more space in-between topics with maybe a bullet-list of where we are going. The speed of this particular video is perfect language-wise, but you have a tendency to speed up in some of your other videos. You have a good resonant voice, a good dialect, and speak clearly - which is awesome! Keep up the great work!!
Thanks so much for the kind words and for the feedback!! I think spacing out the topics and maybe using a bullet list as the "roadmap" for the video is a fantastic idea - I'll likely incorporate something like this in future videos!
thanks for the amazing video!, im currently starting out with rust as my first "proper" attempt at learning a language. i heard programming a website is really good for learning so im going to try and build an entire site with just rust and some mysql as apparently you can code the front and back end in rust! thanks again
Nice Zorba! I've actually never heard of anyone learning Rust as their first programming language. There are quite a few folks that might try to talk you out of it, but I think you'll be fine! It is indeed very versatile.
Hello, You're producing really good content. i have watched other rust related video, Keep it up. One suggestion, consider shrinking down your video little bit, currently it feels bit overwhelming. Like almost 1/4th of the screen so reading code becomes bit difficult.
Thanks for the kind words! and thanks for letting me know about the video being too large, that's just the sort of feedback I'm looking for! Will make it smaller in the next one.
@@codetothemoon 😂🎉 🎉e 1:08 😢😅😮😮😢
Thanks for this video. clear, concise, and good pacing (for me at least). I love Actix's perf characteristics but being new to Rust it feels a bit more intimidating than some of the other frameworks but I think you've talked me into it. Now I just need to get my head around when to use the Actix web framework versus the actor framework ... and I see now they have a broker too?
Glad you found it valuable! I actually haven't delved into the actix actor framework yet - apparently (at least according to actix.rs) Actix web doesn't use the actix actor framework under the hood anymore. Seems like it has been at least partially replaced by language features...
I like the style of your videos - they're to the point and concise. Would it be possible to turn off the VSCode pop-ups whilst you're doing them though? There's a lot of time where I'm slightly behind you in comprehending what you just did, but the pop-up is covering the code now.
Thanks Neil! and great feedback, I generally intend to turn off the hints / autocomplete before recording a video, but there are several videos where I neglected to do so, including this one T_T
Just an FYI, methods are functions defined for a struct (or an enum or trait object).
So no need to self correct there ;)
Got it thanks Martin! I think in the moment I got scared that I had borrowed a term from a non-Rust language, glad to hear that wasn't the case....
@@codetothemoon YW, I like your videos so being able to help make them better is awesome, terminology can be weird and inconsistent :p. You have functions, associated functions, anonymous functions & methods (I think that's it?).
Young Val Kilmer teaching me Rust, nice.
Thank you for this explanation! Would you ever consider making your own blockchain ?
Best rust content out there at the moment! Keep up the great work.
Thanks jemduff!
Thanks for this awesome tutorial, loved the way you explain rust🙌. do you have any plans on making a tutorial for actix or so. since there are fewer or not useful videos on this framework. Thanks.
Thanks, glad you found it valuable! Do you mean actix as in the actor framework?
@@codetothemoon Tutorial for actix v4, i don't know about actix in actor framework but it have been 2 months i have stated learning rust and now i love to code in rust and use actix with PostgreSQL for web backend.
I personally would like to see you flesh out the repository code even if you think it's not worth it. Also don't feel insecure about your code!! Not sure why you didn't show it but I appreciate your videos even if you think the code is "hairy" here and there.
I would have loved to explain it but was worried the lengthy explanation would dilute the "value per watch second" folks get out of the video, especially for those that don't plan to use DDB.
You could pass task using a pointer so that the task can be borrowed, then you wouldn't have to copy the task_identifier
thanks for the pointer (pun intended?) there were a few places where I was trying to pass a borrowed value but couldn't get it to work, I'll revisit this one!
Great videos! Didn't see the dynamo setup video on your channel. Perhaps a "suggested video" card could be helpful for people to reference your previous videos easier
thank you and great idea! did a video on dynamoDB here th-cam.com/video/_TQ3UTyKdJ8/w-d-xo.html more of an overview of what its capable of than a tutorial though, for the latter you might try the aws docs here docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html
Very interesting and good paced video! One small thing I'd have found interesting is starting the program a few times inbetween and look at the current progress. Also the compiler error at 13:15 would have been interesting. But overall very high quality content! Can't believe you don't have more subscribers
Thanks Fabian! This is fantastic feedback. Next time I do something like this i'll try to run it after each sort of "milestone" so it's easier to see the progression
Hi! Great video, just a question. How does one learn all these stuff? Not only related to rust (like the libraries, and such), but web applications in general? I find it extremely overwhelming considering the amount of stuff related. If you had any advice, that would be awesome.
thanks Pedro! I wish I had a good recommendation for a one-stop resource for learning about REST services and webapps. My advice would be to take a course on Next.js (well established framework) or SvelteKit (the up and coming framework that appears to be favored over Next by many people) - those should cover all aspects of webapp development as they encompass both the frontend and the backend.
What's interesting to me is actually how slow a lot of those requests ended up being. I assume it's probably network latency to DDB, but 221ms to do a single lookup on a tiny table and return it as JSON seems like a lot.
For reference, a brand new Ruby on Rails app hitting a local mysql takes about 50ms for me, and Ruby/Rails is considered bloated and slow by many.
You're absolutely right - I actually didn't notice the latency until you pointed it out! 200+ms does seem really slow. I'll have to dig in and find out where the bottleneck is - my guess is that it's not the Actix framework though.
@@codetothemoon Any luck figuring out the bottleneck source ?
@@lucaszecat i think its always the io to aws sdk. its been always to io like to database, or sdk or another services
Great video.
A quick thought: (hot take, don’t take too seriously, and I know the video is old.)
Writing out all the dependencies early on is typically not how I develop. I usually start fresh and then I add dependencies one at a time as I need them by looking at the relevant docs. Until I work with them enough to know them by heart. My thought is that maybe it would be clearer to present it that way.
But maybe it isn’t.
Do you usually program like this or is it for presentation purposes?
thank you - and this is great feedback! I did it this way just for presentation purposes - to your point, when I'm actually developing I add them as needed. After thinking about it for a minute, I think you're right - if I add dependencies as I need them, it would probably make it easier for the viewer to mentally connect the implementation with the specific dependency required for that logic.
in the newest version of cargo we can use " cargo add " to add dependencies.
I haven't tried this yet, should save a ton of time!
@@codetothemoon I'm a new rustocean, I used to use nodes packages managment and figure out that by coincidence
very cool, thanks for the rundown, stay rusty
thanks for watching!
15:50 for the Task struct, why didn't you use str instead of all those String's?
Super helpful video, thanks!
nice, happy you got something out of it!
Great work!
thanks, this is just the sort of feedback I need to improve! thanks for watching!
i like your style this fast 2x when write code good idea
Thanks, glad you liked it!
Do you think is it good for web development.
Like i have a strong foundation in rust.
But I don't know should i do web development in rust or not ?
Or should i stick to typescript for web development?
it's tough to say - if you're building a mission critical application under a tight deadline in 2024, typescript is probably the more pragmatic / less risky choice. If you can afford to take a bit of risk and have a little more leeway in terms of completion time, Rust can be a viable choice. Definitely check out Leptos if you haven't already.
@@codetothemoon i have started to implementing a server in Rust. I think it's avery good thing now I m feeling it's better to write server code in Rust rather than node.js etc
Will sure see Leptos....
Thanks brother 👍👍
Hi! Awesome video. Which language, out of the following three, would you say that makes web dev easier/faster without sacrificing speed? Rust, Go or Elixir?
Well looks like you earned yourself a subscriber!
Thanks Jesse, very happy to have you onboard!
This is amazing, just what I needed. Thank you so much!
thanks, so happy you found it valuable!
As a basic proof of concept for a larger idea I've been sitting on, I'm trying to find a backend framework that will efficiently receive input data with specifications for a Vue component (template element types, selected style properties, a specified set of variables, and a limited set of methods to perform on these variables) and respond with a properly formatted text file that can be mounted to a code element on the front end. Do you think Actix is a good choice for a gizmo of that nature?
Your video is awesome!!!!!
Thank you so much!
Thank you, glad you found it valuable!
Followed the tutorial, made an AWS account but now I'm not sure what to set the primary and sort keys in the table as. Anything I seem to try just results in "One or more parameter values were invalid: Missing the key" and a TaskCreationFaliure.
Just took a look - as written my code expects there to be a partition key called "pK" and a sort key called "sK". The contents of the partition key is an arbitrary "user" uuid, and the sort key is an arbitrary "task" uuid.
Hello,
Excellent video.
What is your advise about Tokio framework and diesel; can they be used in a backend API together with actix-web?
thanks, glad you got something out of it! re: Tokio - I think most developers won't have to interact with it directly (it's likely a transitive dependency of the crates you might use). Re: Diesel, it should work great with actix-web!
Hello! Love your content. Do you plan on creating a video tutorial to create a web app with Actix and Yew?
Thanks Alvaro! I do plan on creating just such a video. Will also likely be creating ones for productionizing such an app, including things like auth, CI/CD, deployment to AWS, etc.
@@codetothemoon If you can throw in some Diesel or other ORM that would be great as well :)
@@AlvaroAlfaroSantiesteban been meaning to check out Diesel, will see what we can do!
9:41 what is that phenomonen called because I've made that same mistake so many times and it fascinates me how our brain even though it knows what we meant to write we still write what we were saying with our mouth instead
Damn, stopping/going back a couple of time I managed to catch like 10 ads for 30 mins video.. Even when one tries to use yt for some useful/productive purpose, it's still such a terrible platform..
Great video though, as always! :)
Yikes that’s so frustrating! TH-cam Premium is amazing… had it for the past 4 years or so, tried living without it for a week or so at one point and quickly realized it’s the most important subscription I have 😎
@@codetothemoon Damn, somehow I didn't even consider it.. I heard it's a thing quite some time ago, but it just slipped through the cracks, seems like no-brainer at this point I guess :D
Keep up the awesome work! :)
Hello, thanks you for this tutorial. It will be interesting for one to many use case or similar to see rust framework powerful ?!
thanks for watching, glad you found it valuable!
This is good stuff, its a bit confusing coming from a Model,view,controller framework do you have any other tid-bits on how to get started with Actix Web and incorporating front end elements like html files or do you suggest using this for the API and other methods for working with views? I have been using codeigniter but I think I am about to move away from it, because they broke their codebase with the new version, so rather than learn relearn the changes in v4 I was considering to switch to something else. Completely new to Rust though.
Hi thatonesnowboarde - maybe check out the "Build A Rust Frontend" video! This particular video is about the backend - MVC is more of a frontend abstraction. Then There is another video called "Full Stack Rust" that ties everything together.
Hey! What are the extensions you are using for this video? For a moment I started adding a lot of additional keywords to the script, until I realized that those were generated by your VSCode extensions. But they seem pretty cool!
I use rust-analyzer. it's the second most popular extension when you search for "Rust" in VSCode's extension marketplace. Heard somewhere it's better than the first one, but I haven't personally done a rigorous comparison.
@@codetothemoon Perfect. Thank you!
Hi! What would you personally recommend as the best Rust project for a beginner to start working on?
I've been dabbling with Ruat since getting into Wasm a while ago but want to dive in and properly learn. Not sure where to start though...
Great question - I actually think a simple webapp is a good place to start - either the frontend, backend, or both. Or if you're into making games, it seems like there are a few Rust game frameworks that have garnered a substantial following. You mentioned WASM - some of them support browsers as a build target. I haven't tried any of them yet, but it seems like a fun place to start. Check out the TH-camr "Tantan" if that side of things sounds interesting!
In terms of approach - I generally dive headfirst into the project, get stuck, read the Rust Book and watch "Let's Get Rusty" videos to get myself unstuck, then repeat over and over...
very helpful, thanks!
thank you so so so much for your support! 😎 realy happy you got something out of the video!
Bro, your camera window is definitely too small😂 tbh, make it smaller who cares about your appearance rather than the code. Btw great material, appreciate your work!
I was using nodejs and non but updating deprecated dependencies has been a real hassle and I'm developing on an arm x64 device 😭 Is this a better alternative? Can I switch my stack to Python and Rust?
Might need more details to give a fully informed answer, but I suspect that if it's able to run nodejs it can be targetted by Rust. If you're going to use Rust on the frontend it might make sense to use Rust on the backend as well, especially if you're trying to get away from NodeJS. This video is a bit old now, and I think Leptos is now a much better place to start than Yew. It allows you to write backend code in the same project as your frontend, similar to what Next.js would give you.
@@codetothemoon Thanks bro, I just started the app so now I don't mind scrapping everything and starting from scratch with a better solution long-term. I'm building an open source platform that would allow filmmakers to create and deploy their own interactive films. Similar to RenPy, but with a focus on interactive video rather than visual novels. I was going to switch to a full python stack and use flask, but do you think I'd be better off dedicating to a Rust stack instead?
Hi, Simple question. Can we create e-commerce, airbnb like websites using Rust? How can we handle its front end part without touching react or vue at all? I think we need more clone projects from stretch! Thank you!
yep there's nothing preventing you from doing that 100% in Rust! On the frontend you can use something like Yew or Leptos (the latter feels a bit more like the future but the former is more mature). Though you could argue that if the project is business critical something like react/vue/svelte would be a "safer" choice
Do I actually need an aws account for this? Cause trying to run the code it complains about not having configuration for aws.
Anyways, awesome content!
Yep! Apologies, I should have made this clearer in the video. Create an AWS account, a DynamoDB table with the name and fields used in the program, and an IAM user with DynamoDB read/write permissions for that table. Then run `aws configure` on the machine you're running this app on, paste in the access key id and secret for the IAM user that you created. Then the app should work!
Separate but related topic - would you like to see more videos about AWS?
@@codetothemoon thank you, and sure, more aws videos would be even more AWSome :)
@@schabby30 i see what you did there!! 🙃
Thank you for tNice tutorials video! I just got soft softs today, and even with the guidebook, I was lost. TNice tutorials video taught even better than
🔥
can you explain what you typed in postman also where to get an user id and the blender file or is it not necessary
re: postman, we first create a task by doing POST to the create task API, which accepts a JSON body where we specify various attributes of the task. This returns the task id of the newly created task, which we can pass to the other task APIs via a URL path parameter. re: user id and blender file, these are just dummy values that we store in the database, as written in this video they don't have any functional effect. So you can just use any random values for those.
Great video, thank you 😁👍
thanks for watching!
Could i use this videos tut in productions for backend api webserver?
it's the start of something that could be used in production, i think in most cases you'd also want to have some kind of authorization/authentication as well. let me know if you'd find a video on that valuable!
Congrats!!
Thanks!
Is this still a valid solution?
should be! Maybe some of the APIs have changed slightly but afaik this is still valid. Though it's worth pointing out that now we have Leptos which is a great full stack webapp solution that actually uses Actix for the backend - so you can have your frontend and backend in one project ala SvelteKit or Next.js. It's quite nice - video to come soon hopefully
are there any IDEs with proper syntax highlighting and intelligent code inspection/suggestions for rust? looking for basic things like automatically importing the right object when trying to use it in the file, or suggestions for overriding methods that are missing, or intelligent suggestions for idiomatic uses. i'm currently trying to IntelliJ + clippy but it's really lacking compared to something like Java
Great tutorial! Unfortunately I am quite stuck at the last step with the testing. I have ensured my code is just like yours, but when I submit the post request in Postman I get a TaskCreationFailure from the middleware logger, and haven't been able to make much progress on debugging this. Help would be appreciated!
This line is in my info output as well if it helps:
aws_smithy_http_tower::parse_response] send_operation; status="construction_failure"
@@eyo4821 Do you have the DynamoDB table set up and credentials configured in ~/.aws/credentials?
Any ideas how to implement onion architecture and unit of work in Rust?
Great, thank you.
You're very welcome, thanks for watching!
What is the best ORM to use with Actix?
I think choosing an ORM is sort of orthogonal to choosing a backend framework - the only Rust ORM I've used is Diesel, which many find to be too complicated. I've heard good things about SeaORM but I haven't used it myself.
@@codetothemoon Is diesel asynchronous? Meaning, the SQL queries will not block the thread? I wonder how it plays out with Actix which is uses on Tokio
bro, whats on your shirt?
Mark Rober’s glitter bomb! 😎
thank youuuuuuuuuuuuuuuuu
you're welcome!
Question is - how to learn all this stuff knowing basic RUST?
Does anyone know how to connect this application with local dynamodb (docker)? What kind of environment variables are needed?
Hey, great tutorial, but I've run into a problem with the dependency injection part, I hope someone here can help me with that.
So what I have is a setup similar to this, except instead of dynamodb I have a connection to a postgres database via Diesel. I'm only working with a single table called "Student" for now with id, name, email and dob.I use this connection to construct a PostgresStudentRepository struct that is responsible for all of my data access operations (get, get_all, insert etc)
So far so good, but I'd like to abstract this away so that my api doesn't depend on a specific implementation so that I can swap it out easily if I want, or use a mock implementation or maybe some in-memory db for testing. For this I have created a StudentRepository trait that my PostgresStudentRepository implements. (I know this is still not the most optimal solution as I could generalize the Repository pattern even more to be able to use it for other tables as well, but this is what I'd like to get working for now.) And in my API I accept Data instead of Data.
However when I try to call my endpoints, I get an error saying "Failed to extract `Data`.
I have found this SO question with a very similar problem: stackoverflow.com/questions/65645622/how-do-i-pass-a-trait-as-application-data-to-actix-web
Here they suggest to wrap my struct in an Arc before injecting it, so like Data::from(Arc::new(blahblah)), I've tried this but I still get the same error. I've also tried using static dispatch to get the same effect but it didn't compile, said it couldn't infer the type, which is why I'm using dyn in the first place.
I suspect there is something I'm missing, so in general how should I go about injecting traits with App::app_data? Thanks.
Does anyone have a simple example of using awc or reqwest within an actix handler, awaiting a request to an external api and parsing the response and returning as a Result or similar?
I don't have an example handy, I'm assuming you're stuck on converting the results of the reqwest into something that you can return from the actix handler?
@@codetothemoon that’s pretty much it yes. I think part of the issue is that it doesn’t like the error of request/awc, probably need to update the error_response implementation.
what if I need two identifiers at 8:41?
actix is nice, but when to come to handling form data with file, things get mad (comparing to python flask for example) :D :D
how so?
@@codetothemoon you have to go via multipart class, which si basicaly stream of values names and bytes, and you have to reconstruct that form by yourself. In python flask form is just almost dictionary,…
Any interest in making an example like this using Tokio's new axum framework?
What should aws_config::load_from_env() be loading? I've placed nothing in the environment for it.
it loads from your aws configuration files. If you download the aws cli, you can use it to configure your keys and profiles.
Is this fireship io? His voice is the same or I imagining
That’s a huge complement, thank you 🙏
Am I the only one who can't run and hit my endpoint? Tried watching/rewatching/cloning the code, there's no readme or anything
enooms xD
all day!! 🙃
Rust: from start to giving up 🤣
no don't give up! what are you stuck on?
All the bureaucracy….
What are you referring to?
what keyboard?
It’s a redragon, link is in the description! Mine is kind of old though, might be a slightly different model
@@codetothemoon thx
How in the world is someone supposed to just "know" all of these steps? The Rust ecosystem seems a bit opaque.
What he did is very similar to other languages in how they stand up APIs
E-nooms
вот это рыгачка
english translation is "this is the lever" - what do you mean?
fastforwarding code typing in the mid of a sec does not make you a better coder.
No? Back to the drawing board then I guess 😔
Why stop there! jsut write machine code instead!
Good idea! 😎
No thanks
What’s the most off putting aspect for you?
Greetings! Thanks for the wonderful video and explanations. But now I'm trying to run a completely identical code and I get an error at the first POST request, there is such a moment with the region in the logs, but I do not know how to fix it... Can you please help?
Log:
.....
[2024-11-18T16:58:29Z INFO aws_smithy_http_tower::parse_response] send_operation; message=timeout: error trying to connect: HTTP connect timeout occurred after 1s
[2024-11-18T16:58:29Z INFO aws_smithy_http_tower::parse_response] send_operation; status="construction_failure"
[2024-11-18T16:58:29Z INFO aws_smithy_http_tower::parse_response] send_operation; message=Failed to load session token: timeout: error trying to connect: HTTP connect timeout occurred after 1s
[2024-11-18T16:58:29Z WARN aws_config::imds::region] failed to load region from IMDS err=Failed to load session token: timeout: error trying to connect: HTTP connect timeout occurred after 1s
this is top 2 now xitca-web ... its inspired by actix.. and top 1 is drogon-core
interesting, hadn't heard of this one! wondering if it's aim is to be a full featured framework or just a benchmark exercise...
I appreciate the time you put into these videos. However, one can easily conclude that Rust does offer security, a fast and efficient application if done right but the developer experience is not good so far at least for me. I mean look at your own example it took so much time and code just to have a simple CRUD API for tasks. I'll stick with the Go for now.
Go > Rust 🦾
I also made the experience that Rust is completely overkill for creating backend APIs, just go with Golang if you want to learn something new or keep to Java, most companies have written their Applications in Java