Jump to content

  • Log In with Google      Sign In   
  • Create Account


stl for C ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 Tylon   Members   -  Reputation: 181

Like
0Likes
Like

Posted 31 January 2005 - 09:24 PM

Is there a C equivalent of the STL for C++? I know there wont be an exact equivalent, coz the STL is part of the C++ standard, but is there a stable, accepted library that the community mostly uses? The features I am interested are things like array lists, linked lists, hash tables etc. Thanks!

Sponsor:

#2 sakky   Banned   -  Reputation: 100

Like
0Likes
Like

Posted 31 January 2005 - 10:46 PM

Did you just ask if C supported C++ classes?

#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 31 January 2005 - 10:55 PM

Glib (http://www.gtk.org) has all of that, and more. It's still tedious to use, mainly because you'll have to do a lot of (unsafe) casting. It's probably better than rolling your own though (more generic). Its a LGPL library.

Hope this helps.


#4 ToohrVyk   Members   -  Reputation: 1587

Like
0Likes
Like

Posted 31 January 2005 - 10:58 PM

sakky: classes don't have anything to do with libraries. Most languages do have libraries that do not use classes in the C++ sense (and, for instance, O'Caml has a standard library that is approximately as powerful as the STL, but uses no classes in it).

Tylon: while I do not doubt the existence of such libraries, they will certainly be awkward to use because of frequent type casting (as C is lacking universal polymorphism). I do not know of any, personnally. At the risk of sounding a C++ zealot, may I inquire why you must use C only (and not C++) ?

#5 Emmanuel Deloget   Members   -  Reputation: 1381

Like
0Likes
Like

Posted 31 January 2005 - 11:01 PM

glib, from the GTK+ project, is rather good.

(edit: toooooooo laaaaaaate...)

#6 Melekor   Members   -  Reputation: 379

Like
1Likes
Like

Posted 01 February 2005 - 06:46 PM

Did you know GLIB has a function called g_blow_chunks()? True Story.

#7 Instruo   Members   -  Reputation: 373

Like
-1Likes
Like

Posted 01 February 2005 - 06:59 PM

Quote:

At the risk of sounding a C++ zealot...


what's wrong with being a C++ zealot? OOP, once understood, makes life so clean and simple ;)

#8 Telastyn   Crossbones+   -  Reputation: 3718

Like
0Likes
Like

Posted 01 February 2005 - 07:51 PM

Quote:
Original post by Instruo
Quote:

At the risk of sounding a C++ zealot...


what's wrong with being a C++ zealot? OOP, once understood, makes life so clean and simple ;)


"once understood" being the key words of course. In the mean time, you get to try and avoid undefined behavior, design pitfalls, and the ever-common vague technical reference.

Not to say that C doesn't have it's own minefields, but C++/OOP isn't the panacea most make it out to be.

#9 Instruo   Members   -  Reputation: 373

Like
-1Likes
Like

Posted 01 February 2005 - 07:52 PM

maybe you just don't understand it very well :D

#10 ToohrVyk   Members   -  Reputation: 1587

Like
1Likes
Like

Posted 01 February 2005 - 09:26 PM

Quote:
what's wrong with being a C++ zealot? OOP, once understood, makes life so clean and simple ;)


C++ is a language, OOP is a programming paradigm. C++ happens to natively implement a (limited) version of OOP, but this is the only relationship between the two. OOP does not require fancy "class" keywords in the language to be used, it only requires the existence of a linking step (and I'm not even sure THAT is required). You can do OOP with any language, including C, so it's not legitimate to use OOP as a justification for using C++

#11 LessBread   Moderators   -  Reputation: 1411

Like
0Likes
Like

Posted 01 February 2005 - 09:45 PM

Here's a previous post about "templates" in old-school C. I dropped some code that implements a template styled vector data structure at the bottom.

#12 Zahlman   Moderators   -  Reputation: 1682

Like
0Likes
Like

Posted 02 February 2005 - 12:05 AM

Quote:
Original post by Instruo
Quote:

At the risk of sounding a C++ zealot...


what's wrong with being a C++ zealot? OOP, once understood, makes life so clean and simple ;)


At the risk of sounding like a Java (or Smalltalk, or any of a gazillion other languages for that matter) zealot: How is that an argument for C++? [smile]

#13 Instruo   Members   -  Reputation: 373

Like
0Likes
Like

Posted 02 February 2005 - 09:33 AM

I actually prefer C#, personally, I was just joking around. I do think that OOP is generally the better way to go, and I think that C is somewhat outdated and is just making things harder than they need to be for... what? Some principle or something that I don't see, I suppose. (And don't tell me 'performance', because most applications don't begin to scratch the surface of what modern hardware can do). Anyway, enough of that rant ;)

#14 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 02 February 2005 - 10:45 AM

Quote:
Original post by Instruo
I actually prefer C#, personally, I was just joking around. I do think that OOP is generally the better way to go, and I think that C is somewhat outdated and is just making things harder than they need to be for... what? Some principle or something that I don't see, I suppose. (And don't tell me 'performance', because most applications don't begin to scratch the surface of what modern hardware can do). Anyway, enough of that rant ;)


C is still the most portable and interoperable language. Nearly every language has C bindings; rarely do you find bindings to other languages. C has sweet simplicity on its side for those who prefer the OOP of CLOS or Smalltalk (dare I even venture to realms outside OOP? Functional programming? Haskell? Scheme? OCaml!?! Heresy!) but have some need to drop to a lower level (speed, foreign libraries, etc.).

Note I'm saying C is better than anything else, just that it has its place. It's quick and dirty for when you need to deal with the nitty gritty under higher level languages.

As for the original question, there aren't many libraries of that sort for C. As mentioned, glib is a good place to look. But why wouldn't C programmers have such a library? Two reasons:

1) They do, it's just a home brew. Back in the day, there was less focus on libraries and so people had to cook up their own. These are perfectly suited to the needs they had, so why would they use some third party library? (If it ain't broke...)

2) As I said, C is an "under the hood" sort of language. (C++ is more like a car without a hood! [lol] Ha! haha... you know I'm funny! err... now you know why I'm anonymous [cool]) General purpose libraries aren't fine tuned for specific purposes. But if you're using C, it's usually because you need something fine tuned for specific purposes.

#15 Sagar_Indurkhya   Members   -  Reputation: 253

Like
0Likes
Like

Posted 02 February 2005 - 01:37 PM

I like using C sometimes because of the power I feel.

You know, like when you are a sniper, and wear all this gear, and just sit and watch all day. Than you come home, and battle with samuarai swords. You can literally feel the torque of the handle as you swing it. You can count the cycles like you can your heartbeat.
</end wierd metaphor>

#16 Avinash Dongre   Members   -  Reputation: 100

Like
0Likes
Like

Posted 14 April 2011 - 07:57 AM

Here is the one I have started, Yet to finish , but you can take a look .
http://code.google.com/p/cstl/

#17 Evil Steve   Members   -  Reputation: 1955

Like
0Likes
Like

Posted 14 April 2011 - 08:38 AM

Really? You bumped a 6 year old thread for that?

Steve Macpherson
Senior programmer, Firebrand Games





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS