The WinterJS Javascript Runtime Is Asking For Your Attention
Written by Nikos Vaggalis   
Thursday, 11 April 2024

WinterJS is a brand new Javascript runtime by Wasmer which comes with the claim that it's the fastest of them all. Let's find out if that holds true.

wasmerlogo

Really there's no shortage of JS runtimes. There's already, Node. js, Deno, Bun and the recently covered by Iprogrammer LLRT by AWS;and that's not the end of the list. So why a new runtime? What does it do differently?

As a refresher and to take the steam off the terminology, a runtime (WinterJS in this case) is a place or environment where your code executes. It is not the thing running the code itself (this is the engine, SpiderMonkey in this case) but rather an environment that provides access to certain parts of the outside world.

So WinterJS is actually the runtime of a Server that uses the SpiderMonkey engine to execute the JavaScript. The claim is that it's blazing fast; faster than Bun and Node.
That stems from the fact that WinterJS is able to handle 150k requests/second when executed natively and 20k requests/second when compiled to Wasm using WASIX.

As another refresher, WASIX is an extension to the WebAssembly System Interface (WASI) designed to make WebAssembly (Wasm) more compatible with POSIX programs, enabling the seamless execution of more complex applications in both the browser and server environments. It extends WASI with most of the missing POSIX features and is designed to run both in the server and the browser.

As such it provides full support for efficient multithreading, sockets, current directory pthreads, process forking , subprocess spawning and waiting (exec, wait), TTY support, asynchronous polling of sockets and files, pipe and event support, etc.

However, currently the only runtime that supports WASIX is Wasmer, the makers of WinterJS. You see the connection here. That might all sound fine but the performance drop of more than 80% when deployed as WASM from that of Native, strikes me as something of importance. Can it do better?

If affirmative then the time when you can pack your full server into a single WASM binary and deploy it on the cloud would come a step closer. And provide further fuel to the Webassembly as a replacement of Docker debate.

Runtime wise, WinterJS is WinterCG complaint, which means that it can't be a drop-in replacement of Node.js, something obvious with just a glance at the Runtime compatibility comparison chart. If you go on to check it you'll see that the supported APIs are not at par with Nodejs's.

More or less, this is something to be expected since Nodejs packs more functionality than WinterCG. However as the trend wants, the newest runtimes being released are dedicated to a special purpose. As such to be more memory savvy as well as fast, they throw a lot of functionality out. An example of that we've examined in "AWS Introduces A New JavaScript Runtime For Lambda" :

LLRT is totally optimized for Lamda use. It really doesn't try to compete with the rest; it's just made for a single purpose only, in the context of Lambda. This also means that its size is tiny, in the order of a few kilobytes in contrast to the 20+MB required by its counterparts.

WinterJS is then a library dedicated to and optimized for Web Servers.

A server that comes with full Cloudflare API compatibility. This was a conscious choice in that this API is compatible with the most of the frontend frameworks and is probably the most used out in the wild. This integration opened the door to a wide compatibility with Web frameworks such as :

  • Next.js
  • Next.js React Server Components
  • Hono
  • Astro.build
  • Remix.run
  • Svelte
  • Gatsby
  • Nuxt

Now to coding. You can install WinterJS natively with:

cargo install --git https://github.com/wasmerio/winterjs winterjs

Once you have WinterJS installed, you can simply run the HTTP server:

winterjs tests/simple. js

and then access the server in https://localhost:8080/

Alternatively to run it under Wasmer :

wasmer run wasmer/winterjs --net --mapdir=tests:tests tests/simple.js

Where simple.js is:

addEventListener('fetch', (req) => {
     req. respondWith(new Response('hello'));
});

Your server application is now up and running!

So that's yet another JavaScript runtime trying to attract your attention. What do you think, has it managed to do so?

 wasmericon

More Information

Official announcement

WinterJS on Github

Related Articles

 AWS Introduces A New JavaScript Runtime For Lambda

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


GitLab Adds Google Cloud Integration
14/05/2024

GitLab has released public betas of the integration features with Google Cloud that the company announced in 2023. The integration means GitLab’s DevSecOps workflow integrates with Google Cloud secu [ ... ]



Digital Play Shown To Be Good For Kids
03/05/2024

When designed with their needs in mind, video games can benefit children’s well-being. This finding comes research from  UNICEF in partnership with LEGO and the University of Sheffield.


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 11 April 2024 )