The C Containers Library

J

jacob navia

Le 30/07/12 06:52, Ansel a écrit :
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.

Thanks Ansel. I think most of the questions that you mention are in the
introduction of the documentation. I will expand that further to
explain the design criteria used in the building of the library

Thanks for your input
 
L

lawrence.jones

jacob navia said:
I am saving money but this will cost me about US$ 2000 in air plane
tickets, hotel costs, etc. I plan to stay only for a few days but even
with that it will very expensive...

Indeed. Have you taked to the Convenor? In the past, we've had
teleconference facilities available, which could be a less expensive
alternative.
 
K

Keith Thompson

Ansel said:
Oh? Apparently you have motive.

What are you talking about?

No C did not invent C++ namespaces. The C standard does use
the phrase "name space", but it doesn't refer to the same thing.
C does not have user-defined namespaces (apart from the kludge of
using consistent prefixes in identifiers).

And I honestly have no idea what you mean by "Apparently you have
motive".
 
K

Keith Thompson

Nick Keighley said:
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.

Nick, if this layout is a response to my "A plea for short lines
in posts here", ragged lines like this are even harder to read than
overly long lines. Compare to this:
 
M

Malcolm McLean

בת×ריך ×™×•× ×©×‘×ª,28 ביולי 2012 17:23:47 UTC+1, מ×ת Ben Bacarisse:
Malcolm McLean said:
But actually the result was the reverse. I think it was because STL
made the syntax for just declaring an array and stepping through it
too cumbersome.


What's so cumbersome? For example:


vector<int> ia = {1, 2, 3, 4, 5, 6, 7, 8};

for (int i = 0; i < ia.size(); i++)

cout << ia << "\n";



The C version is *more* cumbersome in my option.

Toy examples never show up C++'s problems. Language designers aren't totally
stupid, and everything in C++ has some sort of point. However what you often
find is that it only works if all the surrounding code is C primitives.

In fact the code will end up like this


template <class numeric, class output>
void printintegers(output &out)
{
vector<numeric> ia;
for(int i = 1; i < 9; i++)
ia.pushback( numeric(i) );
for(int i =0; i< ia.size(); i++)
out << ia;
}

Preconditions: output must be a writable class which overloads the << operator
with numericals castable to a string using the (String) operator. numeric must
be a type which accepts an integer as a constructor.

You need code to dance around the type system and to carefully document
everything, because it's just possible to get every numeric to work with
every writabble stream, but only just.
 
M

Melzzzzz

On Sat, 28 Jul 2012 06:51:24 -0700 (PDT)
Malcolm McLean said:
When STL first came out I thought that maybe it was the end of C. The
STL containers did provide runtime performance and encapsulation that
you had to handtune C to match. But actually the result was the
reverse. I think it was because STL made the syntax for just
declaring an array and stepping through it too cumbersome. That was
the point at whcih people stopped switching from C to C++, and
started moving from C++ to other languages.

Well try Java containers than ;) that is awful IMO...
STL is not that cumbersome. Do you mind to provide some
example?

C++ had a huge user base
behind it and is still a popular language. But ever since STL it's
been in decline. I'm current programming under Qt. However I've
deliberately written all the non-GUI elements of the program in C.

Heh. Here comes logical question, why not Gtk since it is C?
Qt is great for C++, but I prefer Gtk somehow if I could
choose for new project, even Im C++ programmer mainly.
Even the C++ elements aren't really C++, because Qt preprocesses them
to make the signals and slots mechanism work. C++ doesn't provide the
flexiblity to do this natively.

Of course does it provide. gtkmm (C++ wrapper around Gtk) uses libsigc++
http://libsigc.sourceforge.net/
When I wrote some application for Qt , first thing I did was to
replace Qt's signal slot with my own lib and that was around 2000.
 
M

Melzzzzz

בת×ריך ×™×•× ×©×‘×ª, 28 ביולי 2012 17:23:47 UTC+1, מ×ת Ben Bacarisse:
Malcolm McLean said:
But actually the result was the reverse. I think it was because
STL made the syntax for just declaring an array and stepping
through it too cumbersome.


What's so cumbersome? For example:


vector<int> ia = {1, 2, 3, 4, 5, 6, 7, 8};

for (int i = 0; i < ia.size(); i++)

