what do c developers do without the stl?

C

Conrad Weyns

I have recently gone back to doing some work in c, after years of c++, but I
find the lack of templates and in particular the container in the stl to be
a huge show stopper.
There are math libs, plotting libs, graphic libs etc but I what about some
usefull container lib. Any ideas anyone?
regards,
Conrad Weyns
 
W

websnarf

Conrad said:
I have recently gone back to doing some work in c, after years of
c++, but I find the lack of templates and in particular the
container in the stl to be a huge show stopper.
There are math libs, plotting libs, graphic libs etc but I what
about some useful container lib. Any ideas anyone?

Personally, I redo my strings like so:

http://bstring.sf.net/

and I do things like this:

http://www.pobox.com/~qed/ll.zip

to give me functionally very similar (I mean considering my typical
emphasis in data types) to STL. There are other libraries out there
like:

http://www.xref-tech.com/sglib/main.html

which covers even more.
 
J

Jonathan Bartlett

Conrad said:
> There are math libs, plotting libs, graphic libs etc but I what about
> some usefull container lib. Any ideas anyone?

I use GLIB from Gtk+ (you don't need to be doing GUI programming to use
it -- it's perfectly separable from the rest of Gtk+):

http://www.gtk.org/

API Docs: http://developer.gnome.org/doc/API/2.0/glib/index.html

Of course those of us who program in Scheme and Lisp stand in wonder at
how everyone else gets by without a real macro system :)

Jon
 
S

Servé Lau

Conrad Weyns said:
I have recently gone back to doing some work in c, after years of c++, but I
find the lack of templates and in particular the container in the stl to be
a huge show stopper.
There are math libs, plotting libs, graphic libs etc but I what about some
usefull container lib. Any ideas anyone?
regards,
Conrad Weyns

call me crazy, I made my own.

for fun and learning
 
E

E. Robert Tisdale

Conrad said:
I have recently gone back to doing some work in C after years of C++
but I find the lack of templates
and in particular the container in the stl to be a huge show stopper.
There are math libs, plotting libs, graphic libs etc.
but I what about some usefull container lib.
Any ideas anyone?


Yes.
C really needs a standard template library.
Why don't you propose one
and implement a reference library.
You will need preprocessor to convert templates into C code.

Take a look at the cncl/bin/genclass script which is part of
the ANSI C Numerical Class Library (CNCL)

http://www.netwood.net/~edwin/svmtl/
 
C

CBFalconer

online said:
Many thanks, Paul.

I advise extreme caution in using that package. The following is a
quote from Hsiehs own documentation:

"Bstrlib has been tested on the following compilers:

Microsoft Visual C++
Watcom C/C++ (32 bit flat)
Intel's C/C++ compiler (on Windows)
The GNU C/C++ compiler (on Windows/Linux on x86 and PPC64)
Turbo C"

Note that he does not specify the compiler versions, and that
functioning via a particular compiler is much different from
adhering to the ISO C standard.

He has also been known to advocate that ints are always 32 bits, or
that shifting signed quantities is harmless. Meanwhile the string
operations specified by the Standard are guaranteed portable and
available in all hosted systems.
 
M

Marian

Hello everybody,

I am maintaining a simple generic library for C. It is freely
inspired by STL and it uses preprocessor to simulate templates.
The library is available at http://www.xref-tech.com/sglib/
I would like to compose a proposal to our national scientific
grant agency for some funds for this project and I need to
argue that this is a good idea and that (at least some)
community needs it. Looking at this thread, I think that
this is the best place to ask the following questions.

Do you have any ideas, why such library should exists? Are
there some living software projects written in C? Are there
some new projects which will be written in C? Would you use
such library, if available in a professional quality? Which
functionality would you expect from such library?

If you are working on a living C project and you think that
such library would be a good thing, please let me know. This
will help me a lot in composing the grant proposal.

Thanks in advance,

Marian Vittek
 
C

CBFalconer

Marian said:
I am maintaining a simple generic library for C. It is freely
inspired by STL and it uses preprocessor to simulate templates.
The library is available at http://www.xref-tech.com/sglib/
I would like to compose a proposal to our national scientific
grant agency for some funds for this project and I need to
argue that this is a good idea and that (at least some)
community needs it. Looking at this thread, I think that
this is the best place to ask the following questions.

Do you have any ideas, why such library should exists? Are
there some living software projects written in C? Are there
some new projects which will be written in C? Would you use
such library, if available in a professional quality? Which
functionality would you expect from such library?

If you are working on a living C project and you think that
such library would be a good thing, please let me know. This
will help me a lot in composing the grant proposal.

I suspect you want to be taken seriously. You really should have
looked for a better injection site than as a reply to our resident
troll. Maybe that is why you top-posted? If not, bear in mind
that top-posting is considered rude and foolish here.

I suspect that template like things will hide too much to really
get accepted in C. Just look at how typdef is deregoted by many.

At any rate, you have two paths available: A standard macro
pre-processor such as M4, or the C preprocessor. With the C
preprocess you have access to the other C standard headers, with M4
you don't, as they need not exist as files. The C preprocess is
heavily limited as to abilities. M4 won't have access to such
things as INT_MAX.
 
M

Marian

I am perfectly serious. What do you mean by top-posting?

The library uses C preprocessor. It is just a single header
file written in ANSI C defining all algorithms in form of macros.
It is perfectly operational. Originally, I have written in for
myself, then I have put it on the web. It is for free.

I am just asking people here if there is some "real-life" interest in
further works on it. What is wrong with it?

