The C Containers Library

J

jacob navia

Le 29/07/12 20:58, Keith Thompson a écrit :
And as far as I can tell, glib has no function called "xmalloc".
Perhaps it was in an earlier version?

We have discussed this to death but here we go again.

http://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c/

Examples – libraries
In this section, I present the OOM policies of a couple of well-known
libraries.

Glib

Glib is a cross platform utility library in C, used most notably for
GTK+. At first sight, Glib’s approach to memory allocation is flexible.
It provides two functions (with several variations):

g_malloc: attempts to allocate memory and exits with an error if the
allocation fails, using g_error [1]. This is the abort policy.
g_try_malloc: attempts to allocate memory and just returns NULL if that
fails, without aborting.

This way, Glib leaves the programmer the choice – you can choose the
policy. However, the story doesn’t end here. What does Glib use for its
own utilities? Let’s check g_array for instance. Allocation of a new
array is done by means of calling g_array_maybe_expand that uses
g_realloc, which is implemented with the same abort policy as g_malloc –
it aborts when the memory can’t be allocated.

Curiously, Glib isn’t consistent with this policy. Many modules use
g_malloc, but a couple (such as the gfileutils module) use g_try_malloc
and notify the caller on memory allocation errors.

So what do we have here? It seems that one of the most popular C
libraries out there uses the abort policy of memory allocations. Take
that into account when writing applications that make use of Glib – if
you’re planning some kind of graceful OOM recovery, you’re out of luck.
 
A

Alan Curry

[resending post, it seems to have been lost]

Le 29/07/12 19:27, Alan Curry a écrit :

So, you propose that the standard accepts something hat has "major
problems" as you say just because it is used in GTK+ ?

If you think I proposed it you should read again. I said a proposal
based on a working library with known flaws is more reasonable than a
proposal based on a library that's never seen real-world use (and which
therefore has *unknown* flaws).
From the linux/gnu side GTK+ uses the glib yes, but I do not know of
many major software that uses that stuff OUTSIDE gtk+. I would be
interested to know if there is any. Can you name a few?

I stitched together some "aptitude why" queries and verified that at
least 719 packages available in Debian require libglib but not libgtk.

Here are some of the highlights:

amanda-common: Advanced Maryland Automatic Network Disk Archiver (Client)
asterisk: Open Source Private Branch Exchange (PBX)
bluez: Bluetooth tools and daemons
dvdauthor: create DVD-Video file system
e16: the Enlightenment Window Manager DR16
fontforge: font editor
gettext: GNU Internationalization utilities
gphotofs: filesystem to mount digital cameras
gpsim: Simulator for Microchip's PIC microcontrollers
ifuse: FUSE module for iPhone and iPod Touch devices
imagemagick: image manipulation programs
jnettop: View hosts/ports taking up the most network traffic
lilypond: A program for typesetting sheet music
nbd-server: Network Block Device protocol - server
pcb-lesstif: printed circuit board (pcb) design program - LessTif interface
sobby: a dedicated server for collaborative editing
usbip: USB device sharing system over IP network
wireshark-common: network traffic analyzer - common files
xplanet: planetary body renderer
zorp: An advanced protocol analyzing firewall

Quite a variety of stuff now depends on GLib.
 
A

Ansel

jacob navia said:
Le 29/07/12 06:08, Ansel a écrit :

No, I will not do that. The library is not a direct competition for the
STL,

I don't see how you could *not* examine STL in great detail in pursuit of a
container library these days. Aren't you afraid of missing out on things
learned from the STL implementation? Containers *do* have common ground
(design and architecture) apart from the languages they are written in, you
know.
C++ is the best thing since sliced bread, and people that like
that machinery because they have been building it since years would fall
on me and my small project like hawks...

But consider that you wouldn't have to research/analyze/build all the
containers, just one or two. The rest of the design would pretty much
follow. But that's just something I would do, and worth about .02 to you
maybe. Which other container libraries did you examine in detail? Java or C#
perhaps?
C++ people tend to look upon simpler tools like C with disdain since by
their very existence they show that another (simpler) way is possible
in software development; a way that leads maybe into less complexity
than what C++ offers now.

