GLib
Encyclopedia
GLib is a cross-platform software utility library that began as part of the GTK+
project. However, before releasing version 2 of GTK+, the project's developers decided to separate non-GUI
-specific code from the GTK+ platform, thus creating GLib as a separate product. GLib was released as a separate library so other developers, those that did not make use of the GUI-related portions of GTK+, could make use of the non-GUI portions of the library without the overhead of depending on a full-blown GUI library.
Since GLib is a cross-platform library, applications using it to interface with the operating system are usually portable across different operating systems without major changes.
s, hash table
s, dynamic strings
and string utilities, such as a lexical
scanner, string chunks (groups of strings), dynamic arrays, balanced binary tree
s, N-ary trees
, quarks (a two-way association of a string and a unique integer identifier), keyed data lists, relations and tuple
s. Caches
provide memory management.
GLib implements functions that provide thread
s, thread programming and related facilities such as primitive variable access, mutex
es, asynchronous queues, secure memory pool
s, message passing
and logging, hook functions (callback registering) and timers. Also message passing facilities such as byte order conversion
and I/O channels.
Some other features of GLib include:
(see GObject
for a detailed comparison).
The Apache Portable Runtime
has a large functional overlap with GLib, and provides many similar OS-portable threading, network and data structure implementations in C.
Other widget toolkit
s usually also provide low-level functions and implementations of data structures. For instance, in the wxWidgets
library the non-GUI functions are in the wxBase library, and in Qt the non-GUI parts are in the QtCore module, which is written in C++.
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...
project. However, before releasing version 2 of GTK+, the project's developers decided to separate non-GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...
-specific code from the GTK+ platform, thus creating GLib as a separate product. GLib was released as a separate library so other developers, those that did not make use of the GUI-related portions of GTK+, could make use of the non-GUI portions of the library without the overhead of depending on a full-blown GUI library.
Since GLib is a cross-platform library, applications using it to interface with the operating system are usually portable across different operating systems without major changes.
Features
GLib provides advanced data structures, such as memory chunks, doubly and singly linked listLinked list
In computer science, a linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference to the next node in the sequence; more complex variants add additional links...
s, hash table
Hash table
In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys , to their associated values . Thus, a hash table implements an associative array...
s, dynamic strings
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....
and string utilities, such as a lexical
Lexical analysis
In computer science, lexical analysis is the process of converting a sequence of characters into a sequence of tokens. A program or function which performs lexical analysis is called a lexical analyzer, lexer or scanner...
scanner, string chunks (groups of strings), dynamic arrays, balanced binary tree
Binary tree
In computer science, a binary tree is a tree data structure in which each node has at most two child nodes, usually distinguished as "left" and "right". Nodes with children are parent nodes, and child nodes may contain references to their parents. Outside the tree, there is often a reference to...
s, N-ary trees
K-ary tree
In graph theory, a k-ary tree is a rooted tree in which each node has no more than k children. It is also sometimes known as a k-way tree, an N-ary tree, or an M-ary tree.A binary tree is the special case where k=2....
, quarks (a two-way association of a string and a unique integer identifier), keyed data lists, relations and tuple
Tuple
In mathematics and computer science, a tuple is an ordered list of elements. In set theory, an n-tuple is a sequence of n elements, where n is a positive integer. There is also one 0-tuple, an empty sequence. An n-tuple is defined inductively using the construction of an ordered pair...
s. Caches
Cache algorithms
In computing, cache algorithms are optimizing instructions – algorithms – that a computer program or a hardware-maintained structure can follow to manage a cache of information stored on the computer...
provide memory management.
GLib implements functions that provide thread
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
s, thread programming and related facilities such as primitive variable access, mutex
Mutual exclusion
Mutual exclusion algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections. A critical section is a piece of code in which a process or thread accesses a common resource...
es, asynchronous queues, secure memory pool
Memory pool
Memory pools, also called fixed-size-blocks allocation, allow dynamic memory allocation comparable to malloc or C++'s operator new. As those implementations suffer from fragmentation because of variable block sizes, it can be impossible to use them in a real time system due to performance...
s, message passing
Message passing
Message passing in computer science is a form of communication used in parallel computing, object-oriented programming, and interprocess communication. In this model, processes or objects can send and receive messages to other processes...
and logging, hook functions (callback registering) and timers. Also message passing facilities such as byte order conversion
Endianness
In computing, the term endian or endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item as stored in external memory . Each sub-component in the representation has a unique degree of significance, like the place value of digits...
and I/O channels.
Some other features of GLib include:
- standard macros
- warnings and assertions
- dynamic loading of modules
- a type system, GType
- an object system, GObjectGObjectThe GLib Object System, or GObject, is a free software library providing a portable object system and transparent cross-language interoperability...
Similar projects
For many applications, C with GLib is an alternative to C++ with STLStandard Template Library
The Standard Template Library is a C++ software library which later evolved into the C++ Standard Library. It provides four components called algorithms, containers, functors, and iterators. More specifically, the C++ Standard Library is based on the STL published by SGI. Both include some...
(see GObject
GObject
The GLib Object System, or GObject, is a free software library providing a portable object system and transparent cross-language interoperability...
for a detailed comparison).
The Apache Portable Runtime
Apache Portable Runtime
The Apache Portable Runtime is a supporting library for the Apache web server. It provides a set of APIs that map to the underlying operating system . Where the OS doesn't support a particular function, APR will provide an emulation...
has a large functional overlap with GLib, and provides many similar OS-portable threading, network and data structure implementations in C.
Other widget toolkit
Widget toolkit
In computing, a widget toolkit, widget library, or GUI toolkit is a set of widgets for use in designing applications with graphical user interfaces...
s usually also provide low-level functions and implementations of data structures. For instance, in the wxWidgets
WxWidgets
wxWidgets is a widget toolkit for creating graphical user interfaces for cross-platform applications. wxWidgets enables a program's GUI code to compile and run on several computer platforms with minimal or no code changes...
library the non-GUI functions are in the wxBase library, and in Qt the non-GUI parts are in the QtCore module, which is written in C++.
Components
GLib package consists of 5 libraries:- GObjectGObjectThe GLib Object System, or GObject, is a free software library providing a portable object system and transparent cross-language interoperability...
- Glib
- GModule
- GThread
- GIOGIO (Gnome)GIO provides a modern, easy-to-use VFS API that sits at the right level in the library stack. The goal is to overcome the shortcomings of GnomeVFS and provide an API that is so good that developers prefer it over raw POSIX calls. It ships with GLib as a separate library called libgio-2.0...