marian
 
G

Gregory Pietsch

Well, if you want C++, you know where to find it.

If you want a useful dynamic array library, just download FreeDOS Edlin
2.4 and marvel at a dynamic array of dynamic string library code.

Gregory Pietsch
 
E

E. Robert Tisdale

Marian said:
I am maintaining a simple generic library for C.
It is freely inspired by STL
and it uses preprocessor to simulate templates.
The library is available at

http://www.xref-tech.com/sglib/

I would like to compose a proposal
to our national scientific grant agency
for some funds for this project
and I need to argue that this is a good idea
and that (at least some) community needs it.
Looking at this thread, I think that
this is the best place to ask the following questions.

Do you have any ideas, why such library should exists?
Are there some living software projects written in C?
Are there some new projects which will be written in C?
Would you use such library, if available in a professional quality?
Which functionality would you expect from such library?

If you are working on a living C project
and you think that such library would be a good thing,
please let me know.
This will help me a lot in composing the grant proposal.

I think that Conrad Weyns was looking for something
that looked like the Standard Template Library (STL)

http://www.sgi.com/tech/stl/


There are lots of problems with an implementation
as C preprocessor macros.
They are hard to read, understand and maintain.

Try using Google to search for answers to your questions above.
I'm sure that you can find ample justification for the STL in C.
Of course, you shouldn't expect it to be any easier
to get C programmers to use the STL than it was
to get C++ programmers to use the STL.
You might want to read something about the history of the STL.
It took a lot of people and a long time to develop the STL
and it took a long time to get it accepted as part of the C++ standard.
They are still trying to get C++ programmers to accept it.
 
M

Marian

E. Robert Tisdale said:
I think that Conrad Weyns was looking for something
that looked like the Standard Template Library (STL)

http://www.sgi.com/tech/stl/

I know.
There are lots of problems with an implementation
as C preprocessor macros.
They are hard to read, understand and maintain.

It does not mean they are so hard to use :) Also
the C preprocessor is stronger than people think.

I have nothing against glib from gtk, however it forces
you to represent, for example, a list of doubles as
a list of pointers to doubles and you need to do casts
from (void *) all the time. From my point of view, the
type checking is a good thing and consequently too many
casts is not a good practice.

A well written generic macro seems to be a better solution.
And of course it is better than writting the same code
again and again all the time.

Marian
 
R

Randy Howard

I am perfectly serious. What do you mean by top-posting?

It translates as "google is the bain of Usenet's existence".
Hint: Use the reply button at the TOP of the page when
using google, instead of the broken one at the bottom.
Also, add you text below, or interleaved with that you
are replying to, as I am doing here.
The library uses C preprocessor. It is just a single header
file written in ANSI C defining all algorithms in form of macros.

Interesting. The problem is, if you use C instead of C++, the
reason is often for something lighter weight than C++, so
if you need STL stuff, people would use C++, and if you don't...
well, there is always C. I'm not sure why tax dollars should
go to reinventing the wheel here, but there is ample precedent
for the government doing that.
It is perfectly operational.

Really? Then why do you need grant money? It's done. :)
Originally, I have written in for
myself, then I have put it on the web. It is for free.

Make it open source, and let the community keep it up. If its
useful, it will basically "maintain itself".
I am just asking people here if there is some "real-life" interest in
further works on it. What is wrong with it?

Put it on slashdot if you want to find out how it plays to a large
audience.
 
R

Randy Howard

Do you have any ideas, why such library should exists?

Not really. If I need the STL, I know where to find one that
has been widely used and tested.
Are there some living software projects written in C?

You must be joking.
Are there some new projects which will be written in C?

Several daily, I'm sure.
Would you use such library, if available in a professional quality?

Probably not, unless you guarantee it will work on about a dozen
different platforms and compilers. Even then, I don't think I
have a need for it. What I'd much rather see is a Grand Unified
Multithreading interface for C, that works regardless of platform.
Have one of those on the back burner?

That's going to be big. Probably could even get some grant money
for it.
 
C

CBFalconer

Marian said:
I am perfectly serious. What do you mean by top-posting?
.... snip ...

You should quote enough from whatever you are replying to to
establish at least context. Each article should stand on its own.
The links below (in my sig) will help. Top-posting means placing
your answer before the quoted material, it should follow it (or be
interspersed) with non-germane matter snipped out.

The google reply system is seriously broken. To have at least a
reasonable chance of generating a sane reply, see below:

"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

--
Some informative links:
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html
 
M

Marian

Randy said:
Interesting. The problem is, if you use C instead of C++, the
reason is often for something lighter weight than C++, so
if you need STL stuff, people would use C++,

There are at least two counterexamples in last two days on
this forum. There are two threads asking for such library in C.
Why they do not simply switch to C++ at this stage of development?
It is probably not as easy as this. C an C++ are two different
languages.

and if you don't...
well, there is always C. I'm not sure why tax dollars should
go to reinventing the wheel here, but there is ample precedent
for the government doing that.


Really? Then why do you need grant money? It's done. :)

I have to pay invoices :)
Make it open source, and let the community keep it up. If its
useful, it will basically "maintain itself".

It's just a header file. It must be open source and it is.
Nothing is maintaining itself. This is just an illusion that
some serious project can evolve without expenses.

Put it on slashdot if you want to find out how it plays to a large
audience.

I am starting here :)

Marian Vittek
 

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,163
Messages
2,570,897
Members
47,434
Latest member
TobiasLoan

Latest Threads

Top