News for hackers. Stuff that matters.
Re:Read your Standard Libraries by unwind on Friday January 03, 2014 @12:07PM (#7006536)
This is great advice, since in general you would like to assume that the standard library is implemented well, i.e. by people who know the target language.

Unfortunately, for C this is pretty hard to do, at least for the GNU libc. I'm not trying to critique the implementation, but every time I dive in (generally to help someone on Stack Overflow) I'm confused and get to spend a lot of time searching the code.

It's obviously optimized for a great deal of other parameters before ease of reading, which I totally understand yet still am a bit sorry to see.

Re:Read your Standard Libraries by chubot on Friday January 03, 2014 @02:30PM (#7007521)
Yeah, a lot of good programmers have alternatives to libc, either for reasons of history or taste.

I was just reading DJB's daemontools (less than 6K LOC, very tidy!), and he doesn't use libc. Actually his code has been collected in libdjb, which seems quite nice:

http://www.fefe.de/djb/

And also the Plan 9 / Go guys don't use ANSI libc as far as I remember.

Those are two examples of people who don't even use the ANSI libc interface. But there are plenty of people who don't use GNU libc, and use uclibc or various other source-compatible alternatives. I think Debian switched to eglibc awhile ago.

Re:Read your Standard Libraries by rat87 on Friday January 03, 2014 @03:02PM (#7007740)
I'm pretty sure eglibc(Embedded GLIBC) is basically a patchset for glibc for certain distros(especially debian and derivatives) because they disagreed with the maintainer especially over ARM support.
Re:Read your Standard Libraries by burntsushi on Friday January 03, 2014 @06:53PM (#7009073)
Just FYI, I believe that by default, binaries compiled with the standard Go toolchain do link against your system's libc (which is probably GNU libc on Linux). However, I believe that can be disabled by compiling the Go toolchain with `CGO_ENABLED=0` set. But you might lose some functionality.[1]

[1] - https://groups.google.com/forum/#!msg/golang-nuts/H-NTwhQVp-...

Re:Read your Standard Libraries by chubot on Saturday January 04, 2014 @05:08PM (#7013177)
So I'm actually talking about what the Go compilers themselves use for libc, not Go programs. From what I can tell it is:

http://code.google.com/p/go/source/browse/include/libc.h

Which is definitely not ANSI libc. Go programmers won't care about this, because it's an implementation detail, but we're talking about reading source code.

Re:Read your Standard Libraries by burntsushi on Saturday January 04, 2014 @10:36PM (#7014387)
Ah! Mea culpa. I completely misunderstood your initial comment then. You're absolutely right.
Re:Read your Standard Libraries by asveikau on Friday January 03, 2014 @01:32PM (#7007111)
I don't remember the last time I looked at glibc source so I am not sure if I can relate to this comment or not. However, I just wanted to throw in that I find the various *BSD projects, including their libcs, very readable. It helps that everything is in a single tree with some consistency in naming patterns etc, and the style is usually decent.
Re:Read your Standard Libraries by clarry on Friday January 03, 2014 @03:04PM (#7007747)
I just have to second this. I have a checkout of the OpenBSD source tree on all my machines. While tinkering with stuff, I often end up browsing the code under libc/, with great curiosity. Though there are many not-quite-so-pretty bits inherited from the dark ages, I can't say I've ever really felt confused. On the contrary, there's plenty of nice, inspiring code just waiting to be read. Oh, and there's superb documentation to go with it.
Re:Read your Standard Libraries by NAFV_P on Friday January 03, 2014 @02:10PM (#7007381)
I was reading stdio.h and stdlib.h yesterday, because I wanted to know the macro definition which prevents multiple includes. The code seems a bit 'organic', like it was cultured in a petri dish.
Re:Read your Standard Libraries by maaku on Friday January 03, 2014 @06:07PM (#7008896)
It's an apt description as that code did grow and evolve, constrained by natural selection - only those changes which could be safely made without breaking or even changing functionality on hundreds of architectures over thousands of platforms ever made it in. Naturally that means it is an ever growing assortment of carefully vetted but otherwise horribly ugly hacks.
Re:Read your Standard Libraries by NAFV_P on Friday January 03, 2014 @09:53PM (#7009755)
I thought the headers looked wicked, like a bizarre fantasy wilderness populated with fairies and leprechauns.
Re:Read your Standard Libraries by ori_b on Friday January 03, 2014 @10:11PM (#7009810)
I suggest looking at musl libc: http://git.musl-libc.org/cgit/musl/tree
Re:Read your Standard Libraries by userbinator on Friday January 03, 2014 @09:39PM (#7009702)
You might be interested in this: http://hg.pdclib.e43.eu/pdclib

It's a public domain C library, much smaller and less of a monster than glibc, plus you don't have to worry about any implications of reading GPL code.

Re:Read your Standard Libraries by alextingle on Saturday January 04, 2014 @08:12AM (#7010952)
Tell me more of these "implications of reading GPL code".