2. General Features
A brief comparison of C++ and Felix reveals the
following key similarities and differences:
- primitive types
- C++ has a fixed set of standardised primitive
types built in. The Felix core language
has no primitive types. It does, however,
have a complete set of standard types defined in
the standard library.
- classes
- Felix does not have classes. However C style structs,
and an object construction, are supported.
New abstract types can be introduced into
Felix by binding to any copyable C or C++ type.
- polymorphism
- C++ allows polymorphic functions and classes using
templates, Felix also allows polymorphic typedefs
and modules.
- overloading
- Both C++ and Felix support overloading in a similar
style, including for generic functions. However,
in C++ hiding is based only on the name, whereas
in Felix the parameter type is also taken into account.
- functions
- Felix functions are first class and can be passed
as arguments to other functions. Functions may
also be nested in other functions, and then
have access to all the symbols of that function.
- modules
- Felix modules are similar to C++ namespaces
except that they cannot be extended, however
they may be polymorphic.
- tuples
- Felix supports a first class tuple kind.
A tuple is just a canonical immutable struct.
- arrays
- Felix supports a first class fixed length array kind.
- procedures
- Felix actually supports two kinds of executable
objects: functions and procedures. Unlike C++
functions may not have side effects. A procedure
is like a function that returns no value, and may
have side effects. Procedures may also read a value
from the central event queue.
- pointers
- Felix supports pointers to variables.
Values cannot be addressed. Pointers to local
variables, however, are supported and will not
dangle, even after the function exits.
- memory management
- Felix uses an exact garbage collector which supports
finalisation. Destructors of any embedded C++
types will be correctly executed, but at an indeterminate
time and in an indeterminate order. Therefore the
Resource Acquisition Is Initialisation (RAII) paradigm
should not be used in Felix when synchronous well ordered
resource management is required.