Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

If you were to create your own libc specification, what would you have in it?

48 views
Skip to first unread message

Rishab Tirupathi

unread,
Jul 1, 2022, 11:33:20 AM7/1/22
to
As of date, there are several implementations of the libc, such as glibc, BSD libc, musl libc, llvm-libc, and mlibc, but they all follow the same specification. Many people have thought that the specification is not well thought out. So, if you were to make your own libc specification for a standard library for the C programming language, what would you add?
One thing I would add would be a regex library. Regex has not existed in the C stdlib specification, and many people feel that the POSIX regex library is flawed. I wonder how the regex would work, though. Would it be too much to add Perl-compatible regex?
There are many other things I would like to add, like an OS-agnostic socket API, and perhaps better string functions that work with utf8. However, when should we stop adding stuff to this new stdlib? Many people view C as a language that only has basic primitives. Data structures are not meant to be in the stdlib, because that is C++'s job. So how large would this stdlib be?

Malcolm McLean

unread,
Jul 1, 2022, 11:43:38 AM7/1/22
to
From experience with Perl, I wouldn't add regexes. Regular expressions are too complicated to be entered by
the user. They turn into little programs in their own right, which have to be tested and debugged, and which
are hard to read and maintain. Additionally, you've got the parser problem for validating input. If a function
is a parser, there's no way of validating the input without effectively running the parser over it. So errors
can occur late in the development cycle.

Scott Lurndal

unread,
Jul 1, 2022, 12:58:17 PM7/1/22
to
Rishab Tirupathi <rish...@gmail.com> writes:
> As of date, there are several implementations of the libc, such as glib=
>c, BSD libc, musl libc, llvm-libc, and mlibc, but they all follow the same =
>specification.

Yes, that specification is this:

https://pubs.opengroup.org/onlinepubs/9699919799/

>Many people have thought that the specification is not well
>thought out.

Is that a fact? Or your opinion? A lot of people have spent
a lot of time over the last several decades building that
specification which has served well.

> and many people feel that the POSIX regex library is flawed

Is that a fact, or your opinon? Flawed, or just different?


The power of C is that you can link with any library that provides
the services you require.

Note that 'libc' is an implementation choice, not a standard. The
standard simply requires certain interfaces be provided - it doesn't
discuss libraries at all.

(Unix (the AT&T side) once had a viable OS-Agnostic networking
API (TLI built on System V Streams), but sockets, while perhaps
technically inferior in some ways, clearly won that battle - likely
thanks to WinSock).

https://docs.oracle.com/cd/E23824_01/html/821-1602/tli-33281.html

Malcolm McLean

unread,
Jul 1, 2022, 1:11:20 PM7/1/22
to
On Friday, 1 July 2022 at 17:58:17 UTC+1, Scott Lurndal wrote:
> Rishab Tirupathi <rish...@gmail.com> writes:
> > As of date, there are several implementations of the libc, such as glib=
> >c, BSD libc, musl libc, llvm-libc, and mlibc, but they all follow the same =
> >specification.
> Note that 'libc' is an implementation choice, not a standard. The
> standard simply requires certain interfaces be provided - it doesn't
> discuss libraries at all.
>
Rishab Tirupathi obviously thinks that "libc" means "the standard library".
It's not the right term. libc is the name of the standard library on many
systems, but term for the standard library itself is "the standard library".

As you say, it doesn't actually have to be a library, which can be important
when functions are built in to the compiler, allowing for optimisations
which otherwise wouldn't be possible.

0 new messages