Will Rust replace Javascript on the front end
This is my first blog post.
Rust helps developers write fast software that's memory-efficient. It's a modern replacement for languages like C++ or C with a focus on code safety and concise syntax.
Rust is quite different than JavaScript. JavaScript tries to find variables or objects not in use and automatically clears them from memory. This is called Garbage Collection. The language abstracts the developer from thinking about manual memory management.
With Rust, developers have more control over memory allocation, without it being as painful as C++.
Rust uses a relatively unique memory management approach that incorporates the idea of memory “ownership”. Basically, Rust keeps track of who can read and write to memory. It knows when the program is using memory and immediately frees the memory once it is no longer needed. It enforces memory rules at compile time, making it virtually impossible to have runtime memory bugs. You do not need to manually keep track of memory. The compiler takes care of it. – Discord
Adoption
On top of the companies mentioned above, Rust is also being used for popular open-source libraries like:
- Firecracker (AWS)
- Bottlerocket (AWS)
- Quiche (Cloudflare)
- Neqo (Mozilla)
Rust has been a force multiplier for our team, and betting on Rust was one of the best decisions we made. More than performance, its ergonomics and focus on correctness has helped us tame sync’s complexity. We can encode complex invariants about our system in the type system and have the compiler check them for us. – Dropbox
From JavaScript to Rust
JavaScript is the most widely used programming language, operating on every device with a web browser. Over the past ten years, a massive ecosystem has been built around JavaScript:
- Webpack: developers wanted to bundle multiple JavaScript files into one.
- Babel: developers wanted to write modern JavaScript while supporting older browsers.
- Terser: developers wanted to generate the smallest possible file sizes.
- Prettier: developers wanted an opinionated code formatter that just worked.
- ESLint: developers wanted to find issues with their code before deploying.
Millions of lines of code have been written and even more bugs have been fixed to create the bedrock for shipping web applications of today. All of these tools are written with JavaScript or TypeScript. This has worked well, but we've reached peak optimization with JS. This has inspired a new class of tools, designed to drastically improve the performance of building for the web.
SWC
SWC, created in 2017, is an extensible Rust-based platform for the next generation of fast developer tools. It's used by tools like Next.js, Parcel, and Deno, as well as companies like Vercel, ByteDance, Tencent, Shopify, and more.
SWC can be used for compilation, minification, bundling, and more – and is designed to be extended. It's something you can call to perform code transformations (either built-in or custom). Running those transformations happens through higher-level tools like Next.js.
Deno
Deno, created in 2018, is a simple, modern, and secure runtime for JavaScript and TypeScript that uses V8 and is built with Rust. It's an attempt to replace Node.js, written by the original creators of Node.js. While it was created in 2018, it didn't hit v1.0 until May 2020.
Header 1
Header 2
Header 3
Header 4
Header 5
Header 6
fn main() {
println!("Hello World!");
}
This is a list:
- Never use
asterick. - Avoid trait exetension.
This is a block quote
Multi line.