What Is Gambas?

The Gambas 3 logo

Introduction

The master came to the pulpit,
and just as he was opening his
mouth for his daily harangue,
a nightingale started singing.
When the bird finished his song,
the master said:

"That is all I had to tell you."

Then he took his leave.

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 largely inspired by Java. So Gambas is made up of:

The compiler is a fast little executable written in C:

The interpreter is a small executable also written in C that is about 320 Kb on a 64 bits system.

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:

But Gambas is a true object-oriented language as well. With:

The Gambas inheritance mechanism is entirely dynamic, and allows you to:

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:

All the Gambas features are covered by only 405 classes and 5065 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 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 can be used as 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 gbs3
 
' 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 Kb", 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.

Database Independence

With Gambas, you can write programs that are independent of the underlying database system: every database system is accessed through the same API.

For example, The database manager integrated in the IDE uses the same code to manage MySQL, PostgreSQL, SQLite or ODBC databases.

The IDE Database Manager

GUI Independence

With Gambas, you can write programs that are independent of the graphical toolkit: the QT4 component and the GTK+ component have the same interface.

Here is a Gambas example run with the QT4 and GTK+ toolkits.

The Printing example using Qt4 The Printing example using GTK+

Desktop Independence

Moreover, we tried to provide desktop independence too, by:

Here is the Gambas IDE using KDE and Gnome icon theme.

The development environment using KDE icon theme The development environment using Gnome icon theme

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 source code editor The debugger

The Gambas development environment provides the following features:

The icon editor The translation 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:

     

The IDE Packager

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.

We try as much as possible in lobbying distributions so that they package Gambas correctly. This is not always easy!

You can help us by submitting bug reports to the distributions that fail doing that essential task.

Finally, even though the development environment is strongly tied to the Gambas language, you don't have to use it to create Gambas programs. All Gambas tools (compiler, interpreter...) can be used from the command-line.

Download Gambas and Other Links

You can download Gambas at http://gambas.sourceforge.net from the "Download" menu.

For more information on Gambas, here are a few links:

You can report problems and bugs either on the mailing-list or on the bugtracker.

We hope that you will enjoy Gambas as much as we do! :-)

BenoƮt Minisini