Article on the Release of Gambas 2.0 RC1
After almost two years of development, I am happy to announce the first release
candidate of Gambas 2.
We're making this announcement now in the hope of attracting more testers users to this project during the release candidate cycle. This will help us find any bugs we might have missed.
Introduction
 |
The new logo of Gambas 2 |
Gambas is a full-featured object language and development environment built on a BASIC interpreter. It is released under the GNU General Public Licence.
Its architecture is largly inspired by Java. So Gambas is made up of:
- A compiler.
- An interpreter.
- An archiver.
- A scripter.
- A development environment.
- Many extension components.
The compiler is a fast little executable written in C:
- It compiles about 128000 non-void lines in a second on my own Athlon 2000. This speed allows a quick code/compile/test incremental development process.
- It does almost no optimization at all at the moment, relying on the interpreter to perform this task at runtime.
- It manages and compiles string translations by using the GNU gettext tools.
The interpreter is a small executable also written in C that is less than 180 Kb:
- It provides all of the native features of the language, by giving indirect access to almost all the POSIX glibc features.
- It loads classes on demand, optimizing the bytecode the first time it is run.
- Linking between classes is done entirely at runtime. This is done as late as possible. So even large executables start quickly.
Finally, the archiver is a program that creates a Gambas executable from a Gambas project directory.
 |
Note that a Gambas executable is just an uncompressed archive of a project. It can include any type of file, not just compiled bytecode, and it is internally accessed by the interpreter like a file system.
|
The Gambas Language
The main characteristics of the Gambas BASIC language are:
- About 250 keywords and native functions to manage almost everything: arithmetic, strings, input-outputs, files, time...
- Full error management.
- Full process control, with pseudo-terminal management.
- Full support for watching input-output file descriptors.
- Event loop support with timers.
- Native UTF-8 string support.
- Full internationalization and translation support.
- Ability to call external functions in system shared libraries.
But Gambas is a true object-oriented language as well. With:
- Objects and classes.
- Properties, methods, constants and events.
- Public and private symbols.
- Polymorphism, i.e. virtual method dispatching.
- Single inheritance.
- Constructors and destructors.
- Array accessors, enumerators, sortable objects.
The Gambas inheritance mechanism is entirely dynamic, and allows you to:
- Create a more specialized version of an already existing class.
- Reimplement a class and extend it.
- Override some methods or properties of a class.
Any classes can be inherited, reimplemented or overridden, even the native ones written in C/C++.
Finally, a native class named Observer allows you to intercept any event raised by any object.
An Extensible Language
The core Gambas interpreter is a terminal-only program. All other features are provided by components,
which are groups of classes written in C/C++, or written directly in Gambas.
These components provide, among other things:
- Access to many database systems: MySQL, PostgreSQL, SQLite, Firebird, ODBC.
- Graphical user interface programming, based on the QT toolkit, or the GTK+ toolkit.
- Network programming, with advanced protocol management: HTTP, FTP, SMTP, DNS.
- SDL programming.
- OpenGL programming.
- XML programming.
- CGI programming with session management.
 |