Define the criteria of simplicity. CCL is simpler than STL.. how? Simpler to
implement? Simpler to comprehend and use? How many ancillary techniques does
it require to implement or use CCL? Will C programmers be able to use it
immediately or is there a learning curve and some number of "gotchas"? I
don't actually want you to answer these questions here -- I want to read the
white paper!
But I am not pushing that, and I do not see
C++ people abandoning C++ to come to C. I see C programmers having
more fun with C since they do not have to implement a list AGAIN and
AGAIN.

I see the library a a develomment of the C language, independent of C++.

Not as a competitor.

And I stay to this:

I still think you should develop a professional-level white paper to show
how serious you are. Else, how will anyone know that you didn't bury your
head in the sand to whole realm of container technology, past and present?
Is there a better model for presentation of such technical matter? Compare
"white paper" with "brochure". If you are armed with only "brochure", I
don't see this going anywhere. Do you have a good story to tell the
committee? What is that saying in academic circles? Oh yeah, "publish or
perish".

Just another .02 from me. I wish you luck, but I hope you are, or will be,
well-prepared so you won't need luck.
 
A

Ansel

Alan Curry said:
Le 29/07/12 06:08, Ansel a écrit :
I don't think you can go to the conference and *not* compare against STL
even though you have a C-based product. Else you're going to get
responses
like James gave you about it being kludgy -- you have to address that
("that" being that C gives one less clay to mold a container library
with)
and try to alleviate those concerns so that no one even thinks to say
that.
Your story needs to be not only convincing, but *compelling*.
[...]

No, I will not do that. The library is not a direct competition for the
STL, C++ is the best thing since sliced bread, and people that like
that machinery because they have been building it since years would fall
on me and my small project like hawks...

Could you do a side-by-side with GLib? It has linked lists, trees,
hashes... it's not exactly the same thing, but there is significant
overlap. It's a C library, so it's closer to being your real
competition.

