If I'm sure of one thing, it is that typescript completely changed the way developers viewed javascript.
working with javascript in small and medium projects is not a problem but in bigger and more complex projects it is much more difficult. JavaScript was not originally intended to be a language for creating complex applications as it is today, behaviors like these are some of the reasons why javascript is heavily criticized:
{} + "" // 0
[] + {} // [object Object]
10 + "10" // 1010
10 - "5" // 5
Yes, javascript is rare but it is the language that changed the world since it is the only programming language to run in the backend and frontend.
In 2012, typescript arrived as a superset language that compiled to javascript and brought javascript closer to languages with strong types such as java or C#
So far so good, what is the problem?
typescript bottleneck
the typescript compiler is slow, and don't get me wrong the compiler developers are doing a good job, the problem is node js, node js is designed to use a single core of the processor, it can work with multiple processes but in practice only a single core is used. which causes that when compiling typescript node js cannot take full advantage of the power of your processor, so the compilation can be slow in some cases.
so what is the solution?
Rust
rust is a multi-paradigm language, compiled and concurrent that saw the light in its first version in 2015, this is developed by mozilla and is open source.
SWC is a compiler for typescript and javascript written in rust and is being developed by a 22 year old South Korean student. is making it possible to lower compile times by using rust as the language.
if tools like webpack or babel were written in languages like rust or go that allow us to use all the cores of our processor, we would have more efficient and faster development tools.
then Let's rewrite Typescript in Rust!
this post is inspired by the tweet of Jonny Burger
Let's rewrite Typescript in Rust!
Top comments (17)
Hello, Deno does something about this no?
Part of this concern comes from the fact that I am working on a CLI to for deno and wanted to optimize working times but it takes a long time for the typescript compiler, deno includes the official compiler
Good to know I am learning js/Deno in the same time and the information helps
any questions, I have no problem helping you
Woah. That's a spicy meatball. #bigProject #goBigOrGoHome #rustLang
Kotlin and Clojure also run both in the backend and frontend. If you include wasm it's a bunch more.
F#, Purescript, Nim, Dart, Haxe are also languages that can be used for both frontend and backend since they can be compiled to Javascript.
How's the tooling. Last time I tried with Kotlin it was not that great. Clojurescript on the other hand is pretty amazing, keeping state while reloading, and doing the reloading fast. Only thing with Clojurescript is that error messages are nog always usefull.
Check out esbuild for fast ts bundles
Yep, esbuild is crazy fast and is being written by an extremely talented and experienced developer - it solves the compile speed problem for both TS and ES, so in the likely event that you're going to bundle, well... 🙂
See also Facebook's Rome project, which I think is going to compete in the same space.
esbuild is fast bundler but it does not typecheck
This is a very important point and it's the same for SWC. From what I've seen all it does is strip the types. You can quite happily "compile" what's actually invalid typescript:
to
So really this is not an alternative to tsc, you might as well write javascript. What would be really cool is if their was a true typescript compiler written in rust/c++/go. I've been searching for this, but I don't think it exists.
Do you know maybe, was there any movement in the meantime?
Was searching for the same thing, and could not find anything.
Hi there I’m interested in this project, where is the GitHub repo?
here is the project repo github.com/swc-project/swc
Really cool
Damnnnnnn