At early 2022, I used glib(2.66.x) for about 3 months for project run on OpenEmbedded Linux. Based on my short(3 months) experience, I would like review it. I mostly used gio and gdbus of glib. So, this review focus on those features.

Pros

  • It seems that glib is very popular. However, I am not sure gio and gdbus are also as popular as glib.
  • It has large set of features.
  • It is easy to use in both C and C++.
  • It supports multi-platform(Linux, Windows and so on).

Cons

  • Lack of document. It was not easy for me to find useful documents and examples. Again, it's just my opinion. I think it may be caused from frequent changes of API.
  • Some APIs doesn't give any response of error to caller. That is there is no way for caller to detect error happened inside API.
    • For instance, g_thread_pool_push() prints some error messages to stderr but doesn't return any error values to caller. I think it's because many APIs of glib provides very high-level functionality and use various techniques to improve performance and resource usage like memory pool, async operations and so on. However, it's very critical that there is no programmatic way for caller to detect error of API. I think it may be very critical defect when developers consider using glib at project requiring high-level stability like system daemon.
  • Behavior of Linux file descriptor seems not intuitive to me. One of reasons may be glib provides unified API for multi-platform. For instance, in case of giving and taking file descriptor via GDBus, even if receiver receives only one file descriptor, sometimes, two new open file descriptors are created.
    • When using org.freedesktop.login1.Manager.Inhibit, even if only one file descriptor is passed via GD-Bus, two new file descriptor are created at /proc/<pid>/fd. So, even if FD(File Descriptor) passed via GD-Bus is closed, due to another open FD, inhibitor cannot be closed.
    • Same scinario work well as expected if sd-bus is used instead of GD-Bus.

Summary

After winning over lack of document and get used to it, it looks very powerful and useful library. However, as mentioned above, due to some APIs that don't give error response, it's usablity may be limitted at domain asking very high-level stability.

'Development' 카테고리의 다른 글

Comparing build outputs  (0) 2019.11.14
[Remind] Array vs Set.  (0) 2019.05.03
[Dev] Software developement process...  (0) 2010.01.13
[Dev] Sharing between members and leader...  (0) 2009.12.04
[Dev] Key point to succeed in large project...  (0) 2009.08.01

+ Recent posts