cout << ia << "\n";



The C version is *more* cumbersome in my option.

Toy examples never show up C++'s problems. Language designers aren't
totally stupid, and everything in C++ has some sort of point. However
what you often find is that it only works if all the surrounding code
is C primitives.

In fact the code will end up like this


template <class numeric, class output>
void printintegers(output &out)
{
vector<numeric> ia;
for(int i = 1; i < 9; i++)
ia.pushback( numeric(i) );
for(int i =0; i< ia.size(); i++)
out << ia;
}


Following is compilable, working code:

#include <iostream>
#include <vector>
#include <algorithm>

template <class numeric>
void printintegers(std::eek:stream &out)
{
std::vector<numeric> ia = {1,2,3,4,5,6,7,8};
for(auto i : ia)
out << i <<" ";
out<<'\n';
std::for_each(ia.begin(),ia.end(),[&out](numeric& n){out<<n<<" ";});
out<<'\n';
}

struct Int{
int i;
Int(int i):i(i){}
friend std::eek:stream& operator<<(std::eek:stream& os, Int& i)
{
os << i.i;
return os;
}
};

int main()
{
printintegers<Int>(std::cout);
}

Preconditions: output must be a writable class which overloads the <<
operator with numericals castable to a string using the (String)
operator. numeric must be a type which accepts an integer as a
constructor.
Done.


You need code to dance around the type system and to carefully
document everything, because it's just possible to get every numeric
to work with every writabble stream, but only just.

Why? We have ostream class for that?
 
R

Rui Maciel

Malcolm said:
When STL first came out I thought that maybe it was the end of C. The STL
containers did provide runtime performance and encapsulation that you had
to handtune C to match. But actually the result was the reverse. I think
it was because STL made the syntax for just declaring an array and
stepping through it too cumbersome.

Could you provide an example where you demonstrate how declaring an array
and iterating through it is "too cumbersome"?

That was the point at whcih people
stopped switching from C to C++, and started moving from C++ to other
languages.

Is it a personal opinion or is there any basis for that assertion?

C++ had a huge user base behind it and is still a popular
language. But ever since STL it's been in decline.

The only time I ever heard of any real world complain regarding the STL was
from people involved in game programming, whose complaints were somewhere
between worries that some STL implementations might have efficiency issues
and ignorance on the programmer's behalf.[1] Other than this, I believe you
will be hard-pressed to find a C++ programmer who doesn't employ the STl in
his code.

I'm current programming
under Qt. However I've deliberately written all the non-GUI elements of
the program in C. Even the C++ elements aren't really C++, because Qt
preprocesses them to make the signals and slots mechanism work. C++
doesn't provide the flexiblity to do this natively.

Qt's signals and slots mechanismo is a particular implementation of the
observer pattern, and one which is notoriously inefficient and with a
particular ability of sweeping serious problems under the proverbial rug.

The only reason Qt relies on preprocessing tricks is basically for syntactic
sugar purposes,[2] not any lack of flexibility C++ might have. Meanwhile,
there are plenty of stand-alone implementations of the observer pattern
floating around that manage to do a better job, such as libsigc++.[3] So, I
believe it is safe to say that C++ does provide more than enough flexibility
to handle signals and slots natively. After all, if it didn't then Qt
wouldn't support them.


Rui Maciel

[1] http://software.intel.com/en-us/articles/extending-stl-for-games/
[2] http://doc.qt.nokia.com/4.7-snapshot/moc.html
[3] http://libsigc.sourceforge.net/
 
J

jacob navia

Le 31/07/12 01:53, Rui Maciel a écrit :
Qt's signals and slots mechanismo is a particular implementation of the
observer pattern, and one which is notoriously inefficient and with a
particular ability of sweeping serious problems under the proverbial rug.

The CCL proposes also an observer interface. I have relied on the design
of the observer interface from Apple's API.
The only reason Qt relies on preprocessing tricks is basically for syntactic
sugar purposes,[2] not any lack of flexibility C++ might have.

Actually, the STL doesn't offer observer interfaces. I think that is not
a good idea.
 
P

Phil Bradby

jacob said:
Le 28/07/12 23:46, (e-mail address removed) a écrit :

I am saving money but this will cost me about US$ 2000 in air plane
tickets, hotel costs, etc. I plan to stay only for a few days but even
with that it will very expensive...

