mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Best place to discuss other lightweight libraries?
Date: Mon, 22 Apr 2013 10:53:46 -0400	[thread overview]
Message-ID: <20130422145346.GP20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAFipMOF+dKc_oDGWU6pZ51+8HZ8FhfaMUq=4hOTXUG62WxNJVg@mail.gmail.com>

On Sun, Apr 21, 2013 at 12:30:54PM -0400, LM wrote:
> Musl does a great job of replacing glibc.  It's lightweight,
> well-designed and written with friendly licensing.  However, I'm
> noticing there are a lot of other standard libraries and tools on a
> typical system and often many of them are bloated or not so well
> designed.  I've been looking for a good forum to discuss using
> alternative libraries and tools.  I've checked out projects like

I have no objection to discussion on this list, at least for the time
being. If it becomes too much clutter, I might request later that we
move such discussions to a separate list, but for now, go ahead. We've
already had a few past discussions along these lines.

For what it's worth, I think poor design is really the core of the
problem. Bloat often stems from the effort needed to work around the
bad design. The major design issues I've seen in widespread libraries
are:

- Tacking on error handling as an afterthought or not at all. This
  leads to ugly things like the caller having to setup a jmp_buf for
  the library to bail out on error (likely leaking lots of memory in
  the process) or just aborting the program on error. Sometimes the
  hacks like longjmp are added in ways that they're not safe with
  multiple users of the library or with threads.

- Multiple "portable runtime" layers to do things the standard library
  already does, usually in less-portable or buggy ways.

- Making a big deal out of string handling. Ugly OO-in-C string types
  with dynamic allocation and slow concatenation operations all over
  the place. Basically, anything that's generating strings any way
  other than snprintf/asprintf, unless it's performance-critical, is
  broken.

- Gratuitous OO design. Good OO in C is having the complex or
  long-lived objects your library deals with well-encapsulated by
  library functions, and fully self-contained, without global state.
  Bad OO in C is reimplementing the C++ STL in C, with things like
  container objects, iterator objects, string objects, etc., as well
  as trying to do any global-level inheritance. As a clarification,
  things like implementing multiple video decoders that inherit an
  interface from a base "class" is reasonable; making every single
  object in your library derive from something like "GObject" is not.

- Gratuitous ugly typedefs, especially as part of the external API,
  and especially when they duplicate standard types (INT, gint, etc.).

- Interfaces that encourage or require UB to use them. One example
  that comes to mind is functions with signatures like posix_memalign
  which take a void** argument to store the result of an allocation.
  This encourages things like (void **)&ptr where ptr has type int*,
  for example.

- Thread allergies, i.e. horribly over-complicating program logic to
  avoid threads. The best examples I can think of are the added logic
  needed to generalize a program that's reading from ordinary file
  descriptors (e.g. connection sockets) in an event loop to support
  SSL sockets or zlib-compressed streams. (Note: there are ways to
  address this kind of problem more cleanly without threads too, but
  nobody does it. I can elaborate if anybody's interested.)

- DBus.

- Use of global state. Even seemingly-harmless things like a global
  registered log function are harmful, because two different libraries
  (or the main program and a library) might be trying to use the
  library with the global log destination, and clobbering each other's
  choices.

- Designs based on shared libraries, especially lots of them. This
  creates bloat and often interferes with the ability to use static
  linking.

- Excessive dependence on external files and filesystem layout. This
  conflicts with easily migrating the binaries to other machines.

- Dependency on any library with the above problems. :-)

Rich


  parent reply	other threads:[~2013-04-22 14:53 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-21 16:30 LM
2013-04-21 20:17 ` Rob Landley
2013-04-21 20:24 ` Rob Landley
2013-04-24 11:39   ` LM
2013-04-25 19:30     ` Rob Landley
2013-04-21 23:26 ` Isaac Dunham
2013-04-22 14:53 ` Rich Felker [this message]
2013-04-22 15:21   ` Luca Barbato
2013-04-22 16:40     ` LM
2013-04-22 16:47       ` Daniel Cegiełka
2013-04-22 22:07         ` Rich Felker
2013-04-23 12:50           ` LM
2013-04-23 14:40             ` John Spencer
2013-04-23 14:58               ` Rich Felker
2013-04-22 19:31       ` Luca Barbato
2013-04-22 23:24       ` Rob Landley
2013-04-22 23:31         ` Rich Felker
2013-04-23  0:54           ` Rob Landley
2013-04-23  1:46             ` Rich Felker
2013-04-23  5:04               ` Isaac Dunham
2013-04-23 13:47                 ` Rich Felker
2013-04-23 21:25                   ` Luca Barbato
2013-04-23 21:50                   ` Kurt H Maier
2013-04-24  2:37                     ` Rich Felker
2013-04-24  4:43                       ` Kurt H Maier
2013-04-24 13:37                         ` Rich Felker
2013-04-24  0:50                   ` idunham
2013-04-24  6:11                 ` Rob Landley
2013-04-22 21:52     ` Rich Felker
2013-04-22 22:42       ` Luca Barbato
2013-04-22 23:06         ` Rich Felker
2013-04-23  0:26           ` Luca Barbato
2013-04-23  2:14             ` Rob Landley
2013-04-23 19:07               ` Strake
2013-04-23 19:24                 ` Daniel Cegiełka
2013-04-23 21:33                   ` Szabolcs Nagy
2013-04-24 12:12                     ` Zvi Gilboa
2013-04-23 21:34               ` Luca Barbato
2013-04-24 11:18                 ` Daniel Cegiełka
2013-04-24 11:48                   ` Kurt H Maier
2013-04-24 12:32                     ` Daniel Cegiełka
2013-04-24 13:38                       ` Rich Felker
2013-04-24 13:55                         ` Daniel Cegiełka
2013-04-24 13:37                     ` go support (was: Best place to discuss other lightweight libraries?) John Spencer
2013-04-24 13:39                       ` Rich Felker
2013-04-24 16:33                       ` Kurt H Maier
2013-04-24 15:47                     ` Best place to discuss other lightweight libraries? Szabolcs Nagy
2013-04-24 19:17                       ` Rich Felker
2013-04-25  6:40                         ` Szabolcs Nagy
2013-04-25 19:37                     ` Rob Landley
2013-04-24 13:28                   ` go support (was: Best place to discuss other lightweight libraries?) John Spencer
2013-04-24 13:42                     ` Rich Felker
2013-04-24 14:06                   ` Best place to discuss other lightweight libraries? Christian Neukirchen
2013-04-29 11:41                     ` Daniel Cegiełka
2013-04-29 16:31                       ` Go (was: [musl] Best place to discuss other lightweight libraries?) John Spencer
2013-04-29 16:44                         ` Daniel Cegiełka
2013-04-23  0:31       ` Best place to discuss other lightweight libraries? Rob Landley

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=20130422145346.GP20323@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).