For a few years, I’ve been working in the real world, I mean the enterprise world, sorry. In every company I’ve worked for, they offered me the opportunity to learn a lot of new things, or at least that’s what they always said in the first meeting before sending me to be just another company programmer. But in fact I’ve learned some very important things, just not about programming. I had to learn about these things on my own, about the needs of a real company in the real world.
Software schedules are usually tight. Big custumers think like that old Queen song: “I want it all, and I want it NOW”. Modifications must be done quickly, sometime multiple times, as customers change their mind often. And there’s not just one big custumer, but a hundred important customers for our company, and our program must be adapted to work in different environments.
However, not all programming tasks need a real programmer. There are few programmers, and all the employees need your services. You can’t do all, and you don’t have the time to learn all about marketing, administration, statistics, sales, and all the rest of things existing in a modern company. It would be a tremendous advantage if experts in these fields had the ability to write simple programs to meet their own needs.
Programming in C or C++ is effective, and the basis for much of the world’s most important software. Think about Linux; more than a million lines of code written in C, and it works like a charm thanks to C’s inherent strengths. However, coding in C or even in C++ is slow and cumbersome if you want to program an interface for a database in a day. But there are many cases where someone in a company, or just a computer user in their house would want to do some simple programming to automate a task.
Programming languages like Perl or Python are nice too, especially for web tasks, but they’re designed for programmers, and they have important shortcomings for the beginner, for example, lacking a really easy and comfortable IDE.
On the other side, a lot of old computer users, whether they are currently working as programmers or not, began using computers with well known names like MSX, Spectrum, Commodore, or Amstrad. All of them had their own BASIC interpreter, and almost everyone who used computers back then remembers something about BASIC. Due to the success of a small software company back in the 80s, I can’t remember the name, sorry, BASIC was also extended to manage databases, spreadsheets, and there’s even a good IDE for a BASIC dialect thanks to that company, and a lot of programmers have learned that this BASIC dialect is poor, and has bugs, but they can easily write and debug programs using it, so they have become productive for their companies.
New things like C# are also good for big projects, but for a beginner it’s just confusing when they read things like “System Runtime Interop Services”, and they realize that they have to learn about name spaces, inheritance, interfaces and provider objects before writing anything useful.
So it seems there’s a good place for an easy and powerful language, so both beginners and programmers that need to concentrate in the problems instead of the syntax, can work without problems. That’s where Gambas can help the free software community. Gambas offers an easy IDE and a BASIC interpreter that allow the user to create both graphical and console programs, database applications, and communications programs. Even CGI’s can be written with few effort. And it is ready; the 1.0 version will be out soon.
Let’s program using Gambas. You can download and compile the sources from the download section of Gambas , or if you’re using Mandrake, you can download the latest version from Kudla.org, or install it from the “contrib” section of Mandrake distribution. Debian Sid/Sarge/Linex users can do it just typing “deb http://www.linex.org/sources/linex/debian/ sarge linex”. There are packages for other distributions like Slackware, too. Just look the download page, in the “Binary packages” section.
Once you’ve installed it, run Gambas. The first screen shows a wizard that allows you to open some example programs, open recent projects and to create a new project.
Let’s create a new project, so press the “New Project” option. Then press “next”.
Select “Create a graphical project”, then press “Next”.
In the “project” name type “MyProgram”, for example, and in the application title place any description, for example “This is my first program” or leave it blank, if you want.
In the next screen select a folder into your home directory where you want to save the project. The IDE will create a folder, with the same name as your project, into selected folder. Finally, a little resume of the options you’ve selected, and after pressing “Finish”, you will have access to the RAD environment to start developing your project.
Go to “Forms” the press the right button and select “New Form”. A dialog appears asking for the project properties.
Call it “FrmMain” the press OK.
Now in the “ToolBox” window, click on the button widget, go to your created form, and place it there resizing it as you want.
Now modify the button text, write “Hello” in the “Text” property of that button.
Let’s code a little. Double-click your button. The code editor will appear. Just write the code for the button:
Message.Info ("Hello, World!")
Now, execute your program. To do that, press “F5” or the “run” button. To test the program click your button. A dialog appears with the welcome message. Easy, isn’t it?
Gambas can do more!
This was just a very little example. However, Gambas allows you to write complex programs. The RAD environment is written in Gambas itself. You can write multi language programs. To help you doing that, the RAD offers a wizard to translate your programs to a lot of languages. All translations are compiled with the main executable, and according with the user language, the program will automatically show the texts in a language or another. All form texts are automatically added to the translation wizard, and you can select if any of the texts written in the code must be translated or not. A usual string (between the ” symbols), is not translated, but if you round it with the “(” and “)” symbols, it will be available for translating:
Text1.Text="This string will be not translated"<p>
Text2.Text=("This string will be translated")
Gambas offers database access. Cvurrently you can manage MySQL, PostgreSQL and Sqlite. You can write code to read and alter table contents, and even to create and delete databases and tables. Gambas RAD also provides a database manager, that allows you to graphically connect with a database server, create and destroy databases, tables and records in a table. It also offers interesting features, like translating table structure to Gambas code, so you can create the table in any new installation without having to write the “CREATE TABLE” statements by hand, or database users management.
A complete documentation system can help you when you are in trouble. That documentation is being updated all the time, as it is placed in a wiki at Binara. There’s a Spanish translation in progress at Linex.
There are wizards to distribute your program as source code (tar.gz format) and to create binary packages for the main GNU/Linux distributions. You can create a rpm or deb package without knowing the build tools for these package systems.
You can write network applications using Gambas; there’s a low level network component that allows to write TCP, Unix and UDP socket clients and servers, and to work with serial port devices. A beta component, based on the curl library, allows to directly perform querys to HTTP servers and work as an FTP client.
XML is work in progress, soon you’ll be able to read and write XML files, perform XML-RPC calls and make conversions to XHTML using XSLT.
The components model
Gambas is designed to be extensible. There’s a base language, and all the rest of the features are provided by components. Currently, components are written in C or C++, and in the future you’ll be able to write your own components in Gambas! Even the graphical toolkit is just a component. By default, Gambas can just be use for console programs, but adding the qt component, the program becomes a graphical application. This qt component is as agnostic as possible, so in the future there will be a GTK+ component, that will work absolutely the same as the qt component, allowing you to decide what low-level toolkit to use.
Gambas is just 1.0. In the next year there will be a lot of advances: finishing the network and XML component, writing components in Gambas, serialization, persistence, sound and graphics with SDL, a GTK+ toolkit, a report designer, data widgets (grids, combo-boxes…)…
So, if you plan to write the applications for your home financials, or have to write programs for big customers, think of Gambas, it can make you productive, fast, smart, and all the kind of things that big companies marketing campaigns say, with the freedom of GNU/Linux or FreeBSD, and the support of a big team of volunteers!
About the author:
Daniel Campos Fernández
Working for Gambas since 2003, writing the network, XML/XSLT, and compression components.
If you would like to see your thoughts or experiences with technology published, please consider writing an article for OSNews.