That doesn't sound particularly expensive. Unless you're a college
student or something, $2000 isn't going to break the bank. Just put it on
expenses.
 
J

jacob navia

Le 01/08/12 23:00, Phil Bradby a écrit :
That doesn't sound particularly expensive. Unless you're a college
student or something, $2000 isn't going to break the bank. Just put it on
expenses.

Expenses of who?

Look, everything is a matter of perspective. For me, it is hard to spend
US$ 2000. Customers aren't easy to find nowadays. But I will manage.

jacob
 
N

Nick Keighley

That doesn't sound particularly expensive. Unless you're a college
student or something, $2000 isn't going to break the bank. Just put it on
expenses.

wow. who do you work for? the government?
 
A

Ansel

Nick said:
you seem to have a bit of idee fixe about white papers...

I was trying to bring out the difference between an objective study and a
brochure. The latter plays to a product's "spiel" and downplays other
ligitimate concerns about it in attempt to cover up the shortcomings. You
asked about the Unicode spec -- well I find the book about it more of a
brochure than an objective analysis of the design choices. Though I find a
lot of white papers overly detailed, I do find them to be objective -- but
I'm talking about the scholarly ones.

In the case of JN's container library, I hope he won't just "high-level,
gloss-over" the design issues and background information (i.e., history of
and issues in container development), for I believe that will be key in
having a good story to tell.
 
A

Ansel

Nick said:
it does actually. It has several.


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.

But we are talking about the C-to-C++ evolution. C++ automated and
abstracted-away the decorative naming conventions used by C programmers as a
technique, into a some keywords. To say that C++ invented anything new would
be overstating it.
 
A

Ansel

Nick said:
Oh, and what's the problem with Unicode?

What *isn't* the problem with Unicode?! Like most one-size-fits-all things,
it's a severe compromise almost everywhere you use it. All kinds of
metaphors apply -- like using an 18-wheeler to run errands around town and
go grocery shopping. One thing you can definitely say about Unicode -- it's
BIG!
 
J

James Kuyper

it does actually. It has several.

No, what C has are name spaces, a somewhat different concept than
namespaces. C++ has them too, but fewer (and correspondingly less
significant) than C's name spaces.
 
J

James Kuyper

But we are talking about the C-to-C++ evolution. C++ automated and
abstracted-away the decorative naming conventions used by C programmers as a
technique, into a some keywords. To say that C++ invented anything new would
be overstating it.

C programmers didn't invent that technique; it long pre-dates C. C++ did
invent the keywords, special syntax, and the rules associated with those
keywords and syntax. To say that "C invented C++ namespaces" is nonsense
because "C++ namespaces" refers very specifically to those keywords,
that syntax, and the associated rules. It is not a term that can be
loosely extended to cover the naming conventions that were used in other
languages to achieve the same goal.

What you're saying is roughly comparable to denying the significance of
the invention of the prefix ++ operator, by pointing out that it's just
equivalent to i = i + 1. There's no denying the equivalence, but
recognizing that fact doesn't reduce the significance of the invention.
 
J

James Kuyper

wow. who do you work for? the government?

If he worked for the government, he would have called $2000 pocket
change. :)

A private business for which $2000 is a major expense that threatens
it's liquidity isn't doing very well; the owner should seriously
consider liquidating the company and try doing something else to earn a
living.
 
J

jacob navia

Le 02/08/12 13:00, James Kuyper a écrit :
If he worked for the government, he would have called $2000 pocket
change. :)

A private business for which $2000 is a major expense that threatens
it's liquidity isn't doing very well; the owner should seriously
consider liquidating the company and try doing something else to earn a
living.

The average wage in the U.S. is 39 959 US$/year, i.e around 3 329 US$ a
month.[1]

For people that earn much more, the effort that you must do to have US$
2000 to spare looks ridiculous, mainly because they have never been in
a situation where they have to think about money.

I understand that Mr Kuyper, that never misses an opportunity to
downgrade what I am doing, would love that I "try doing something else",
but that is not going to happen.

jacob

[1] The social security site: http://www.ssa.gov/oact/cola/central.html
Look at the line for 2010 (last available)
 

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
474,079
Messages
2,570,574
Members
47,205
Latest member
ElwoodDurh

Latest Threads

Top