A 1 minute read post about Deno, the new kid in town. Is Node.js safe? Yes. Will you need to learn something new soon? Probably.
Deno is a project (written in Rust) which was created by the original creator of Node.js, Ryan Dahl and has recently gone 1.0 (currently 1.0.5).
It's defined on its website as:
- Read also: https://kitsonkelly.com/posts/deno-is-a-browser-for-code/
- See also: https://github.com/denolib/awesome-deno
In Deno by default your code can not:
- Access the filesystem
- Access the network
- Access the environment
To allow this, you have to explicitly enable access by providing a flag when executing your code.
Deno is trying to bring the "disabled by default" nature of the browser, to the server-side. They do this by sandboxing your code mostly like a browser does.
Here is an example.
If you run this without using the
--allow-net flag you'll see an error.
So to run this server you need to type
deno run --allow-net server.ts
In Deno things are quite different from Node.js, in particular:
- Dependency management (URLs instead of package.json, still somehow controversial for some people and some alternatives have been proposed)
- A secure/audited standard library is available! https://deno.land/std (HTTP, websockets, UUID, DateTime, etc...)
- Unlike Node.js, where once built/compiled you are given a set of files, with a single entry point, Deno will always give you a single executable binary (great for portability)
- Built-In linting and much more is coming in version 1.1!
Done, I told you this was fast.