i'm writing my current SaaS project with rust completely, because it's fast, it consumes very low memory, when the code compiles that means your code will work %99 of the cases except database actions, and error messages so well explained and explicit. Because of that rust is the best choice for me, i'm already scaled my project with only writing it with rust and i'll be able to deploy it so easily.
@@voidwalker7774, is this better than what he said he's using [tokio-postgres and deadpool-postgres]? Or is it only better if you're using tokio, because then they already _match_ ? I mean, at least from a *DB System* PoV, Postgres SQL > MySQL🤔 Thanks.
@@theintjengineer SQLX, gives pooling and a unified frontend for MariaDB, Postgres and SQLite. You write Raw SQL. And you have the option to check your SQL at compiletime against the DB you selected. Just look at the crate :)
@himanshusharma6713 firstly, i don't use rust for small scale projects unless i don't need best performance, for basic things node.js has good performance. I choose rust because i do some cpu and memory intensive things. Second, when your code compiles that means your code is debugged, that means you don't need debugging. Updating could be hard but everything comes with costs. Rust is relatively new language and most of the tools are not hit to the 1.0, even most of my dependencies are like that, i still use it because i trust the maturity of the ecosystem, but most of the companies not. Because of that companies don't want to take that risk. It was also like that for C++, in 2000's still most of the cpu and memory intensive things was done with C, because C++ don't evaluated as mature enough to write that kinda things, so also rust faces that problem. And for other languages that you wrote i could say that things: C# - C# is an outdated language by most of the ways. Even most of the C# developers don't use newest .net and c# versions, and it's only slightly faster than modern php(even .net fanatics don't admit it), and far more memory consuming. It was semi successfull substituon of java in it's prime times but it's completely unsuccessfull in this time. But .net somehow achieve to be de facto official computer science education language, so every computer or software science student learning it, because of that it's achieved to live for 10 years. And because of that they become very comfortable that language they don't try new language for serious things. Go - Go is very fast and less memory consuming and also easy to write language. If i wouldn't decide to write my whole system with rust i definitely choose go with no doubt. Although i still could be able to deploy go apps, rust's "if its compiles it will work!" rule seduces and encourages me to do that choice, also go has more latency than rust, which in high traffic circumstances makes it significantly slower than rust. Mern Stack - The actual most hyped thing is react i suppose. It has most silly, most idiotish rules, one of them is: "you can not call a hook conditionally". This is most dumb thing, because in programming doing something conditionally is trivial. Because of that state changing and page changing without sending new http request is charming people. If they don't need good performance or they don't care about performance and they started coding by front-end development, people choose the go with that. And for your last opinions: I hate C# most, because the slowest and high memory consuming softwares which i used built with it and most of the slowness of our internet is because of firstly php, later c#. Also it's a product of windows, which is the probably most dangerous and harmful company in whole software world, it's always a reason of avoidance for me if a software built by microsoft, because of that i also hate typescript. I could understand why you're hate rust, because it's synthax is very hard to get familiar but with the help of ai you could write and debug rust codes easy if you're not a newbie developer. For me, Javascript, Go And Rust is ultimate stack for everything and if there is rust i don't think i use go for anything.
I am working on a Vue compiler in Rust as a side project, so far it's been a great journey. I would hope that when it's production ready, more tools from the Vue ecosystem would switch to the "native side".
This was good, mate. Good job, really good job I really enjoyed watching it and learnt a lot. Hard to find video that respect people time like this one
This video is amazing, superb job. And yay, that WASM future I hoped for a few years ago where you can use WASM in your JS and not even notice is here!
Before now, if you wanted C-like speed then you had to write in C or C++. Now you can write at a high level of abstraction with friendly syntax and still get all the performance benefits of a low-level compiled language. Why not do an easy re-write and get a 30x+ speed boost? It's a no-brainer.
I rewrote my nodejs bot (vibegraph) to rust and it is 4x easier to read, more performant, and less prone to weird bugs. that is why rust is what typescript WISHES it could be
@himanshusharma6713 Company immediately rushed to PHP, Ruby, OCaml, Java and C# back in the early days. Companies won't bother to migrate Legacy software either. Companies are stupid.
Now use it on a project where 2500+ devs are using it. Rust is what hobbyists WISHES web development is like and will always be an everchanging "toy". Typescript solves REAL problems NOW.
@@ZephrymWOW It is (in my opinion) unfathomable to think that 2500+ devs could manage type-consistency on a project in a language that is not strongly typed (meaning a first-class type system, with no Any-types) In my experience, as a project grows, (correct) types become increasingly more important.
Been wanting to like Rust for years now. I thought after some time to mature I'd come back and find it pleasant as I did with Go. But I come back and it keeps managing to piss me off. Maybe I need to go and look at some services written in Rust to see if I'm overcomplicating things.
Blazingly fast is great when it's blazingly fast. Too many projects feel slow and bloated. Some blazingly fast here and there, and over there too, is a welcome change.
I came from a Python background then added JavaScript because everything on the web has JavaScript in it recently i started learning Rust and am glad i did, i started learning Rust because of Solana Blockchain and coming now seeing that i can do more outside Solana too . Am glad i took this part
This is true, however the const keyword is not a variable declaration. Its important to know that const refers to creating an item that is evaluated at compile time, and its usage in the compiler is such that the computer value will be inlined wherever it is used. Its like a compile-time find-and-replace for the name of the const using the computed value. Similarly the static keyword exists which is closer to a variable, but IMO mentioning either of these isn't really what people think of when they think of every day use variables. Rust heavily discourages the use of global state and accessing static mut items requires unsafe Rust which I consider out of scope for this introductory level video.
Not really a JS developer - I spend my days coding in Go lately - but still watched this anyway. I gotta say, the second half explained things to me I have previously never had anyone explain and now I feel like I better understand how at least some of Rust's unique features work. So thanks for that! One thing that was unclear to me about the first half though is the embedding of Rust in JS. Are you saying that you can embed Rust in JS in the *browser*, or is Rust embedding really just a server-side NodeJS thing?
Glad you found it useful! You can embed Rust in the browser or in node. In the browser this is going to be by using wasm, which can be interacted with directly by javascript, and in node this can be either through the native extensions (napi) or through wasm, both work.
@@chrisbiscardi - Thanks for the quick response. When I was asking about embedding in the browser I was asking specifically about native since you made it clear the distinction between native and Wasm, and it was clear that generating Wasm was a strong feature of Rust, which obviously works in the browser. So for clarity on this point my takeaway is that “No, you cannot embed Rust natively in the browser, but you can embed it natively on the server with Node” which I post in case someone else has the same question in the future.
45:00 - I'm fairly new to rust but a decade in the industry. i got myself a somewhat working view on how to work with ownership model. However, you explanation with the dog was so good, it really just clicked now. really good setup there. thanks for your work. man i really have to use rust more.
I wager that it’s a mix between hype and the 3x speedup you can get (according to the debian benchmarksgame) when you go from JS to Rust. Re-using tooling from FF is naturally also free code …
You sound levels are not consistent between videos (I came from the rewriting in rust video which was much louder). Consider adding a step to your process where you check or nomalize your levels. Thanks for documenting these technically items.
Programming languages are a popularity contest. Now is Rust and maybe in the near future will be Zig or other. Rust is not "stable" enough for me in terms is leadership, etc. Things may go wrong very quickly. I want stability, but people continue obsessed with the promise of performance in same cases and just popularity in other cases, such as Python and JavaScript. It's always the same, for decades.
One thing I would like to add is that for the same reasons that rust works well with rust-analyzer (strong typing, no syntactic flutter), it also works very well with code generating AIs. It is quite pleasing to have an AI generate an entire function for you that is just the way you wanted it to be.
@@workflowinmind depends on the AI, copilot works amazing especially with workspace access while chatgpt just barely scrapes by I literally typed "i" once and copilot made nearly a perfect generation of the if statement i wanted and only thing i needed to change was a integer it used.
If just all these projects could agree on developing ONE packager, bundler, … it seems that every two days somebody creates a new one. It is such a waste of energy and fragments the ecosystem. These fragmentation makes web development a nightmare. Gulp, Grunt, Webpack, Vite, Parcel, Rollup, … and now all these other newcomers. I am all-in for choice, but this is just crazy.
I was wondering if I maybe should move away from Rust because of the bad news/decisions about the organization. Could they possibly change Rust in a bad way and push people away from it?
why would that matter? only twitter people care about that stuff. rust has trade-offs good and bad and that's really all that matters to people who aren't weirdos
I don't know which news you're referring to specifically but speaking generally: IMO you won't get away from having people in charge of the development of a language anywhere you end up. Whether its a BDFL or a foundation or a spec group or implementors (browsers, compilers, runtimes) or something else, there's always someone at the end of the day that can make decisions you don't agree with. Rust is a great language but it is also not the last language and its problems are not unique
My favorite error message ever is from LISP: UNHAPPY MAKNAM ERROR. It happened when an attempt to make a new symbol or name failed for some reason, usually because you ran out of naming space. It also made an appearance in a Firesign Theatre sketch titled "Don't Crush That Dwarf, Hand Me My Pliers," when an amusement park attendee intentionally breaks the animatronic President.
Recently, JavaScript has been receiving a lot of optimisation. However, I agree that it's a poor language from a software engineering perspective. The issue with Rust is that it's too new and thus lacks the libraries available in C and C++. If I ever wanted to learn a new language, it would likely be Golang; for now, I'll stick with my projects in C++, Python, and JavaScript.
@@ITSecNEO Hi, I hadn't replied because I actually have a life. Today, the first of January, I've got some time to procrastinate, so let me give you an answer. First of all, programming languages aren't a religion. They are just tools, like a hammer. Falling in love with a programming language is like falling in love with a hammer. Now, my comment was a bit taken out of context. I am not saying that Rust is wrong. I am just stating a fact: it lacks the overwhelming amount of libraries that you would find in C and C++ ecosystems, and I know that some Rust lovers might struggle to admit that fact. I am also aware that Rust can somehow import 'extern' C/C++ code. Actually, there is nothing innovative with that approach. Almost every programming language that I know can do the same thing and probably in better ways. Java with the Java Native Interface (JNI), Python with PyBind11/Shiboken/SIP/Boost::Python, JavaScript with Node native modules, and so on. The list also includes those languages that are self-proclaimed C++ killers but have miserably failed to replace C or C++ in the same way Dart failed to replace JavaScript. The problem with Rust integrating with other languages like C++ is that the two programming languages are fundamentally incompatible. I am not a Rust expert, but just to give you an example, many GUI libraries generally rely on OOP patterns such as inheritance, which allows extending functionalities in a more streamlined way. However, Rust doesn't even support inheritance, which closes the door to many design patterns that heavily rely on that OOP feature. Yes, I know there are traits in Rust, but they are not the same, and achieving the same flexibility might be more painful. Yes, I know composition is generally better than inheritance, but that is a different conversation. In fact, I am not saying that C++ is better than Rust as a programming language. It is very likely that Rust is better in many aspects, just as Dart is better than JavaScript. However, that is a different conversation. My point is that replacing a programming language such as C and C++ by using an incompatible programming language imposes too many challenges that could make it just another failure in that respect. There is a lot of code written in C and C++ that cannot be easily replaced by an incompatible programming language, no matter how good or better it is supposed to be. The industry has infallibly proven that that approach is more likely to fail. Instead, I see other approaches more likely to succeed in replacing C++. We can see examples of this in the industry. For example, TypeScript is a very good example of how you can migrate code from JavaScript to another programming language while maintaining compatibility. You just change the extension of a file from .js to .ts, and you start seeing results right away. This is also why C++ is a very successful language in terms of adoption. Because it was compatible with C right away, you just compile a C program with a C++ compiler, and you start seeing progress in code migration. I believe more in those approaches. This means that languages such as Carbon and CPP2 might have better chances to succeed than Rust if the first production-ready version of those languages gets released. However, it has been about 12 years since we first heard of Rust, and in 2024, it is still more like a niche programming language, and honestly, it hasn't yet replaced C and C++. In any case, I will be open to migrating code to Rust if I ever see that it offers as much or more than the C and C++ ecosystems offer today. More importantly, however, I will consider migration if I can achieve transparent integration of my code without having to contend with the pitfalls associated with the 'extern-function approach'. Regarding Golang, I like that it has a lot of support for cloud services while being relatively easy to learn and use in concurrency contexts. It also provides a descent performance. However, I will not give it a chance unless I have a compelling reason to use it. In the end, it is just another tool.
JS is also slow due to how it uses memory, not only that it uses a GC it allocates lots of tiny objects all the time instead of having structs or larger entities it can always collect as a complete unit. Programs with lots of allocations are in my experience from debugging and profiling them a lot in production horribly inefficient in how they use memory with large number of objects. It also doesn't help that the still prevailing trend of JS projects using hundreds or some times even thousands of npm dependencies which bloats the whole build and run process a lot.
The answer is mostly social/funding IMO. You could totally build tsc and the typechecking in another language, but what typescript "is" is defined entirely by what's in the microsoft/TypeScript repo and how that code works. So *if* you pursued this project, you would take on the burden of effectively tracking every PR into that repo in addition to building a whole second implementation of the compiler and typechecker. The TS src/ directory is conservatively estimated at 300k lines of TS (I used tokei to count). This is fundamentally a lot of work to replicate in addition to there being very valid reasons to build a language's compiler in its own language so its unlikely that the microsoft/TypeScript repo switches away from TS. This is actually where I would prefer to see the effort happen as it has the most chance of success IMO. The most common approach is to not replicate the typechecking at all and instead just try to build the compiler. This is what swc does: swc.rs/docs/migrating-from-tsc That all said, there actually *are* attempts to write a TS typechecker in Rust. At least two that I know of. enzo and stc. Enzo explicitly declares that they aren't chasing 1:1 parity with TSC, while I *believe* stc is still trying to, but stc is very early in its lifecycle. Enzo is also mentioned as being part of oxc, which is the tooling vite/rolldown are going to use. * enzo: github.com/kaleidawave/ezno * stc: github.com/dudykr/stc * github.com/web-infra-dev/oxc * oxc/ezno: github.com/web-infra-dev/oxc#-ezno-type-checker
Рік тому
@@chrisbiscardi I get it.. But lets take esbuild - (as I understand) they are just trimming typscript out, leaving plain JS. And if you want typechecking - well - they say - check yourself.. This just feels like a hot patch, which on the surface works fast, but actually doesn't do what I would want it to do, and doesn't entirely resolve the issue. I might be wrong.
"You can do nothing in any language" is true only up to a point. Lots of languages don't adhere to the idea of zero-cost abstractions so you're stuck choosing between ergonomics and efficiency. E.g. Every user-defined type in Java is a pointer to an object on the heap, which makes it impossible to have zero-cost newtypes in general, and especially numeric newtypes.
I would love to use rust, but as mobile dev it lacks easy setup even to configure it as bindings. as for web, I'd love to see something like Rails for Ruby but for Rust
What do you think about the existing web frameworks? I only used actix-web for a single endpoint hello world server with custom error handler yesterday. Yes, rails is simpler, but I can't judge it just from that tiny experiment.
@@bloody_albatross I checked actix-web, rocket and looked a little bit at axum - they are very similar to each other but they're more like micro frameworks - think express for javascript or flask for python. In my opinion, rust should have something like rails or laravel - generator for project, sqlx configured out of the box, cli program to generate scaffolding, configuration in place for web templates, api + plugins for authorization. In that way you can startup your project in few seconds when currently you spend whole evening just to configure project structure and connection to database.
@@climatechangedoesntbargain9140you mean uniffi ? Yes it does exist. Still I cannot say it's easy to set up a new project with it. Compare it to something like creating a project with react native or flutter or even creating native project
CLI Rust tools make sense, but big fat no to Prisma. I'm not willing to take the cold-boot time hit on serverless. Multi-second cold-boot times are a deal-breaker. Honestly, I'm looking at making a monolith. Today with the new hyper-fast CPUs, it makes more sense for you to target a 128-core server with 2TB RAM and some nVidia H100 GPUs. You should probably just use a dyndns at first and server your website from home until you hit 1000 active month users. Chances are you'll never max it out, but if you do then you can just scale by doubling and you probably will save 4-10 $million. C++ for the win!
Rust is not the cause of Prisma's effect on cold boot times. Rust boot times in serverless environments are some of the lowest I've seen for any language.
It's true that you can write performant code in any language or dogshit code in any language. But it is also true that the language pushes you in one direction or another via the path of least resistance. For example, JS tends to result in code that creates lots of garbage which can be a performance issue on memory constrained devices. Not creating garbage in JS is hard to do, you have to fight against the language to do that.
We should not misunderstood that Rust used for tools which general developers use to create web apps in JavaScript. Rust is very difficult language. People cannot write good code even in JavaScript which more easier to grasp.
Why are you so reluctant to say Rust is fast? The same algorithm implemented runs much faster when written in rust and compiled than written in javascript and interpreted, right?
The first thing I would say is that JavaScript is also compiled these days. Chrome, for example, has a multi-stage compiler process including an optimizing compiler for turning JavaScript into machine code (ex TurboFan: v8.dev/docs/turbofan). Yes, Rust has a strong focus on being able to achieve performance using various knobs. The focus on zero-cost abstractions helps a lot here to be able to use high-level language constructs without paying a runtime cost. But at the end of the day there is more to performance than "use X language". IMO unless you're benchmarking your use case any statement along the lines of "X is faster than Y" is mostly theoretical, and applying that at the language level is even more fraught. For example, even if Rust is faster for a given algorithm as you suggested, is the overhead expended calling it across the FFI boundary worth it?
@@chrisbiscardi I wasn't thinking about using Rust to develop web front-ends, but libraries and CLI tools, where there is no overhead to crossing the boundary. That being said, I really wish we'd get rid of JS' monopoly on the FE. If only wasm didn't seem opposed to the idea.
I would be really happy if we slowly transitioned to rust for general web development. I've always wanted to get more experience with a low level language, but can never really afford the time to since all of my work pertains to javascript/typescript tooling
Um, I didn't go look if Vite has made any statements about it but I'd assume Vite comes from French (fast, quick) and then his pronunciation is in the ballpark.
haha, unfortunately you're going to be disappointed in the next video; I'm mostly a dark mode user 😅. I gave this video as a presentation recently in-person which I find works much better with light-mode themes, which is why everything here is light-mode.
One correction: It's only possible to write programs that realize their full performance potential on C, C++, or Rust (and some other languages that are not popular enough to warrant a mention). Other languages are not zero-overhead.
Macros are definitely tough to write compared to everyday Rust. Luckily it seems like there was a macros working group (very) recently approved to work on this. It'll still be awhile before there's anything to show for it but it's a thing now: github.com/rust-lang/wg-macros
I also love the Rust testing framework. To such an extent that I have recreated something similar in Python to test my Py code. Was very simple as well.
If you have the time and energy to learn it, its a great language to know, but without knowing what kinds of programs you write, etc I can't make any blanket suggestions.
@@chrisbiscardi well I do frontend, currently angular, but I’ve been wanting to get more into backend and I was searching for a good language, although I know it doesn’t matter that much. I’ve hear a lot about rust, and mostly hear good things, so I might just jump into it
@@goo2581 yeah, choice of language won't matter too much when just getting started building small web APIs and such, you could use JS for that too. Rust can definitely be a great backend language to add to your toolbox. Axum in particular has a wonderful set of examples that can help as you're learning: github.com/tokio-rs/axum/tree/8854e660e9ab07404e5bb8e30b92311d3848de05/examples
@@chrisbiscardi yeah, I’ll check it out, note that I’m not new to backend, I used to work with C# and I’ll start to work again, for work-related purposes, but I want to make some personal projects with something new and better
There are some. Deno is the most well known and viable one. It still uses v8 under the hood though, just like node (bun uses JavaScriptCore). Building a competing JavaScript *engine* (like v8/jsc) is something nobody is doing afaik.
Yeah I use Deno wherever I can 'cause of its toolchain (lsp, formatter, etc) since I use helix and it is just simpler and more performant. But I actually meant I would love a javascript engine, not wrappers around v8 or javascriptcore like bun.
@brielov it's a tough project so I see why it hasn't been taken on. v8 is a million lines of code iirc and at the end of all that work you still end up with a JavaScript engine, which v8 already is. Even Servo, which I consider a wildly ambitious project, uses Rust bindings to spidermonkey for the JS engine afaik.
@@brielov There's an engine called Boa, but it's still very much new and doesn't support the entire ECMA specification yet and also lacks important performance optimizations. It might be possible to build a runtime around it once it matures though
I’m using mostly typescript & python for now, hoping to jump into more rust in the next year. Internal support at my work is growing!
i'm writing my current SaaS project with rust completely, because it's fast, it consumes very low memory, when the code compiles that means your code will work %99 of the cases except database actions, and error messages so well explained and explicit. Because of that rust is the best choice for me, i'm already scaled my project with only writing it with rust and i'll be able to deploy it so easily.
Wait you are not using SQLX, which tests your SQL statements at compile time?
@@voidwalker7774 no, i'm using tokio-postgres and deadpool-postgres packages.
@@voidwalker7774, is this better than what he said he's using [tokio-postgres and deadpool-postgres]? Or is it only better if you're using tokio, because then they already _match_ ?
I mean, at least from a *DB System* PoV, Postgres SQL > MySQL🤔
Thanks.
@@theintjengineer SQLX, gives pooling and a unified frontend for MariaDB, Postgres and SQLite. You write Raw SQL. And you have the option to check your SQL at compiletime against the DB you selected.
Just look at the crate :)
@himanshusharma6713 firstly, i don't use rust for small scale projects unless i don't need best performance, for basic things node.js has good performance. I choose rust because i do some cpu and memory intensive things. Second, when your code compiles that means your code is debugged, that means you don't need debugging. Updating could be hard but everything comes with costs. Rust is relatively new language and most of the tools are not hit to the 1.0, even most of my dependencies are like that, i still use it because i trust the maturity of the ecosystem, but most of the companies not. Because of that companies don't want to take that risk. It was also like that for C++, in 2000's still most of the cpu and memory intensive things was done with C, because C++ don't evaluated as mature enough to write that kinda things, so also rust faces that problem. And for other languages that you wrote i could say that things:
C# - C# is an outdated language by most of the ways. Even most of the C# developers don't use newest .net and c# versions, and it's only slightly faster than modern php(even .net fanatics don't admit it), and far more memory consuming. It was semi successfull substituon of java in it's prime times but it's completely unsuccessfull in this time. But .net somehow achieve to be de facto official computer science education language, so every computer or software science student learning it, because of that it's achieved to live for 10 years. And because of that they become very comfortable that language they don't try new language for serious things.
Go - Go is very fast and less memory consuming and also easy to write language. If i wouldn't decide to write my whole system with rust i definitely choose go with no doubt. Although i still could be able to deploy go apps, rust's "if its compiles it will work!" rule seduces and encourages me to do that choice, also go has more latency than rust, which in high traffic circumstances makes it significantly slower than rust.
Mern Stack - The actual most hyped thing is react i suppose. It has most silly, most idiotish rules, one of them is: "you can not call a hook conditionally". This is most dumb thing, because in programming doing something conditionally is trivial. Because of that state changing and page changing without sending new http request is charming people. If they don't need good performance or they don't care about performance and they started coding by front-end development, people choose the go with that.
And for your last opinions: I hate C# most, because the slowest and high memory consuming softwares which i used built with it and most of the slowness of our internet is because of firstly php, later c#. Also it's a product of windows, which is the probably most dangerous and harmful company in whole software world, it's always a reason of avoidance for me if a software built by microsoft, because of that i also hate typescript. I could understand why you're hate rust, because it's synthax is very hard to get familiar but with the help of ai you could write and debug rust codes easy if you're not a newbie developer. For me, Javascript, Go And Rust is ultimate stack for everything and if there is rust i don't think i use go for anything.
I am working on a Vue compiler in Rust as a side project, so far it's been a great journey.
I would hope that when it's production ready, more tools from the Vue ecosystem would switch to the "native side".
Can you advise what I need to know to also understand that I need to write my compiler for Vue
This was good, mate. Good job, really good job
I really enjoyed watching it and learnt a lot. Hard to find video that respect people time like this one
Very good "Borrowing" section and metaphor usage in it. 👍
This video is amazing, superb job.
And yay, that WASM future I hoped for a few years ago where you can use WASM in your JS and not even notice is here!
Turbopack - 1:24 - Bundler
Rspack - 2:13 - Bundler
Rspress - 2:52 -
Rolldown - 3:18 - Same as rollup
Parcel - 4:42 - Bundler
SWC - 5:56 -
OXC - 6:10 - Compiler
Lightning CSS - 6:22 - CSS
Tailwind CSS - 7:01
NX - 7:18
got bored at 7m eh?
Before now, if you wanted C-like speed then you had to write in C or C++. Now you can write at a high level of abstraction with friendly syntax and still get all the performance benefits of a low-level compiled language.
Why not do an easy re-write and get a 30x+ speed boost? It's a no-brainer.
I rewrote my nodejs bot (vibegraph) to rust and it is 4x easier to read, more performant, and less prone to weird bugs. that is why
rust is what typescript WISHES it could be
@himanshusharma6713 Rust is harder than Go. You can get results in Go from 0 to end of the week. That's why companies adopted it so quickly.
@himanshusharma6713 Company immediately rushed to PHP, Ruby, OCaml, Java and C# back in the early days. Companies won't bother to migrate Legacy software either. Companies are stupid.
Rust is what cpp wants to be not just typescript 😉
Now use it on a project where 2500+ devs are using it. Rust is what hobbyists WISHES web development is like and will always be an everchanging "toy". Typescript solves REAL problems NOW.
@@ZephrymWOW It is (in my opinion) unfathomable to think that 2500+ devs could manage type-consistency on a project in a language that is not strongly typed (meaning a first-class type system, with no Any-types)
In my experience, as a project grows, (correct) types become increasingly more important.
Been wanting to like Rust for years now. I thought after some time to mature I'd come back and find it pleasant as I did with Go. But I come back and it keeps managing to piss me off. Maybe I need to go and look at some services written in Rust to see if I'm overcomplicating things.
if by pleasant you mean simplicity then you are wasting your time looking into rust.
Just like how Python libraries are in C++.
and just like php extensions are written in C
Just like markdown is written in html
That depends on the library. "Python" libs can also be written in C or Rust.
@@MrRaitiz There's "ext-php-rs", which lets you build PHP extensions in Rust.
@@Gramini Yes. Can also be written in assembly.
90% of the projects are using Webpack its very hard to migrate and no one want to use an other bundler specially in the entreprise env
Blazingly fast is great when it's blazingly fast. Too many projects feel slow and bloated. Some blazingly fast here and there, and over there too, is a welcome change.
This is brillant content. I'm TS dev starting with Rust. I really really enjoyed it. Thanks! 👍
Blazing fast and Rust go hand to hand, I like the meme and should continue
I came from a Python background then added JavaScript because everything on the web has JavaScript in it recently i started learning Rust and am glad i did, i started learning Rust because of Solana Blockchain and coming now seeing that i can do more outside Solana too . Am glad i took this part
same here i didnt expect i would like rust untill i tried it
in 31:12 actually in rust const keyword exist, which you can use it for defining a variable outside to the any function(including main function).
Keep in mind though that such constant has to be constant at compile time. You cannot ask for user input and store than in a const or something.
This is true, however the const keyword is not a variable declaration. Its important to know that const refers to creating an item that is evaluated at compile time, and its usage in the compiler is such that the computer value will be inlined wherever it is used. Its like a compile-time find-and-replace for the name of the const using the computed value.
Similarly the static keyword exists which is closer to a variable, but IMO mentioning either of these isn't really what people think of when they think of every day use variables. Rust heavily discourages the use of global state and accessing static mut items requires unsafe Rust which I consider out of scope for this introductory level video.
Great breakdown and summary of common Rust concept in the master half of the video. I will have to revisit this section a few times
superb video! 🙂🦀 very insightful!
Glad you enjoyed it!
the reason I personally did not stay on js was limitations and speed, its been 7 years though
Not really a JS developer - I spend my days coding in Go lately - but still watched this anyway. I gotta say, the second half explained things to me I have previously never had anyone explain and now I feel like I better understand how at least some of Rust's unique features work. So thanks for that!
One thing that was unclear to me about the first half though is the embedding of Rust in JS. Are you saying that you can embed Rust in JS in the *browser*, or is Rust embedding really just a server-side NodeJS thing?
Glad you found it useful!
You can embed Rust in the browser or in node. In the browser this is going to be by using wasm, which can be interacted with directly by javascript, and in node this can be either through the native extensions (napi) or through wasm, both work.
@@chrisbiscardi - Thanks for the quick response.
When I was asking about embedding in the browser I was asking specifically about native since you made it clear the distinction between native and Wasm, and it was clear that generating Wasm was a strong feature of Rust, which obviously works in the browser.
So for clarity on this point my takeaway is that “No, you cannot embed Rust natively in the browser, but you can embed it natively on the server with Node” which I post in case someone else has the same question in the future.
45:00 - I'm fairly new to rust but a decade in the industry. i got myself a somewhat working view on how to work with ownership model.
However, you explanation with the dog was so good, it really just clicked now.
really good setup there. thanks for your work. man i really have to use rust more.
That is true, and i take screenshoot at that part
I wager that it’s a mix between hype and the 3x speedup you can get (according to the debian benchmarksgame) when you go from JS to Rust. Re-using tooling from FF is naturally also free code …
I feel so old and slow... now again learning something new?? Or better changing to project management ...
You sound levels are not consistent between videos (I came from the rewriting in rust video which was much louder). Consider adding a step to your process where you check or nomalize your levels. Thanks for documenting these technically items.
heck good video bro. You do a great job of providing high level detail so a beginner developer can understand.
Programming languages are a popularity contest. Now is Rust and maybe in the near future will be Zig or other. Rust is not "stable" enough for me in terms is leadership, etc. Things may go wrong very quickly. I want stability, but people continue obsessed with the promise of performance in same cases and just popularity in other cases, such as Python and JavaScript. It's always the same, for decades.
Not stable enough in what sense?
One thing I would like to add is that for the same reasons that rust works well with rust-analyzer (strong typing, no syntactic flutter), it also works very well with code generating AIs. It is quite pleasing to have an AI generate an entire function for you that is just the way you wanted it to be.
Not my experience, it's good for completion but makes tons of subtle mistakes otherwise in a Rust context
@@workflowinmind depends on the AI, copilot works amazing especially with workspace access while chatgpt just barely scrapes by
I literally typed "i" once and copilot made nearly a perfect generation of the if statement i wanted and only thing i needed to change was a integer it used.
Always nice to see a fellow Nushell user =)
I'm in half migrating my Fastify backend to rust. So far so good. Happy with the results and more faster
If just all these projects could agree on developing ONE packager, bundler, … it seems that every two days somebody creates a new one. It is such a waste of energy and fragments the ecosystem. These fragmentation makes web development a nightmare. Gulp, Grunt, Webpack, Vite, Parcel, Rollup, … and now all these other newcomers. I am all-in for choice, but this is just crazy.
Dont believe with next turbo, its unstable, i oftenly got my app crash in dev mode. And not compatible with all library
I was wondering if I maybe should move away from Rust because of the bad news/decisions about the organization. Could they possibly change Rust in a bad way and push people away from it?
why would that matter? only twitter people care about that stuff. rust has trade-offs good and bad and that's really all that matters to people who aren't weirdos
I don't know which news you're referring to specifically but speaking generally: IMO you won't get away from having people in charge of the development of a language anywhere you end up. Whether its a BDFL or a foundation or a spec group or implementors (browsers, compilers, runtimes) or something else, there's always someone at the end of the day that can make decisions you don't agree with.
Rust is a great language but it is also not the last language and its problems are not unique
My favorite error message ever is from LISP: UNHAPPY MAKNAM ERROR.
It happened when an attempt to make a new symbol or name failed for some reason, usually because you ran out of naming space.
It also made an appearance in a Firesign Theatre sketch titled "Don't Crush That Dwarf, Hand Me My Pliers," when an amusement park attendee intentionally breaks the animatronic President.
Really awesome content!!
Recently, JavaScript has been receiving a lot of optimisation. However, I agree that it's a poor language from a software engineering perspective. The issue with Rust is that it's too new and thus lacks the libraries available in C and C++. If I ever wanted to learn a new language, it would likely be Golang; for now, I'll stick with my projects in C++, Python, and JavaScript.
you know you can import the libs from c++
Can you explain how it’s a poor language from software engineering perspective?
Go doesn’t even have the most common math operators for integers
@@ITSecNEO Hi, I hadn't replied because I actually have a life. Today, the first of January, I've got some time to procrastinate, so let me give you an answer. First of all, programming languages aren't a religion. They are just tools, like a hammer. Falling in love with a programming language is like falling in love with a hammer. Now, my comment was a bit taken out of context. I am not saying that Rust is wrong. I am just stating a fact: it lacks the overwhelming amount of libraries that you would find in C and C++ ecosystems, and I know that some Rust lovers might struggle to admit that fact. I am also aware that Rust can somehow import 'extern' C/C++ code. Actually, there is nothing innovative with that approach. Almost every programming language that I know can do the same thing and probably in better ways. Java with the Java Native Interface (JNI), Python with PyBind11/Shiboken/SIP/Boost::Python, JavaScript with Node native modules, and so on. The list also includes those languages that are self-proclaimed C++ killers but have miserably failed to replace C or C++ in the same way Dart failed to replace JavaScript. The problem with Rust integrating with other languages like C++ is that the two programming languages are fundamentally incompatible. I am not a Rust expert, but just to give you an example, many GUI libraries generally rely on OOP patterns such as inheritance, which allows extending functionalities in a more streamlined way. However, Rust doesn't even support inheritance, which closes the door to many design patterns that heavily rely on that OOP feature. Yes, I know there are traits in Rust, but they are not the same, and achieving the same flexibility might be more painful. Yes, I know composition is generally better than inheritance, but that is a different conversation. In fact, I am not saying that C++ is better than Rust as a programming language. It is very likely that Rust is better in many aspects, just as Dart is better than JavaScript. However, that is a different conversation. My point is that replacing a programming language such as C and C++ by using an incompatible programming language imposes too many challenges that could make it just another failure in that respect. There is a lot of code written in C and C++ that cannot be easily replaced by an incompatible programming language, no matter how good or better it is supposed to be. The industry has infallibly proven that that approach is more likely to fail. Instead, I see other approaches more likely to succeed in replacing C++. We can see examples of this in the industry. For example, TypeScript is a very good example of how you can migrate code from JavaScript to another programming language while maintaining compatibility. You just change the extension of a file from .js to .ts, and you start seeing results right away. This is also why C++ is a very successful language in terms of adoption. Because it was compatible with C right away, you just compile a C program with a C++ compiler, and you start seeing progress in code migration. I believe more in those approaches. This means that languages such as Carbon and CPP2 might have better chances to succeed than Rust if the first production-ready version of those languages gets released. However, it has been about 12 years since we first heard of Rust, and in 2024, it is still more like a niche programming language, and honestly, it hasn't yet replaced C and C++. In any case, I will be open to migrating code to Rust if I ever see that it offers as much or more than the C and C++ ecosystems offer today. More importantly, however, I will consider migration if I can achieve transparent integration of my code without having to contend with the pitfalls associated with the 'extern-function approach'. Regarding Golang, I like that it has a lot of support for cloud services while being relatively easy to learn and use in concurrency contexts. It also provides a descent performance. However, I will not give it a chance unless I have a compelling reason to use it. In the end, it is just another tool.
bro really coding in C++ 💀
The problem is Rust is still a new language and the job market for it is basically non-existing
Thanks for the awesome video! They r getting better and better. 👌
Clap, this could be a great talk in a conference
It was 👀
Nice job Chris!
JS is also slow due to how it uses memory, not only that it uses a GC it allocates lots of tiny objects all the time instead of having structs or larger entities it can always collect as a complete unit. Programs with lots of allocations are in my experience from debugging and profiling them a lot in production horribly inefficient in how they use memory with large number of objects. It also doesn't help that the still prevailing trend of JS projects using hundreds or some times even thousands of npm dependencies which bloats the whole build and run process a lot.
I like that statement of cargo.
It learnes from npm, yarn, etc. Improve on the good ones and optimize the bad ones.
this makes me want to learn rust, will start learning rust once I get job so I can freely focus on learning rust
thanks for the video though :)
You know what's interesting,... when you think about it... both JS and Rust came from Netscape/Mozilla.
Pretty soon Rust will run on the web and we’ll have videos with title like “Python or Rust. What to choose as your first programming language”
Why is nobody rewriting typescript (tsserver, tsc) itself to rust .. ?
The answer is mostly social/funding IMO. You could totally build tsc and the typechecking in another language, but what typescript "is" is defined entirely by what's in the microsoft/TypeScript repo and how that code works. So *if* you pursued this project, you would take on the burden of effectively tracking every PR into that repo in addition to building a whole second implementation of the compiler and typechecker.
The TS src/ directory is conservatively estimated at 300k lines of TS (I used tokei to count). This is fundamentally a lot of work to replicate in addition to there being very valid reasons to build a language's compiler in its own language so its unlikely that the microsoft/TypeScript repo switches away from TS. This is actually where I would prefer to see the effort happen as it has the most chance of success IMO.
The most common approach is to not replicate the typechecking at all and instead just try to build the compiler. This is what swc does: swc.rs/docs/migrating-from-tsc
That all said, there actually *are* attempts to write a TS typechecker in Rust. At least two that I know of. enzo and stc. Enzo explicitly declares that they aren't chasing 1:1 parity with TSC, while I *believe* stc is still trying to, but stc is very early in its lifecycle. Enzo is also mentioned as being part of oxc, which is the tooling vite/rolldown are going to use.
* enzo: github.com/kaleidawave/ezno
* stc: github.com/dudykr/stc
* github.com/web-infra-dev/oxc
* oxc/ezno: github.com/web-infra-dev/oxc#-ezno-type-checker
@@chrisbiscardi I get it.. But lets take esbuild - (as I understand) they are just trimming typscript out, leaving plain JS. And if you want typechecking - well - they say - check yourself.. This just feels like a hot patch, which on the surface works fast, but actually doesn't do what I would want it to do, and doesn't entirely resolve the issue. I might be wrong.
never used WebPack, I used rollup before and now vite.
"You can do nothing in any language" is true only up to a point. Lots of languages don't adhere to the idea of zero-cost abstractions so you're stuck choosing between ergonomics and efficiency. E.g. Every user-defined type in Java is a pointer to an object on the heap, which makes it impossible to have zero-cost newtypes in general, and especially numeric newtypes.
Just found you channel. Great vid!!! Later I'll check your other stuff.
I would love to use rust, but as mobile dev it lacks easy setup even to configure it as bindings.
as for web, I'd love to see something like Rails for Ruby but for Rust
What do you think about the existing web frameworks? I only used actix-web for a single endpoint hello world server with custom error handler yesterday. Yes, rails is simpler, but I can't judge it just from that tiny experiment.
@@bloody_albatross I checked actix-web, rocket and looked a little bit at axum - they are very similar to each other but they're more like micro frameworks - think express for javascript or flask for python.
In my opinion, rust should have something like rails or laravel - generator for project, sqlx configured out of the box, cli program to generate scaffolding, configuration in place for web templates, api + plugins for authorization. In that way you can startup your project in few seconds when currently you spend whole evening just to configure project structure and connection to database.
uniffy?
@@climatechangedoesntbargain9140you mean uniffi ? Yes it does exist. Still I cannot say it's easy to set up a new project with it. Compare it to something like creating a project with react native or flutter or even creating native project
@@gorudonu sorry, uniffi indeed
What 'bout bun, powered by zig?
this was an excellent intro to rust. thank you
CLI Rust tools make sense, but big fat no to Prisma. I'm not willing to take the cold-boot time hit on serverless. Multi-second cold-boot times are a deal-breaker. Honestly, I'm looking at making a monolith. Today with the new hyper-fast CPUs, it makes more sense for you to target a 128-core server with 2TB RAM and some nVidia H100 GPUs. You should probably just use a dyndns at first and server your website from home until you hit 1000 active month users. Chances are you'll never max it out, but if you do then you can just scale by doubling and you probably will save 4-10 $million. C++ for the win!
Rust is not the cause of Prisma's effect on cold boot times. Rust boot times in serverless environments are some of the lowest I've seen for any language.
Such a stud, excellent as always
Give me the short answer here please
I love rspress.
It's true that you can write performant code in any language or dogshit code in any language. But it is also true that the language pushes you in one direction or another via the path of least resistance. For example, JS tends to result in code that creates lots of garbage which can be a performance issue on memory constrained devices. Not creating garbage in JS is hard to do, you have to fight against the language to do that.
Expecting a full featured DOM API written in Rust in built with web browser 😊 Hope we can write frontend browser apps with Rust soon 😊
It's possible to do this today with crates like Yew and Leptos. We don't need to wait for a wasm dom api, although it would be nice to have that api.
@@chrisbiscardi then why aren’t we doing it? what’s blocking?
@@monawwarabdullah7438 not sure what you mean. I'm already doing it and there's nothing blocking me from doing it.
Yeah, why are we switching) BTW Thanks for twiggy!
Perhaps one day, ppl will write Rust instead of JS.
When every libraries we need are re-written in Rust.
Then it doesnt matter.
@no1youknowz could be fine too.
Indeed I intend to write transpiler to take use of Rust advanced compiler/analyzer.
We should not misunderstood that Rust used for tools which general developers use to create web apps in JavaScript. Rust is very difficult language. People cannot write good code even in JavaScript which more easier to grasp.
Why are you so reluctant to say Rust is fast? The same algorithm implemented runs much faster when written in rust and compiled than written in javascript and interpreted, right?
The first thing I would say is that JavaScript is also compiled these days. Chrome, for example, has a multi-stage compiler process including an optimizing compiler for turning JavaScript into machine code (ex TurboFan: v8.dev/docs/turbofan).
Yes, Rust has a strong focus on being able to achieve performance using various knobs. The focus on zero-cost abstractions helps a lot here to be able to use high-level language constructs without paying a runtime cost.
But at the end of the day there is more to performance than "use X language". IMO unless you're benchmarking your use case any statement along the lines of "X is faster than Y" is mostly theoretical, and applying that at the language level is even more fraught. For example, even if Rust is faster for a given algorithm as you suggested, is the overhead expended calling it across the FFI boundary worth it?
@@chrisbiscardi I wasn't thinking about using Rust to develop web front-ends, but libraries and CLI tools, where there is no overhead to crossing the boundary. That being said, I really wish we'd get rid of JS' monopoly on the FE. If only wasm didn't seem opposed to the idea.
People start to build everything with vite now though..
Fantastic video 👏🦀
we have a very long long long way to go
Amazing overview
I would be really happy if we slowly transitioned to rust for general web development. I've always wanted to get more experience with a low level language, but can never really afford the time to since all of my work pertains to javascript/typescript tooling
It's note veet, its vyte. It's not Linux, it's leenoox.
Um, I didn't go look if Vite has made any statements about it but I'd assume Vite comes from French (fast, quick) and then his pronunciation is in the ballpark.
Subscribed because you are using a light theme 😂
haha, unfortunately you're going to be disappointed in the next video; I'm mostly a dark mode user 😅. I gave this video as a presentation recently in-person which I find works much better with light-mode themes, which is why everything here is light-mode.
One correction: It's only possible to write programs that realize their full performance potential on C, C++, or Rust (and some other languages that are not popular enough to warrant a mention).
Other languages are not zero-overhead.
So you are 2 meters tall 🤨
Very good video 👏
Imagine ending the war between nodeJS & JS by simply using Rust & napi-rs
any minute now there will be a new language that "compiles to vanilla rust!"
and maybe that would be great actually, because procedural macros are not great last time I tried to write one.
Macros are definitely tough to write compared to everyday Rust. Luckily it seems like there was a macros working group (very) recently approved to work on this. It'll still be awhile before there's anything to show for it but it's a thing now: github.com/rust-lang/wg-macros
206cm?! 😮
I have realized watching channels like this is actually procrastination against learning Rust seriously. no. more.
Sounds like it's time for you to pick a project to work on.
js that compiles to rust is the future
Your pet the dog borrow checker example made it very easy to understand, cleared up many of my doubts. Thank you!
I also love the Rust testing framework. To such an extent that I have recreated something similar in Python to test my Py code.
Was very simple as well.
replace rustup, nvm, volta, n, fnm all with asdf-vm. seriously.
206, odd flex ;)
OK!
Parallelism is great and all but concurrency is where it's at
so, I should just learn rust, right?
If you have the time and energy to learn it, its a great language to know, but without knowing what kinds of programs you write, etc I can't make any blanket suggestions.
@@chrisbiscardi well I do frontend, currently angular, but I’ve been wanting to get more into backend and I was searching for a good language, although I know it doesn’t matter that much. I’ve hear a lot about rust, and mostly hear good things, so I might just jump into it
@@goo2581 yeah, choice of language won't matter too much when just getting started building small web APIs and such, you could use JS for that too. Rust can definitely be a great backend language to add to your toolbox. Axum in particular has a wonderful set of examples that can help as you're learning: github.com/tokio-rs/axum/tree/8854e660e9ab07404e5bb8e30b92311d3848de05/examples
@@chrisbiscardi yeah, I’ll check it out, note that I’m not new to backend, I used to work with C# and I’ll start to work again, for work-related purposes, but I want to make some personal projects with something new and better
@@goo2581 oh yeah, then you'll do fine. It'll just take a bit of time to get used to the language and whatnot.
206cm!?
I don't know why but I would love a javascript runtime written in rust.
There are some. Deno is the most well known and viable one. It still uses v8 under the hood though, just like node (bun uses JavaScriptCore). Building a competing JavaScript *engine* (like v8/jsc) is something nobody is doing afaik.
Yeah I use Deno wherever I can 'cause of its toolchain (lsp, formatter, etc) since I use helix and it is just simpler and more performant. But I actually meant I would love a javascript engine, not wrappers around v8 or javascriptcore like bun.
@brielov it's a tough project so I see why it hasn't been taken on. v8 is a million lines of code iirc and at the end of all that work you still end up with a JavaScript engine, which v8 already is. Even Servo, which I consider a wildly ambitious project, uses Rust bindings to spidermonkey for the JS engine afaik.
@@brielov There's an engine called Boa, but it's still very much new and doesn't support the entire ECMA specification yet and also lacks important performance optimizations. It might be possible to build a runtime around it once it matures though
45:16 nah bruv, the dog after it got adopted, got out of scope, got dropped and it ceased to exist.. it was killed 🥲
Zig and bun 😏
Honestly, I think the main reason is clout.
206 cm LUL