Gambas: A Fast Visual Basic for Linux

Gambas 1.0 has shipped. Gambas is a free, open source, Visual Basic like development environment for Linux. It has a built in visual designer, a built in debugger, components, a properties window (object inspector), and code insight. You can currently access MySQL and PostgreSQL databases from Gambas programs.

Gambas is not source compatible with Visual Basic. Instead, it contains an improved, rearchitected version of the Basic language. There is definitely a good deal of C++ code in the source for the project, but the IDE itself was written in Gambas, just as Delphi was written in Delphi. This is undoubtedly one of the reasons that the product is so good. The developers used Gambas to build and debug Gambas, and therefore took the time to make sure it was clean and functional.

This article is a very preliminary review of the product. It is a first look, describing my immediate impressions upon installing and loading Gambas.

A Delphi-Like IDE

The Gambas IDE has free floating windows like the original Delphi, and unlike Visual Studio. There is a green run button just like in Delphi, and you can compile the project to a Linux executable in one step.

Performance: Lightening Fast

Gambas is fast and responsive. On my aging 1700 MHZ Fedora 2 system, I would estimate that response time in the IDE is roughly equivalent with Delphi 1 or 2. There is a barely perceptible lag between the time I push the green run button and the time when the compiled program first appears, but it is well under a second. If I put a break point on the first line of code in a button response method, I can sense that there is a lag before I hit the break point, but it is not a humanly measurable period of time. It is not quite instant, but it is a small enough period of time that I am not able to measure it.

A color coded version of CodeInsight appears instantly when you need it. If I type in a variable, such as ListBox1, then type a period, the list of methods on the object appears as quickly as my machine can redraw. CodeInsight picks up on new methods that I add to my main class instantly, without me having to recompile the code. For instance, if I add a method called Foo to my main class, then Gambas sees it immediately when I type the period after the word me. (me plays the same role in Basic as the words this or self do in Java, C++ and Delphi. It is a way of referencing the current object.)


Event Model

Gambas has an event model very similar to that found in Delphi or VB 6. You can access the list of built in events for a component by right clicking on it. For instance, if you right click on a button, you can choose Events from the popup menu, and then select one of 16 events to automatically create the wrapper code for your event. Selecting the DblClk event creates the following code:

PUBLIC SUB Button1_DblClick()

Other events you can create on a button include: Click, Drag, DragMove, Drop, Enter, GotFocus, KeyPress, KeyRelease, Leave, LostFocus, Menu, MouseDown, MouseMove, MouseUp and MouseWheel.


Component Model

Gambas has a simple toolbox, containing about 25 components. You can double click the icon for any of these components in the ToolBox to make an instance of the component appear in the upper left hand corner of the currently selected form.

Gambas comes with the following built in components: Label, Image, TextLabel, ProgressBar, Button, CheckBox, RadioButton, ToggleButton, TextBox, ComboBox, TextArea, ListBox, ListView, TreeView, IconView, GridView, ColumnView, Frame, Panel, TabStrip, ScrollView, DrawingArea, Timer, GambasEditor, LCDNumber, Dial, SpinBox, ScrollBar, Slider, TableView, Splitter, Workspace.

I did not detect any context sensitive help, but pressing F1 brought up the help file in less than one second. I was then able to search on the name of my currently selected component to get very minimal, but complete, hyperlink style help. For instance, if I typed in the word Button, I got a list of the properties, methods and events on the button. If I clicked on the name of any of the events or methods, I was taken to a short description of that event or method. The declaration for the item was also listed in the help pane.

The components in Gambas appear to be based on the QT library. Since Gambas ships with source, and runs on Linux, there will be no need for a complex, Kylix-like license with TrollTech, and a simple recompile of Gambas itself will link you to the most recent QT library.

You can create your own components in Gambas, but in this first version, you must write them in C or C++. The components must be developed in the Gambas source tree, and at least part of Gambas itself must be recompiled in order to integrate your component into the IDE. The object model for these components looked reasonable on first glance, but it is of course a major disappointment to find that one can’t create them in Basic. This was easily the most disappointing find in my first look at Gambas. However, the second release of Gambas is scheduled to support native components built in Basic.

Regular Expressions, Movies, and other Miscellaneous Features

A quick perusal of the help files showed that there are various other components and tools that ship with Gambas. I found tools adding scripting, regular expressions, and multimedia movies to your applications. There were internet components for creating sockets, working with serial ports, and querying DNS servers. A compression library was also built into the Gambas tool chest.

I have not used, or tried to use, any of these advanced components. In many cases, these advanced components, such as the movie tool, appear to be wrappers around QT components. I hope to come back and revisit this subject in future articles.

The product comes with various sample programs. Most of them compiled immediately after installation with no fuss or extra effort on my part. A few of them accessed components which I had not installed yet, but they popped up a clear explanation of the error, and the IDE handled the exception flawlessly. I accessed the examples from the File | Open Example menu choice.


Gambas comes with source. There are binary releases you can download for many of the major distributions. However, I just downloaded the source for the project in a tar ball. I then typed the following three lines of code to compile and install the project:

su -c “make install”

After completing these steps, I launched Gambas by typing the following command:


If you are familiar with Linux, you should have no trouble installing Gambas using the method I show here. I would say it took me about ten minutes to download and install Gambas. If you are new to Linux, or a very occasional Linux user, then you should look carefully at the Gambas download page and see if you can find a way to install Gambas using the binary installation tools.


I don’t think I ever started actually crying during the first few minutes in which I used Gambas. However, my eyes did sting a bit, and there was a funny churning sensation in my heart and stomach areas.

This is, of course, what we had all hoped for when Borland announced a Linux version of Delphi. Rather than indulging in yet another Kylix postmortem, I will simply say that at first glance this appears to be an extraordinary win for the open source movement in general, and the SourceForge community in particular.

This project was apparently developed primarily by a single individual, Benoît Minisini. There were others involved in the project, but Benoit was definitely the chief architect and creator of the majority of the source code for the tool. He has outlined an ambitious future for Gambas.

I do not know how well Gambas is going to hold up under careful scrutiny, nor how well the IDE holds up when large Gambas projects are loaded into it. I have read that Gambas has database connectivity, and that it is an important and central part of the product, but I have not yet tested that feature.

There are some shadows in this otherwise bright picture. Gambas uses QT, so there is no cost to distribute free GUI based applications written in Gambas, but if you want to sell a product written in Gambas, you must talk to TrollTech. Having to build components in C or C++ is definitely less than ideal, and I look forward to seeing the Basic component model promised in version 2.0. Some people might find the free floating, Delphi 7 style windows to be less than ideal. But considering that this is a free tool, one can’t help but consider these minor drawbacks.

Regular CodeFez readers will know that I am a big supporter of the open source movement. Yet frankly, this project caught me a little off guard. I simply was not expecting anything quite this promising. Despite all my enthusiam for open source, I still tend to underestimate the power of the movement. It frequently exceeds my expectations. And that, of course, was the sensation that I used to get back in the mid-nineties, when Delphi was hot.

I know that finding acceptance for a Visual Basic like IDE on Linux will be an uphill battle. However, for windows developers who want to move to Linux, this could well be a major find. If it can live up to expectations, here at last is an environment that brings the promise of true visual development to Linux.