Web developers should start learning Rust now (its not about webassembly)

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 88

  • @ChumX100
    @ChumX100 2 года назад +53

    Love the language. Seems to me that the reason of its steep learning curve is that it doesn't hide complexity from the dev in exchange for performance, instead, it gives you well thought-out tools to tackle that complexity head-on in a safe way.

  • @skyy_xx
    @skyy_xx 2 года назад +47

    I totally agree. Less than month ago I decided to learn Rust because TS/Nodejs/Rails as backend are mostly slow and massive compared to Rust performance, and I'm planning to leave nodejs in favor to Rust but still using Rails for Rapid development, smaller project and MVP as it's great tool. Also Rust are so universal and compatible i.e. Tauri for cross platform apps development and code compatibility with every platform, growing game development, machine learning and other projects just shows it's potential.
    I've written Rust server with actix + juniper + diesel and compared it to nodejs + fastify + mercurius performance with autocannon that was sending same version query request.
    Node was 23k req/s (Fastify one of fastest from node family here) Rust (in release build) was 125k req/s, also RAM usage and app size, whole Rust webserver takes 7mb after compilation and uses 3-4mb of ram on my kubernetes servers , while Rails idle usage are 190mb and jumps with calls, Nuxt SSR takes round 90mb RAM and Fastify something around it.
    I've also written twitch bot with rust + diesel for database + actix api for showing bot command + vue3 frontend to show API. I've thrown it into kubernetes aswell, 2 instances of API, 2 instances of Vue3 web apps served on nginx image and 1 bot process takes all round 20mb of RAM and that's crazy. Even if I have 24GB of ram on my servers It doesn't matter as now I can probably host hunderts of web apps and it'd work great. Only using SSR for frontend will be more consuming but it's still low amount of memory.
    And I mean Rust only by backend, using JS/TS for frontend are great and universal way. Ionic for Mobile, Tauri for Desktop (mobile will come later), Electron are bad example as it's heavy and fully working on node.
    I've created example tauri application with some calculations on rust backend and my full Vue3 stack on front - apollo,state management,tailwindcss and other things. After compiling it to application it was like 7.8mb and took not more RAM on runtime. And using style library like Tailwind that has normalize.css and autoprefixer solves most of compatibility cases as it works on system native webview not build in chromium.
    Forgot to mention Rust compiler that takes care of every line in your code so you won't mess it up and later you'll get into and errors shows less often.
    Overall I was struggling with the book and it took me relatively long time to feel comfortable with Rust but I don't regret. It's great tool and future of development - security, performance and compatibility.

    • @lindblomdev
      @lindblomdev  2 года назад +1

      Thanks for this long and meaty comment :) I have not looked at Tauri but is sounds like something i should keep on my radar in-case i want to make a desktop application. Regarding your Node test, it says 23k vs rust 125k req/s. I wonder if node was also limited by its single core limitation or did you hook something up in-front of it to make it use all your cores? Do you still have everything and can run it again, this time also looking at the CPU utilization? Even if Node was limited by the CPU and the requests per second gets a bump if you spin up more instances to use the equal amount of cores, it would still be a more complex set up and the node overhead would be multiplied by the number of instances you have to run.
      I remember ruby from the pre-2.0 days and back then rails were also around 200MB memory (a little above iirc), sounds like not much have changed in that regards. They probably have a different focus.

    • @skyy_xx
      @skyy_xx 2 года назад

      @@lindblomdev RUclips put my reply probably to spam, can you check?

    • @lindblomdev
      @lindblomdev  2 года назад

      Yes I will check it when I get to a computer. I can't see it in studio on the phone.

    • @lindblomdev
      @lindblomdev  2 года назад

      Now i also checked from the computer. And i cannot find your comment, i dont even have the "likely spam" tab :/

    • @skyy_xx
      @skyy_xx 2 года назад +2

      @@lindblomdev Classic youtube, I've written that Node has easy cluster implementation but you need to use i.e. redis for storing temporary data than in hash.
      I've made tests again but also enabled clustering in my nodejs app as I've had this function but disabled for development env. Actix performed worse today than day ago without code changes, kinda strange.
      Paste this after imgur url to get image a/mYZO7Dv (prob url was cause of comment deletion)
      It's all tested on macbook air m1
      Look also at ram usage but don't look at reference ram as I've closed some browser tabs since then.

  • @தமிழோன்
    @தமிழோன் 2 года назад +13

    The moment I stumbled upon Rust a few years ago, I fell in love with it! I like how Rust has no 'null' but it has the elegant Option instead, and no exception but it has Result instead. It's the most beautiful language I have ever seen! Long live Rust! ❤️

    • @bjugdbjk
      @bjugdbjk 2 года назад +1

      +1

    • @v01d_r34l1ty
      @v01d_r34l1ty 2 года назад

      Trying to learn Rust and I hate it. I would love to get into it, but it's a pain in the ass to learn. Everything with crates and unwrap()s just pisses me off and 5 days I spent trying to learn, and I haven't made any progress whatsoever. It's so boring. I learned a good 75% of what I know in C++ in 2 days and it's lasted me years. 5 days and all I can do is the basic shit that you learn within the first hour of C++. If you have any advice, I'd be happy to hear it as you say you have a few years experience with it, but it's pissing me off having been used to being a self-taught programmer, but now not even being able to grasp why anything is done in an overly OO language.

    • @தமிழோன்
      @தமிழோன் 2 года назад

      @@v01d_r34l1ty I had a similar feeling when I started writing my first Rust code haha. I guess you’re on the right track. 😅
      Rust compiler is pedantic, yes, but that’s what differentiates from other languages. You’re never allowed to write bad code.
      And you’ve mentioned that you had to use unwrap(). But you’re not supposed to use it unless you know that the value will always be ‘Some’thing and not ‘None’. You should always address the absence of value in your code. That’s what Rust is forcing you to do!

    • @v01d_r34l1ty
      @v01d_r34l1ty 2 года назад

      @@தமிழோன் thanks for that I guess… but it doesn’t help with the api any. Don’t understand the macros and don’t understand the way packages are laid out or even how to use the std api. Switching from knowing C++ and having a good outline of how memory works to Rust and having no idea how it compiles is stressful to say the least lol.

  • @xiuxiu624
    @xiuxiu624 2 года назад +9

    such a good language, i picked it up last year and it’s my go to for most side projects now. really excited to see where it goes in the next few years

    • @lindblomdev
      @lindblomdev  2 года назад +1

      Cool. What have you built so far?

  • @TAINCER_
    @TAINCER_ 2 года назад +6

    I'm using rust for many months now. The thing that "annoys" me is that there are many, many talks or videos like this online describing the first half of the video (or the whole video) what rust is and why someone would choose it. Borrow checker, etc. I know it's important to on-board people, but still. The amount of people covering intermediate stuff like architecture or best practise error handling (in a real Programm context) is not very large. At least in video form. For anyone looking for intermediate videos, search for "Jon Gjengset" on RUclips. He's covering intermediate stuff very extensively, but the videos are very lengthy. He also wrote the book "Rust for Rustaceans"

    • @lindblomdev
      @lindblomdev  2 года назад

      I agree, Jon is very good: ruclips.net/user/JonGjengset
      His book is also good, the only book I feel has given me anything after reading "the rust book". As it goes more in depth and doesn't just say the same surface level stuff as every other book out there.

  • @yongjiachan575
    @yongjiachan575 2 года назад +4

    I'm happy to have Rust as an option for web / cloud project. Components that need speed and memory efficient, I can use Rust, where attach Java or Node as it's web frontend through API or Event Stream. I'm able to reduce my server cost by migrating some of the service from Node / Java to Rust. Although 20$ a month doesn't bother much, but (20$ x 12months) vs (5$ x 12 months), then we see the different.

    • @lindblomdev
      @lindblomdev  2 года назад

      So you do some sort of event processing in rust. And leave the api Frontend to remain where it was before. That's a nice way of moving logic over to rust, without complicating your stack with FFI. Especially if you already have a non locked in message based solution. 👍

  • @AlexanderSuraphel
    @AlexanderSuraphel 2 года назад

    How this channel has only 1.22K is beyond me. Your content is gold Chris!

    • @lindblomdev
      @lindblomdev  2 года назад +1

      Thank you for your kind comment :)

  • @casecamel6719
    @casecamel6719 2 года назад +1

    Rust solves lots of problems in a very elegant way called 'ownership' and this concept itself is worthy to know.
    I don't think everyone should learn this for now especially for programmers that already has a C language backgrounds.
    Language is beautiful, but thinking about the performance, its capability is "near C" not exceeding.
    But thinking about catchin bugs and productivity, I think there will be a lot of projects using Rust.

    • @lindblomdev
      @lindblomdev  2 года назад

      Hum.. I haven't argued for increased performance compared to C. Only high level programming languages like python, ruby, Java, etc. While I agree that you will not beat C performance over short or very well written C. But I have heard from teams where they could improve their solution to make it more performant taken as a whole thanks to the support from the language. Where for example concurrency and/or parallelism were too hard to get right.

  • @DissyFanart
    @DissyFanart Год назад

    I just recently started to wrap up my first full stack web project, it took me a couple months of on and off work but I never could've done this if it wasn't for the safety of rust

    • @lindblomdev
      @lindblomdev  Год назад

      Did you do your first web project ever and you did it in rust? That is very impressive IMO :)

  • @DavidAlsh
    @DavidAlsh 2 года назад +2

    Love the language but I think it has significantly more utility as a tool to build GUI applications - be it web or native.
    In the server we can always horizontally scale, sure it's costly but even if you have a memory hogging single threaded application server, you just spawn more containers and distribute them across a cluster. You are in control of the hardware it runs on after all.
    On the client however, you cannot buy your customers a faster machine. Resources are precious and a language that lets us take maximal advantage of the client CPU cores and memory is essential to ensure a smooth experience.
    Imo, we need a simplified Rust derivative that uses simple data types, like "array" "map" or "string". Half the battle of learning rust is the high fidelity data types.

    • @lindblomdev
      @lindblomdev  2 года назад +1

      Yes that is true. An increase of the replicas setting in the deployment will make kubernetes spin up more pods. But seeing low memory useage when I run kubectl top pod would be 😍 instead of what I see when I run it today and see my .net numbers.
      It sounds a bit like you are describing swift at the end there in your comment? They even have a ownership manifesto, maybe they pick that up.

    • @DavidAlsh
      @DavidAlsh 2 года назад +1

      @@lindblomdev I haven't looked at Swift, it being an apple language. I will check it out now 🙂

    • @lindblomdev
      @lindblomdev  2 года назад

      Yeah I think many people dismiss it for that reason 🙃 the language designer is the same guy that made LLVM if I remember correctly. I read the swift book that is available for free in the apple book store, it was a pretty dry read, unlike the rust book. But the language seems very nice.

    • @hinach4n698
      @hinach4n698 2 года назад

      There already are such types in rust. Hashmap, Vec and String.

    • @DavidAlsh
      @DavidAlsh 2 года назад

      @@hinach4n698 I totally get what you're saying, my thoughts are just that it would be nice for a _slightly_ higher level Rust that has opinionated data types to make it more practical for the development of web servers where we are just trying to parse some JSON and send it on it's way.
      eg
      let foo: string[] = []
      Is easier to understand than
      let mut foo: Vec = vec![];
      Especially when you consider "String" and "string" are different, "array" and "Vector" are different and just try passing a function as an argument.
      I'm not saying the granularity of Rust's datatypes are bad - they are great, especially when dealing with systems level development - but can be a hindrance when writing a web server or a front end with WASM

  • @eddie2378
    @eddie2378 2 года назад +2

    My biggest concern is the compile time. If it compiles instantly, I'm pretty much sold.

    • @lindblomdev
      @lindblomdev  2 года назад

      Yeah that can be a problem indeed. So far I havent had any issues with this locally. Fast machine and cached builds. Clean production build in the free tier of Google cloud build on the other hand is horrible. About 30 minutes for small web api 🤨

  • @krfloll
    @krfloll 2 года назад +4

    Rust has changed a lot in the past few years. Imo the language was much harder to learn 2 or 3 years ago

    • @lindblomdev
      @lindblomdev  2 года назад +1

      I've heard that from others too. I looked at it when async/await was still not stabilized and I slowly backed away, as I see a stable async solution needs to be in place for something to be viable for web solutions, but the rest of the language was already pretty much as it is now so I missed the hard times your got to experience. And I do belive it will get even "easier" as they are working on the ergonomics.

    • @krfloll
      @krfloll 2 года назад +1

      @@lindblomdev they replaced a lot of symbols with keywords as well. The list goes on from there. It's always been a good language but it's starting to become a great one

  • @EduardO-gm7hx
    @EduardO-gm7hx 2 года назад +8

    Rust is a systems engineering language comparable to c++. Rust is great when you need to be close to the metal and do some performance critical tasks (see how discord uses it), but as a web developer you will rarely need it.

    • @recklessroges
      @recklessroges 2 года назад +2

      Think of Rust as a sports car - you can drive it at jaw-dropping speeds, but you can also just use it to drive to the shops. (Though I do agree that if I were just doing front-end I'd probably stick with Elm or MithrilJS .)

    • @lindblomdev
      @lindblomdev  2 года назад +11

      I hear what you are saying. I would not let the "systems engineering language" scare you away. If you take a web framework like poem or rocket, they are not much harder to learn than any other web framework in other languages. So why not do it in a "systems engineering language" where you will get better performance and memory utilization, while also being safer which will result in less bugs in production?
      Nice that you brought up the discord article. If i remember it correctly, the switched out go for rust to get rid of tail latency, and the way they used go/rust was to integrate it with their Elixir solution via FFI. That is another reason (as you said) why its good to have rust in your back pocket. Since rust can spit out a c style library, and almost every language can integrate with c style libraries, this means that you can build performance critical parts of you app in Rust without switching the whole project over.
      One thing with rust that i have recognized, is that even though it is a low level language, it doesn't feel like it when you get used to it. The number of lines in my rust program is probably comparable with the same program written in node or c#.

    • @uziboozy4540
      @uziboozy4540 2 года назад +6

      Frontend - Yew
      Games - Amethyst
      GraphQL - Juniper
      Web server - Hyper
      It's not a systems language only.
      It's used for everything due to its extremely highly optimized compiler that produce no runtime errors, because well, there is no runtime when using Rust.

    • @EduardO-gm7hx
      @EduardO-gm7hx 2 года назад +4

      @@uziboozy4540 it's not optimized for web development. You're gonna spend an order of magnitude more time writing a web application in rust than you would in an established/mature web framework from one of the popular backend languages such as Javascript, Python, Java, C#, Elixir, Ruby.
      Your comment about it not being just a systems language I can say the same about pretty much any other comparable language such as C, and C++. You could in theory write a backend purely in C++ but it would take you significantly longer to accomplish the most basic of tasks. Just because you can do something in language X doesn't mean you should. You can do pretty much anything with any turing complete programming language if you have enough time.
      Think of programming languages as tools which are meant to be applied to problem domains for which they are optimized. Stop looking for a silver bullet because it doesn't exist.

    • @lindblomdev
      @lindblomdev  2 года назад +1

      @Eduard O Im not saying that you are wrong, but i am intrigued by your answer here. An order of magnitude is a very big difference. Sure, if you come to it completely green, but once you have learned it, made Rust your native tongue. Then i think its about the same amount of time as with the others you mentioned.
      Short self study: Even at my novice level of rust knowledge i hammered out a web back-end fairly quickly. Im currently building a side project, where i record what i do and will release it when its edited down so people doesn't have to watch me reading documentation. Something I get while doing this, is a very good sense of how long things take, since i record everything, i just need to look at the length of the videos. And so far I'm a bit slower, but not an order of magnitude slower than c#/js. Remember that I am a novice rust developer and I conciser myself a very good developer both when it comes to C# and JavaScript. Therefore i believe that the gap between my old languages and rust will narrow, the more time i spend in rust, maybe even vanish.

  • @bjugdbjk
    @bjugdbjk 2 года назад

    Wow ..I moved from Mobile dev to Rust !! NO regrets at all :0 just love to be Rustacian !!

  • @key7644
    @key7644 2 года назад +1

    do it with GO ( Golang ) :)

    • @lindblomdev
      @lindblomdev  2 года назад +1

      Do a mini comparison like the one I did with C#/asp.net? That's a good idea.

  • @user-df1gs1kf8w
    @user-df1gs1kf8w 2 года назад

    I will never understand why some people use commas instead of dots for decimals. Unless I'm mistaken I think the US does this too, although as a Canadian who have crossed the border from time to time, I have yet to encounter this...

    • @lindblomdev
      @lindblomdev  2 года назад +1

      😆 I'm sorry for the Swedish locale. We got dates and the metric system, but I agree that we totally missed the boat on the use of comma as a decimal separator. I also prefer the dot. Yeah I think they use comma as thousands separator in US, which I also don't really like 😅 there I prefer spaces or rust style_ 😎👌

  • @Valeriooooh
    @Valeriooooh 2 года назад +1

    Hi I think you said that rust with release is faster than higher leve languages (ex: JavaScript, python...) but you wanted to say that it was faster than lower level languages (C,C++...)

    • @lindblomdev
      @lindblomdev  2 года назад +1

      I would love to say that, but I don't think that would have been true. Some teams experience leaner and faster code bases after a rust rewrite from c or c++, the reason for this is probably the state of the original code, not that Rust is faster than the former, it's easier to write faster correct code in rust. What I wanted to communicate was that a web server written in rust compiled in release mode is usually faster than the same server written in languages you usually write web servers in (js, ruby, python, Java, c#, etc.). Even if you are new to rust and do more cloning than is actually needed (because it's simpler). It's also my opinion that the resulting rust code reads just as well, thanks to great library authors and language team. I'm sorry for not being clearer the first time around, I'm working on my communication skillz 😅

    • @ekremdincel1505
      @ekremdincel1505 2 года назад

      @@lindblomdev The current fastest backend framework of the world, Actix, is written in Rust. You can find benchmarks where Rust performs mostly same with C and C++. You can pretty much say it is usually on par with low level languages if we are talking about the performance. And Rust have more potential for performance nevause there is lots of unimplemented-yet optimization ideas.

  • @lordmagegamer4623
    @lordmagegamer4623 2 года назад +1

    Hi, I have about 15+yrs exp in Java/j2ee applications development. So, wondering is Rust worth switching to as I keep hearing that Rust is the language for the future. If yes, what would be a good way to transition from a java backend dev to Rust developer?

    • @lindblomdev
      @lindblomdev  2 года назад +3

      I have a similar amount of developer experience. I believe that you are more than JUST a java/j2ee developer. Much of the stuff you have picked up applies on other platforms too. Likewise, the things you would learn on a rust journey could make you a better Java developer. I'm developing smaller projects at work in rust and build my side projects in rust, that's how I work on my rust experience, maybe you can do the same?
      Just don't spend too much time contemplating if you should or should not, just do it, learn a little bit. If you find you don't like it, just stop doing it 🙃 thinking too much about if or if not, will just leave you stuck in between, not moving anywhere, that's the worst. Because then the time you didn't want to waste on rust, got wasted on nothing. Glhf! 😁

  • @shalashtein
    @shalashtein 2 года назад +2

    Can you do another one that compares Rust to Ruby 3

    • @lindblomdev
      @lindblomdev  2 года назад +4

      I love that idea, thank you. I haven't been doing ruby for a long time, so it would be a fun and nostalgic video for me to make 😃👍

    • @Stoney-g1o
      @Stoney-g1o 2 года назад +1

      He should include a compiled crystal-Lang esult as well. Crystal-Lang is mostly compatible with ruby

    • @lindblomdev
      @lindblomdev  2 года назад +1

      Sure why not 😊👍

  • @mitotv6376
    @mitotv6376 2 года назад

    Nice

  • @hjarnspik
    @hjarnspik 2 года назад

    In rust we trust

  • @JensQNilsson
    @JensQNilsson 2 года назад

    Hi, I was looking for the PoC you talked about. Its not on your GitHub. Could you maybe upload it?

    • @lindblomdev
      @lindblomdev  2 года назад

      Hey! No it was for work, and I'm not sure I still have it. Basically I just taped together warp, mongodb, juniper and a jwt lib. The code was not very impressive 😅 is it something perticular you are interested in there?

  • @yamiteru4376
    @yamiteru4376 2 года назад

    I like sheeper products 👌

  • @hargunbeersingh8918
    @hargunbeersingh8918 2 года назад

    I have been gaining expertise over js and node, should i leave that and start learning rust? Btw i am a backend dev

    • @lindblomdev
      @lindblomdev  2 года назад +2

      No I don't think that is wise. You don't say it, but i will assume that you're pretty new to programming, and therefore its better to stick with what you are doing instead of jumping on to the next shiny thing. Jumping around will result in you not learning anything fully. JavaScript and node is broadly used and great tools to have in your toolbox.
      And once you have mastered js, then rust will probably be easier to learn as the language and tools have progressed, if you feel like learning it.

    • @hargunbeersingh8918
      @hargunbeersingh8918 2 года назад +1

      @@lindblomdev Thanks for the advice :D

  • @Supermath101
    @Supermath101 2 года назад

    Judging by the video title, I thought you were going to talk about the front-end part, instead you specifically were talking about back-end web development using Rust. 🙃

    • @lindblomdev
      @lindblomdev  2 года назад

      Haha 🙈 yes that is correct. While I do think we can be better at leveraging more threads in our web apps, I don't think we have much to gain by moving away from ts/js in the browser for most apps.

  • @psesh362
    @psesh362 2 года назад

    Hi, Christopher. Just started learning HTML/C++ to get the basics of web dev. Should I move onto rust right after I finish up with the building blocks of HTML/C++?

    • @lindblomdev
      @lindblomdev  2 года назад +2

      First i would like to say that HTML/C++ is a very interesting choice for web development. Maybe you mean c#? If you are actually doing c++ for web, and do not have any special reason for doing so, i would suggest that you switch to something else, C# is a great option. Another option would be nodejs, since its javascript on the server and you will get in contact with javascript sooner rather than later in your web dev journey.
      Should you move onto Rust? I think its better that you master web development in something else before concidering moving to Rust. Rust makes you have to think more about things that other programming languages takes care for you, therefore it will probably increase the likelihood that you give up, which we dont wont.
      Then after some time and XP has been collected, you can take a look at Rust and see if its something that you would like. I think it will be easier to program Rust at that time too.

  • @siyaram2855
    @siyaram2855 2 года назад

    Rust will dominate future for sure, but not in web development. It will take applications of system programming, Go lang will take over the backend.

    • @lindblomdev
      @lindblomdev  2 года назад

      It's interesting that you think so. After I initially dipped my toes in rust, I was discouraged. It felt like I was about to use the wrong tool for the job. I then read the docs for go. While doing that I couldn't see any benefit over continuing to use C#, so I went back 100% into C#. After a while Rust came creeping again. I then realized that the only benefit C#/Go has over Rust is the initial learning curve is lower. Thats when I decided that it's better to pay the price now and learn rust to have the edge going forward.
      With that said. I agree with you that rust will remain with a smaller piece of the web dev cake. Not because it's not better in most ways, but it's harder to learn and it's a numbers game.

    • @siyaram2855
      @siyaram2855 2 года назад

      @@lindblomdev In the end popularity of a language is determined by the adoption rate, companies adopted node.js not because it was the best thing but because it reduced the labour cost, I see people shifting from node to Go lang easily, The next trend and data suggest Go will dominate the backend dev.(it has types and performance )
      Rust, as I feel will always be used to write the low level stuff by bigger companies, AWS wrote a whole lot of stuff in Rust which brought down their electricity consumption, in that way rust will be a gamechanger.

  • @guidyouguy7306
    @guidyouguy7306 2 года назад

    Why not move to binary

  • @rafaelcisnerosgomez7295
    @rafaelcisnerosgomez7295 2 года назад +1

    This thing empowers solana… so yeah I’ll give it a try.

  • @lucastavares206
    @lucastavares206 2 года назад

    Im too dumb to learn rust by myself. Couldnt find great tutorials online yet

    • @lindblomdev
      @lindblomdev  2 года назад +6

      Maybe you are trying to eat the whole cake in one go, try to break it down in pieces and start with the basics.
      Here are some to get you going:
      let vs let mut
      String vs &str
      borrowed vs owned
      option/result types + unwrap
      functions
      structs
      enums
      match
      From that list, take one. Focus on learning that, then be done for the session and wait until the next day to do the next (if you still remember the first one, otherwise do the first one again).
      The list is just a starter list to get you going. If the order is bad for you, move things around. When you find new things in the rust langage that you dont know, put them on the list, then go back to what you are currently learning. Unless, that new thing is blocking you, then you will of course have to tackle it instead of what you are currently learning.
      Happy learning!