All these features are covered by only 351 classes and 4197 symbols (at the current time).
There are only a small number of concepts to learn when compared with other languages.
Moreover, we tried to make the names of these symbols as coherent as possible.
All this helps to make Gambas relatively easy to learn.
|
Components written in C/C++ are stored in shared libraries, and components written in Gambas are just Gambas projects like any other project.
They are loaded by the interpreter at program start-up, or when
needed during program execution.
Developing a component in C/C++ is a bit like developing a device driver for the Linux kernel:
- The source code of the component is located inside the Gambas source tree.
- The components and the interpreter communicate through an Application Programming Interface.
- They are executed in the interpreter environment, and so cannot do whatever they want.
The documentation about writing components is not yet finished, but all the required help will be provided on the developer mailing-list.
A Scripting Language
Gambas recently obtained support for becoming a scripting language.
This feature is provided by the scripter, a small Gambas executable that allows you to dump any Gambas code into a text file.
Here is a little script example:
#!/usr/bin/env gbs2
' This script returns the memory really used by the system, the cache and swap being excluded.
FUNCTION GetUsedMemory() AS Integer
DIM sRes AS String
DIM aRes AS String[]
DIM cVal AS NEW Collection
DIM sVal AS String
EXEC ["cat", "/proc/meminfo"] TO sRes
FOR EACH sVal IN Split(sRes, "\n", "", TRUE)
aRes = Split(sVal, " ", "", TRUE)
cVal[Left$(aRes[0], -1)] = CInt(aRes[1])
NEXT
RETURN cVal!MemTotal - cVal!MemFree - cVal!Buffers - cVal!Cached + cVal!SwapTotal - cVal!SwapFree - cVal!SwapCached
END
PRINT Subst("Used memory: &1 bytes", GetUsedMemory())
Database, GUI & Desktop Independence
Gambas components are not just bindings. They try to abstract the underlying library they are based on,
so that coherency and simplicity win.
Consequently, with Gambas, you can write programs that are:
- Independent of the underlying database system: every database system is accessed through the same API.
- Independent of the graphical toolkit: the QT component and the GTK+ component have the same interface.
For example, Gambas provides a database manager tool that:
- Allows you to edit and manage any database, provided that there is a component for it.
- Uses the QT toolkit when run from KDE, and the GTK+ toolkit when run from Gnome or XFCE.
 |
 |
The database manager under KDE |
The database manager under XFCE |
Moreover, we tried to provide desktop independence too, by:
- The use of icon themes according to the current desktop environment (KDE, Gnome or XFCE).
- The gb.desktop component, based on the shell scripts from the Portland project.
The Development Environment
Gambas provides a full-featured IDE, which is itself written in Gambas.
You can create forms, insert controls just by drawing them, edit your code, and do many other things similar to other rapid application development systems.
 |
 |
The IDE in design mode |
The IDE in debugging mode |
The Gambas development environment provides the following features:
- Syntax highlighting of Gambas code, HTML and CSS files.
- Automatic completion.
- GUI form editor.
- Integrated debugger.
- Icon editor.
- String translator.
 |
 |
 |
The source code editor |
The icon editor |
The translation dialog |
- Subversion support.
- Database manager.
- Online documentation coming directly from the documentation wiki.
- Many program examples.
 |
 |
 |
The three first tabs of the project property dialog
|
Moreover, it can make installation packages for many distributions,
and also tar.gz installation packages based on GNU autotools.
The following GNU/Linux distributions are supported:
- Debian.
- Fedora.
- Mandriva.
- SuSE.
- Slackware.
- Ubuntu.
 |
The packages made by the IDE work only if the target distribution correctly packages Gambas as specified
on the How To Package Gambas page of the wiki. Alas, this is not
always the case at the moment...
|
Finally, even though the development environment is strongly tied to the Gambas language, you don't have to use it to create Gambas programs.
Caveats
So that people will not claim this essay simply looks like an advertisement :-), we should mention that there are still some caveats in Gambas.
The main one are:
- Gambas is only a 32 bit application, and does not run natively on 64 bit systems.
- Some features are missing in the language: enumeration declaration, and support for structures.
- The GTK+ component is not completely finished yet, and so the GUI toolkit independence is not complete.
Hopefully, the goal is to solve these problems in the next release.
The Future
...is not predictable, especially the Gambas one.
Thanks to a Perl script using the Positronic::Variables and Quantum::Superposition modules,
we were able to guess that the next release will provide:
- 64 bit support.
- DBus support.
- The merging of the database manager into the development environment.
- A report designer in the IDE.
- QT4 & Cairo support.
- KDE4 support.
- An enhanced gb.desktop component.
- OpenOffice document generation.
 |
Gambas is free software. So, contrary to proprietary software, what is promised may not always be delivered on time, or may not be delivered at all. :-)
|
Download Gambas and Other Links
You can download Gambas at http://gambas.sourceforge.net/download.html.
For more information on Gambas, here are a few links:
You can report problems and bugs either on the mailing-list or on the bug tracker at
http://gambasrad.org.
We hope that you will enjoy Gambas as much as we do! :-)
BenoƮt Minisini
"When you are doing something, you have against you every people doing the same thing,
every people doing the opposite thing, and the very large majority of people doing nothing."
- Confucius.