The maemo platform and Symbian OS concepts

The Symbian OS is famous for its design, concepts, and coding conventions. The maemo platform gives the developer more freedom, but it also requires the developer to take more responsibility. The maemo platform does not enforce any specific design patterns, so the developer is responsible for preventing memory leaks, buffer overflows, and other security problems.

C and C++

Software for Symbian OS is mostly written in C++, whereas software for the maemo platform is mostly written in C. There are, however, several C++ bindings available for different libraries in the maemo platform, enabling an object-oriented approach. Despite of these bindings, C library calls must be made in code written for the maemo platform sooner or later.

GLib - object system and utility library

GLib is a cross-platform software utility and object management library. It enables object-oriented programming in C, without C++.

GLib defines many data structures and related operations. Developers may write such structures and operations.

GLib is mentioned here because some of its features are accessible only through C APIs.

Symbian OS essential concepts

Some differences between Symbian C++ and C++ used in maemo are listed below. These differences are more about the conventions, concepts, and software design than about differences in the C++ syntax, language, or compiler features. Some replacements for missing Symbian OS-specific concepts are also introduced.

Naming guidelines
Symbian OS naming conventions are quite strict. Class names are prefixed with either C, M, R, or T, depending on what they are used for. There are also naming rules for member variables, function names, and function parameters. On maemo, the developer is given more freedom and there are no mandatory prefixes in class names. The programming guidelines in maemo wiki state that "Descriptive, lower-case names should be used for variables and functions. Underscores (_) can be used to indicate word boundaries."
Runtime type information (RTTI)
Symbian OS has no support for runtime type information and therefore the dynamic_cast operator is not supported. In maemo, RTTI is available.
Symbian C++ developers are familiar with concepts like 'leaving' and 'trap harness' because standard C++ exceptions did not exist when Symbian OS was originally developed. The C++ exceptions were added to Symbian OS in version 9, but they are not to be used in the code written by users.
In maemo the standard C++ exceptions (try, catch, throw) are available.
Cleanup stack
A Symbian OS-specific concept that is not available in the maemo platform. Similar functionality can be achieved by using an auto_ptr class*. auto_ptr is a smart pointer implementation in C++ Standard Template Library, and it is a good way to prevent memory leaks in case of exceptions.
For more information on using the auto_ptr, see the article Using auto_ptr Effectively.

Class construction

The Symbian OS documentation states that if a class has to allocate memory, it should be derived from CBase. In maemo, there is no such base class*. This design difference causes the following:

Class inheritance
Deriving from CBase limits the inheritance system in such way that multiple inheritance is only possible when using the M-classes. M-classes are just interfaces with abstract functions. In the maemo platform, there is no equivalent for CBase and therefore it is possible to inherit from multiple concrete classes.
Two-phase construction
Since the Symbian OS lacks the real C++ exceptions and the class constructor cannot leave, a two-phase construction idiom with NewL() and ConstructL() methods is used.
Example alternatives:
* GObject is the base class for all GLib and GTK+ objects, but you do not need to inherit their application-specific C++ classes from it.


Descriptors are specific to Symbian OS and they do not exist as such in the maemo platform.

When working with strings, instead of descriptors you can use:

The NULL-terminated character arrays and GStrings are manipulated using C-functions, whereas the STL string is a C++ class.

If you are working with binary data, you can use:

Active Objects and threads

Symbian OS discourages the usage of threads because context switching is considered an expensive operation which degrades battery life. Basically this is true in the maemo platform too, but avoiding threads at all cost is not required.

Using the main event loop of GLib it is possible to run several asynchronous operations in a single thread, without blocking. This is fairly similar to using Active Objects.

You can use the following threads:

No static data in DLLs

While the Symbian OS does not support static data in DLLs, the maemo platform does not have this limitation. You can use, for example, global variables in your shared libraries. Note, however, that the static data is not shared between the processes.

Platform security

Platform security does not exist in the maemo platform. When installing software with the 'Application manager', it only warns if the software is NOT being downloaded from the official maemo repositories. Maemo is a multi-user environment, where different users and user groups have different permissions to access files and platform services. However, when installing a software package, the package developer can freely decide the permissions under which the software runs.

Client/Server model

Whereas Symbian OS extensively uses a client/server approach with asynchronous method calls, the maemo platform uses direct, synchronous API calls. Usually this means that called functions block until they finish, with some exceptions.

Using sockets is a good example of the differences between the Symbian OS and maemo platforms, regarding the client/server model vs. direct API calls. See Networking example.