4 points vodou | 5 comments | | HN request time: 0.616s | source

I know, I know... There are countless "it depends" baked into this question. But let’s try anyway.

After reading HN for years, I have encountered so many opinions regarding standard libraries in various programming languages, e.g., how they should be designed, what they should (and should not) include, etc.

The C standard library is very minimal, focusing mostly on low-level facilities. Everyone is expected to implement their own dynamic arrays or choose one implementation from a zillion available libraries. And, apparently, null-terminated strings are the work of the devil. C++ has a much more extensive standard library, built around generic programming techniques using containers, iterators, and algorithms applied in a composable way. It is rather elegant and powerful, but not very intuitive for beginners. It also has some notable omissions compared to more modern languages. Python comes with "batteries included" in the form of a very rich standard library. However, the PSF tends to "break user space" from time to time by deprecating older modules, such as “boring” technologies like CGI or modules with known security problems. (I am not comfortable enough to say anything about JS, Go, Rust, etc.)

So, what would a great standard library look like? What would make you happy? What have we learned about this after 50+ years of computing? Do you want everything from linked lists to red-black trees (and beyond)? Graphics and sound? (Even if no single API can please everyone.) XML? YAML? SIMD abstractions? Where do you even stop without causing anger? Where do you begin?

(No, I am not creating a new programming language. Enough is enough.)

1. rickcarlino ◴[] No.44574757[source]
I love this question.

HTTP server and related parsers (just a basic one), URL parsing and escaping, JSON, Socket handling, timers, interactive debugger, basic templating library, WebSocket client, SQLite.

I think Ruby got it right in this regard and Bun comes close as a second place.

2. bjourne ◴[] No.44576046[source]
Like Wikipedia tries to catalogue all useful knowledge in the world, a standard library should catalogue all useful modules in the world. The problem is that tools and community structures we have are not advanced enough to support that workflow yet. E.g., it's difficult to see how you could put PyTorch into Python's standard library and have all developers happy with that. But it would make a lot of "meta" issues easier, such as release management, consistent documentation, community relations, etc.
3. moomoo11 ◴[] No.44577264[source]
Go has a nice std, and interfaces that make it easy to add on top instead of reinventing the wheel.

I think as long as a language offers the basics (like streams, etc) it’s not that bad to build on top of it.

4. mikewarot ◴[] No.44577897[source]
If you can possibly include the "magic" strings that Free Pascal has, you'll be light years ahead of just plain C strings. They're counted, reference counted, and copy on modify. You don't have to allocate/free them, and they can contain gigabytes of ASCII, Unicode, or Binary data.