Hacker News new | ask | show | jobs
by simonw 83 days ago
Those aren't a standard library for the language itself - they're not showing up in browsers, for example.
1 comments

Thanks but that doesn't answer my question. Forget node and bun then. What is missing from the standard library?
There’s been a lot of progress (Temporal, URL, TextDecoder, Base64 encoding, etc.) but there are still gaps.

Math.clamp is a big one (it’s a TC39 proposal). I’d also love to have the stats functions that Python has (geometric mean, median, etc.).

On the more ambitious end: CSV reading/writing and IPv4/IPv6 manipulation.

> On the more ambitious end: CSV reading/writing

Deno's standard libary has nice CSV parsing/serializing, and you can use it in any environment.

Docs: https://docs.deno.com/examples/parsing_serializing_csv/

What standard library? Do you mean the built-in Array.x etc methods you get in the core language spec?
In the browser, Javascript’s role is to add interactivity to the web page, and the API has a good surface area (even if not really pretty). People talk about the lack of standard library, but they can never say what’s missing.

https://developer.mozilla.org/en-US/docs/Web/API

The above seems fairly expansive, even if we remove all the experimental ones in the list.

I suppose we could quibble about what exactly “standard library” means, but I’m presuming we’re talking about the web (rather than, say, Node or Bun). And to me it’s fair to use it to refer to all web APIs that are widely available. Things like crypto, ArrayBuffer, TextEncoder, File and the File System Access API, Intl, the Streams API, Window.performance, etc.
Most things in Remeda, ramda, rxjs, the methods in the Ruby stdlib, etc. would all be great to have. I use at least Remeda in every project when I can.
String.splitRight, for one. (As an example: "www.a.north.website.com".splitRight(".", 3) == ["www.a.north", "website", "com"].)
Python and Rust have such a thing, but not e.g. Java, Go, C#. And I can't find any libraries on npm which do this. That seems like a very niche need, not actually the sort of thing whose absence causes people to have lots of npm dependencies.
When would you want that when it wouldn't be covered by more domain-specific use cases?