mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Musl-extra: C general-purpose and utility library
Date: Fri, 7 Sep 2012 09:31:47 -0400	[thread overview]
Message-ID: <20120907133147.GN27715@brightrain.aerifal.cx> (raw)
In-Reply-To: <20120907130412.25ecfd90@gmail.com>

On Fri, Sep 07, 2012 at 01:04:12PM +0200, philomath wrote:
> Hi,
> 
> (sorry for the title, I couldn't resist...)
> 
> During the recent discussions about feature-test-macros and libcap, it occurred
> to me that we need a unified good general-purpose C library (with "good"
> being understood as in musl's spirit).
> Musl at it's core aims to be a standards-compliant libc, and minimalistic at
> that, that's great. but it also brings in extra baggage, plus it has no place
> for data-structures, algorithms, and general utility functions.
> 
> Maybe we should only implement in musl the absolute minimum, and move
> everything else to musl-extra.  there we would create something like an
> alternative to Glib (and -shudder- gnulib) that sucks less (or even rocks). we
> can build on libraries such as plan9's, DJB and derivatives, etc (taking the
> good from the bed). in affect creating our own standards with no nonsense
> baggage.  who knows, in years to come we may all be working on the SMS (single
> musl specification).
> 
> Or maybe I should stop dreaming and get some work done?

I think what you're proposing is actually extremely difficult. Most of
what makes working C in valuable is doing your data structures without
generic containers. Having a binary search that operates on a static
const array, or putting your objects in one or more linked lists by
having prev/next pointers embedded in the structure rather than using
a container object for the list.

Once you move to using generic data structure implementations, the
complexity of managing allocations (and allocation failure!) increases
drastically. This is why most libraries like glib don't even bother to
do it right, and just crash when they run out of memory.

I'd love to be proven wrong, but so far my view is that if you want to
be using generic data structure classes, you should be using C++ or
another higher-level language. Doing it in C gives you all of the same
disadvantages (bloat, performance, impossibility of writing fail-safe
code with no allocations) but fails to give you many of the advantages
(for example, exceptions, which help you deal with the added
complexity of allocation failure, and syntactic sugar).

Personally, I think a clean, sane, bloat-free implementation of the
C++ standard library would be a lot more valuable for this kind of
work than a new non-standardized C library.

Rich


  reply	other threads:[~2012-09-07 13:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 11:04 philomath
2012-09-07 13:31 ` Rich Felker [this message]
2012-09-07 13:38   ` Gregor Richards
2012-09-07 13:49     ` Rich Felker
2012-09-19  8:38   ` Arvid E. Picciani
2012-09-19  8:54     ` Luca Barbato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120907133147.GN27715@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).