I don't see it as a competition-type thing at all. Showing cognizance of
current technology is important (yes outside of one's pet language too). If
a dead C programmer from the 1970's were resurected and he immediately
created a container library for C based upon his existing knowledge, would
you take it seriously as a potential tool? It is A-OK to reject
alternatives, but it is not OK to not know what the alternatives (such as
design choices) are.

For example, in this thread there were some posts about "intrusive" an
"non-intrusive" containers. Well that is one design parameter and the
perpetrator of the design must tell why he chose one over the other or chose
to offer both. All the paths that the alternatives give must be examined and
final choices documented with the reasoning behind the choices made given.
(I'm not going to rewrite that sentence -- write a parser if it is
"obtuse" -- lol!).
 
A

Ansel

jacob navia said:
Le 29/07/12 19:27, Alan Curry a écrit :

So, you propose that the standard accepts something hat has "major
problems" as you say just because it is used in GTK+ ?


What is the logic behin d that? I do not see any.



Microsoft has abandonned any development in C or C++ since the adoption
of the C# language.

You are a year or two behind the change of direction in that regard. C++
seems to be prime path these days at MS -- but I'm not an insider, I just
get that impression from the external info they release, and I don't even
hardly keep up with such things diligently. Where have you been?

Insiders (and others), please correct me if my impression about that is
wrong.
Even Visual Basic now runs in the virtual .net
machine, as do many other languages that are just different language
front ends for the .net VM.

..net is on another level. Languages are still the foundation for "real"
software product. .net is there for those who want high-level APIs that can
deliver product on Windows fast. (Noted and granted that a company's product
built on top of .net may be more of a toll-stop entry onto the Windows
highway than a "real" software product).
Of course there isn't any official announcement of this but you can
see where the Microsoft emphasis is just by reading between the lines

You seem to be living in the past? It was obvious to even the casual
observer that C# was a prime path at MS for awhile. They even tried to
bastardize C++ by introducing C++/CLI at the time. Now if that isn't a
bastard of a name, nothing is (!): "Oh yes, and have you met our son? His
name is C++ (/CLI). Yes, half human, and 10% artificiality. (Don't ask about
the rest -- you *don't* want to know).

C# started out as a competitive response to java. C# has merits. I defy any
C++ programmer (I cannot say C programmer, but it may be so too) to examine,
to some thorough degree, C# and *not* come away a better programmer. I am
pointing at those C/C++ programmers that don't really use or eval other
languages much. Then again, it could likely be that examining C# cured some
of my deficiencies in understanding about certain topics and others don't
have those or any deficiencies. It is worth a look, IMO. On that note, it
would be much worth a look at the container architecture if one was creating
such a thing.

Again, I'm not an insider and spurt out what I think I know based upon what
I read and hear -- and I'm hardly up with current events either, but Jacob
seems to be too far removed and needs to "read the paper" a bit IMO.

I *encourage* factual correction, for then my brain gets reprogrammed with
current data. Yes, I am a cyborg.
There isn't any new versions of the SDK since several years now,

What do you care? You are a C programmer and compete directly with MS and
..net. You're not Johnny or Jainie pointing-and-clicking their ways to
software production nirvana. Get a bit more lax, though, and they may do
just that! (Ref: the movie with Sly Stallone as the thawed-out cop in the
future world where Taco Bell is then "Fine Dining").
the
developments of the C++ wrappers for the windows API has ceased, and
in general Microsoft is going in the direction of "managed" C++ if
at all.

"Hello". What year is this please? Someone post that info so that I can know
whether I am insane or Jacob is asleep.
So, from that side there isn't anything.

"So", via your decree? I am sceptical now. I was proceeding as if you did
not have a "white paper" about your CCL, and was expecting you to "shut me
up" with: "dude, the white paper is available at <link>". You have on gun
and holster, but no bullets? Duel in October you said -- you better learn to
shoot fast and straight before then, because it's the real thing and the
talk is about to end. You're not thinking about backing out and waiting for
next committee meeting which would require more bits to convey the date, are
you? Need more time? You got two months -- use them. I suggest you create
the white paper and pander it around the guru circles and let them tear up
each detail. In private.
You're not developing a product, don't need NDA, and that makes it waaay
easier. People who like words, love the challenge of crosswords. Guru
developers, love evaluating code, for it expands their knowledge
synergistically. Then there are architects and designers, most of who
couldn't program their way out of a subway and wouldn't care to, and your
CCL is what they do and it behooves you to get their input. God bless those
who can work for a paycheck.
 
A

Ansel

Nick said:
the term "language lawyer" is a metaphor.

Do tell: explain please.
The standard is intended to
supply an unambiguous defintion of the language.

You mean, like the Unicode specification does? And the USA laws do? You
kinda lost me on "intent". Please expound.
 
J

jacob navia

Le 30/07/12 01:41, Rui Maciel a écrit :
jacob said:
You gdon't glike ghaving gall gyour gvariables gprexfed gwith g?

The pthreads API prefixes all its symbols with pthread_,[1] and that didn't
stopped it from being made an interantional standard or becoming widely
adopted.


So, did they invent "pthread_int" and "pthread_char" ???

What is funny in the glib is the desire to go to the most ridiculous
extremes.

 
N

Nick Keighley

Do tell: explain please.

um. "Language Lawyers" aren't actually lawyers. Checkout "The Jargon
File" if
memory serves me right (I'm blocked from "Hacking Sites"!). LL was I
believe coined
whilst Algol was being defined to describe the incredible pedantic nit
pickers.
No actual lawyers.

I reiterate. I find the C Standard a model of clarity. Show me a
language with an
informal defintion and I'll show you a mess.
You mean, like the Unicode specification does?

I was talking about the C standard. Ok its not perfect. What is?

Oh, and what's the problem with Unicode?
And the USA laws do?

legislation isn't a computer language defintion. You seem very
confused.
Legislation is a *hard* problem. Filled with necessary weasel words
like "intent".
If I "intended" to kill someone I may face far more serious
consequences than
if I killed soemone by accident or negligence.
You kinda lost me on "intent". Please expound.

they meant, to the best of their ability, to unambiguously define the
C
programming language. What else would they be doing? How many people
have
gone to court based on the C Lanaguage Standard?

bizzare...
 
N

Nick Keighley

it does actually. It has several.
That doesn't make a lot of sense.

because it's nonsense. If he means it is common to use naming
conventions
to distinguish namespaces in C, then this was common in plenty of
other
languages.
 
N

Nick Keighley

I still think you should develop a professional-level white paper to show
how serious you are.

you seem to have a bit of idee fixe about white papers...
 
J

Jorgen Grahn

Oh? Apparently you have motive.

"-- Let's see ... Mr Thompson had a motive to invent namespaces, *and*
he had access to a wood-chipper. We also found stack traces from
November 1980 in his car. Unfortunately, he has an alibi for that
night."

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top