Hacker News new | ask | show | jobs
by synergy20 1624 days ago
nice to have ts+linter+formatter together, it took me one or two hours to set up with my own vim(using vite/volar), so it saves me some time.

what I really like a new Node.js(e.g. deno) is actually its module system, I don't like the `npm i` in node.js pulls hundreds of modules, a standard library that contains most commonly needed modules is the key. If deno does not do that, I probably will never try that(as I can have the bundle of tooling done myself in one-or-two hours, vite/volar now makes this even simpler).

In short, I will prefer gold-quality set of modules or APIs(e.g. glibc) to the 100% flexibility "you pull whatever you want freely now even over http URL", for security and stability reasons.

2 comments

> I don't like the `npm i` in node.js pulls hundreds of modules

Because modules/packages routinely have dependencies. And their dependencies have dependencies. And...

Deno changes nothing in that regard with one single exception:

> a standard library that contains most commonly needed modules is the key

^ This is the bane of Javascript, yes. But this doesn't mean that having a standard library somehow prevents modules having multiple dependencies and subdependencies.

> "you pull whatever you want freely now even over http URL", for security and stability reasons.

- If you pull your deps from a random URL and that URL goes away, how do you solve that?

- If your deps pull other subdeps from a random URL and that URL goes away, how do you solve that?

- For security, how do you vet what your dependencies keep on pulling from random URLs?

For node, the answer is: run your own registry, and don't load anything from outside. That's how many companies operate. How can this be solved with Deno?

In Deno's case, there are two things:

Deno API, which comes bundled with Deno and is present globally, always, without importing: https://doc.deno.land/deno/stable. Includes basic stuff like stdin, stdout, stderr, file management... etc and standard Web APIs like Fetch API, web assembly interoperability, localStorage, FormData, TextEncoder/TextDecoder, etc.

Deno std lib, an official library that presents what you could expect from a standard library, based on Deno API: https://deno.land/std@0.120.0, but you need to import it, because it's no different than any other module in the wild. Mime types, more encoding options, extended file system management, etc.

I just noticed that Deno merged their native FFI support: https://deno.land/manual@main/runtime/ffi_api

I had been watching some issues around this, but lost track, so I'm very excited to see it is available now! This makes Deno _very appealing_ for a wide range of tasks where FFI is a small but non-negotiable necessity (places where I would use Python's ctypes, for example tooling around C libraries; such tooling becomes much more complicated if another toolchain and compilation step is required before lib can be called from a script).

So what's Deno's stdlib principle:

    1. you got pretty much 80% of what you will need from the std libraries for a mid-size 'normal' application(similar to glibc, libstdcpp, go stdlib, python's stdlib)
    2. you got a small stdlib than usual(rust's stdlib), the rest you use cargo and good luck with that
    3. you grab whatever you need(node.js, you have no idea about the 500 modules npm just installed)
I prefer No.1 here.
Isn't the scope of the standard library of C and C++ close to the scope of the Rust standard library (an thus much smaller than python's)?
nope, I was told rust prefers to a light stdlib approach.
C and C++ also have light stdlibs from my point of view, just like Rust.

Rust has collections, strings and algorithms manipulating these. It supports synchronous IO (files and network) and can work with threads/processes. It lacks async IO, higher level network protocols (e.g. HTTP and TLS), regex, advanced unicode support, serialization, UUIDs, GUI, linear algebra/vectors, logging, encoding, time, randomness, command line parsing, cryptography, compression.

C++ has reasonable randomness and time support, but apart from that Rust isn't far behind.

It's definitely No.1.