16 Responses

  1. Tim Harig
    Tim Harig at |

    The same might be said for the apache portable runtime.

  2. Erik
    Erik at |

    If there is no need to implement custom helper functions, there is actually no need program in C. In that case, you can use the one or the other scripting language, that will internally use the boilerplate algorithms.

    The very purpose of taking on the cost of programming in C, is to implement specific helper mechanisms that will speed up things for that particular kind of application.

    But then again, the source code for a library such as GLib is definitely a very good source of inspiration, when rolling your own helper mechanisms in C.

  3. Ebrahim
    Ebrahim at |

    Do you know stdint.h?

  4. RaineF
    RaineF at |

    Any possibility that GLib has lock-free data structures?

  5. buh
    buh at |

    what’s an “helper mechanism” ?

  6. paines
    paines at |

    Glib is a good example for a widely used OSS lib.
    What I don’t understand about it, is that it leaks memory and no one doesn’t seem to care about it. You can check and proove that with tools like Duma, Dmalloc, Valgrind etc.
    e.g. you have to call g_type_init() which will set up Signal / Slot mechanism and allocate memory here and there. It has no counter part, like glib_deinit or glib_shutdown.
    Same applies for DBus, which is even much more apreciated in the OSS world.
    Besides those leaks that Libs are really power- and usefull. Hopefully one day the developers will investigate for those leaks.


  7. marcin
    marcin at |

    Beside portability, utility functions and data structures there’s yet another killer feature I love: glib’s main loop. It gives all you need: timers, file descriptor and child watches, idlers and possibility of plugging custom watches into main loop. Good both for gui and service daemons.

  8. mb
    mb at |


    What would be the use of a glib_shutdown? The type systems is
    supposed to run as long as the program runs. It doesn’t make
    sense to shut down the type system unless the process is going
    to terminate anyway.

  9. Ed Davis
    Ed Davis at |

    How portable is this to Windows? A quick look at the documentation, and it does not tell how to build or compile applications for it on Windows.

  10. Anon
    Anon at |

    and note: most of those memory leaks
    are a part of your own ignorance
    if you knew how glib operated, you’d know that
    they aren’t mempry leaks …
    any memory leaks you find are most likely going to be from your own code

  11. romat
    romat at |

    hi there
    i’d like to learn how to programm (java/c/c++/mysql- which ever easy to start and similar)
    the thing is i have no clue where to start im windows user 32bit, if there any one who kindly give me instruction step by step i’d appreceate it

  12. paines
    paines at |

    @mb: That is correct. Anyway I think, it isn’t good programming style to leave it to the OS to cleanup after you.

  13. Recent Links Tagged With "datastructures" - JabberTags

    […] and how does it work? Video of cards sorted by… Saved by seundlibrary on Fri 12-12-2008 Want To Program Smartly In C? Use GLib Saved by gregoirechollet on Wed 10-12-2008 Linked lists in the linux kernel Saved by xaragay on […]

  14. anon
    anon at |

    I would recommend you start with Java. Learning to program takes a lot of _individual_ time and effort. It’s not something others can teach you. Start here: http://java.sun.com/docs/books/tutorial/ There is a getting started link.

  15. anon
    anon at |

    It’s not leaving the OS to clean up after you. When the program ends, the memory is de-allocated. I’m not sure you understand how the typing system works.

  16. Erik
    Erik at |

    Something like a hashtable (associative array) or an arraylist (array without fixed bounds), are typically helper mechanisms. You can write many of your algorithms in terms of hashtables and arraylists. But then again, a specialized implementation for the particular problem at hand can speed up the program. It is, however, rarely worth it. With 200 KB of extra overhead, you already have a fast scripting engine like lua or javascript; which has efficient implementations for most commonly used helper mechanisms. Write the code in scripting, and stuff your code and the engine all in one self-contained executable. Nobody will know that you used lua or javascript instead of C 🙂

Comments are closed.