TypeScript, WebAssembly, Rust: Three Tools Revolutionizing JavaScript Dev
Thanks to its ease of use, JavaScript is rapidly becoming the world’s most popular programming language. Developers love it, but it's not necessarily the best choice for the job, especially when it comes to back-end tooling, where safety and speed are critical factors.
One trend we are seeing is using Rust to build JavaScript tooling, points out Vercel developer advocate Lee Robinson, in a contributed post, “Could Rust be the Future of JavaScript Infrastructure?”
For instance, SWC built its platform for the next generation of fast developer tools in Rust. Deno, the secure alternative to the Node.js engine, was built in Rust. Also being rewritten in Rust: Rome, the frontend tooling package that includes a linter, compiler, bundler, test runner, and more for JavaScript, TypeScript, HTML, JSON, Markdown and CSS.
“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,” Robinson writes.
The folks behind the popular Svelte framework are also mulling the use of Rust, for building a compiler.
“A lot of JavaScript tooling is written in Rust at the moment, and maybe it would make sense if the Svelte compiler was written in Rust,” Svelte creator Richard said in a recent video interview.
Rust is not the only tool being used to optimize JavaScript. There is also TypeScript, a superset of JavaScript with static typing. Defining variables by data types sets the stage for better debugging and code analysis, noted Synopsys’ Charlotte Freeman, in a recent post. She notes that…
"TypeScript is also a statically typed language, which means that it checks types at compile. A dynamically typed language like JavaScript checks types at runtime. Moving these checks left to the compile stage means that TypeScript can find type errors before they are propagated into the program, preventing exploitable vulnerabilities from reaching a production application."
Last week, TNS contributing writer Divya Mohan wrote about combining TypeScript with WebAssembly for further optimization, by way of a TypeScript variant called AssemblyScript. Their reasoning goes like this:
"Although portable and fast, the performance of JavaScript was unpredictable when it came to complex web applications. This paved the way for efforts to design a compilation target for the web that was fast, secure, portable and enabled high performance — and for standardizing those efforts."
WebAssembly, as we covered before, allows the developer to write super-fast code, but it has a difficult interface. By using TypeScript as a language to write to WebAssembly, however, it offers a way to turbocharge JavaScript.
|