Gambas
Gambas is a free and open-source object-oriented dialect of the BASIC programming language, accompanied by an integrated development environment (IDE) that facilitates graphical application development, primarily for Linux and other Unix-like operating systems.[1] Developed by French programmer Benoît Minisini since 1999, it draws inspiration from Microsoft Visual Basic while incorporating modern object-oriented features like inheritance and polymorphism, and is released under the GNU General Public License.[2] The name "Gambas" is a playful acronym standing for "Gambas Almost Means BASIC," reflecting its roots in the accessible syntax of BASIC interpreters.[3]
The project began as an effort to create a Visual Basic-like tool for Linux, with the first public release occurring in 2002 and version 1.0 in 2005; subsequent major versions include Gambas 3 (2012) and the current stable series, Gambas 3.21.0, released in late 2025.[4] Gambas supports a compact language with approximately 250-350 keywords and functions, enabling rapid development of desktop applications through its visual form editor, syntax-highlighted code editor, and built-in debugger.[1] Key components include a compiler that processes code at high speeds (around 920,000 lines per second on modern hardware), an interpreter for runtime execution, and libraries for GUI toolkits such as Qt and GTK+, as well as database connectivity to systems like MySQL, PostgreSQL, and SQLite.[1]
Notable features emphasize ease of use for beginners and power for advanced users, including full UTF-8 support, internationalization tools, process control, error management, and scripting capabilities, allowing applications to integrate seamlessly with desktop environments like KDE, GNOME, and XFCE.[1] Gambas programs can be packaged for distribution via formats compatible with Debian, Ubuntu, and other Linux repositories, and it extends to cross-platform potential through efforts for FreeBSD, Haiku, and even Windows via Cygwin or WSL.[5] With over 860 classes and 10,000 symbols in its runtime library, Gambas remains a lightweight yet versatile platform (interpreter size ~654 KB on 64-bit systems), actively maintained to support contemporary development needs in open-source software ecosystems.[1]
Introduction
Overview
Gambas is an object-oriented dialect of the BASIC programming language, accompanied by an integrated development environment (IDE) designed for rapid application development.[1] Developed by French programmer Benoît Minisini, development of which began in 1999, with the first public release in 2002 as a free and open-source alternative inspired by Visual Basic, targeting graphical desktop applications on Linux and other Unix-like operating systems.[2] The language compiles to bytecode for interpretation, enabling quick prototyping due to the fast compilation process (around 920,000 lines per second on modern hardware), while the IDE provides tools for visual design, debugging, and project management.[1]
Key characteristics of Gambas include its support for GTK+ and Qt toolkits, allowing developers to create cross-compatible graphical user interfaces.[6] It features over 860 built-in classes and components that facilitate multimedia handling via SDL and OpenGL, database interactions with systems like MySQL, PostgreSQL, SQLite, and ODBC, as well as networking protocols including XML-RPC and SOAP.[1] These elements promote object-oriented programming with inheritance and polymorphism, all within a BASIC-like syntax for accessibility.[1]
As of November 2025, the current stable version is Gambas 3.21.0, which introduces enhancements such as optimized JSON processing up to 20 times faster, improved just-in-time (JIT) compilation for better interpreter speed, and various bug fixes addressing memory issues and debugger stability.[7] These updates refine the platform's performance and reliability for modern application development.[7]
Etymology
The name Gambas serves as a recursive acronym for "Gambas Almost Means BASIC," underscoring its roots as an object-oriented dialect of the BASIC programming language.[8] This construction was devised by Benoît Minisini, the French developer who created the project in 1999, to playfully nod to its BASIC heritage while distinguishing it as a modern evolution.[3]
The term "gambas" also carries a linguistic pun, as it translates to "shrimp" or "prawn" in Spanish, French, and Portuguese.[9] Minisini selected this name to infuse humor and whimsy, evoking the lightweight and approachable nature of seafood as a metaphor for the language's simplicity and ease of use.[8]
Through this etymological choice, Minisini aimed to position Gambas as a fun, accessible open-source alternative to proprietary tools like Visual Basic, emphasizing an inviting entry point for developers seeking straightforward programming on Linux and Unix-like systems.[3][8]
History
Origins
Gambas was conceived by Benoît Minisini, a French programmer from the suburbs of Paris who had been passionate about programming since childhood, beginning with BASIC on computers like the Amstrad CPC 464 and Atari 520 STE at age 12.[10] Minisini's early experiences with BASIC shaped his affinity for simple, accessible languages, but by the late 1990s, he grew frustrated with the absence of a Visual Basic-like tool for Linux, where rapid graphical user interface (GUI) development was cumbersome compared to Windows environments.[11]
The initial motivation for Gambas stemmed from Minisini's desire to create an open-source, Linux-native alternative to Microsoft Visual Basic, enabling quick GUI application development without proprietary dependencies or the quirks of the original.[11] He envisioned a complete development environment inspired by BASIC's ease but extended with object-oriented features, akin to Java or .NET, to meet his personal needs for visual and straightforward programming.[10] As a solo project, Minisini began by sketching ideas on paper before implementing the core components in 1999, starting with a basic interpreter and a simple form designer to facilitate immediate GUI prototyping. The first public release occurred in 2002. Early development posed significant challenges, as Minisini built everything from scratch to ensure independence from proprietary software, initially focusing on the Qt toolkit for cross-platform GUI support while prioritizing coherence and reliability for Linux users.[11]
Version Timeline
Gambas achieved its first stable release with version 1.0 on January 10, 2005, marking a milestone in providing basic stability for creating graphical user interfaces and applications on Linux systems. This version established the core interpreter and IDE framework, enabling developers to build Visual Basic-style programs with improved reliability over earlier prototypes.[12]
The release of Gambas 2.0 in early 2008 represented a significant advancement, with enhancements to object-oriented programming capabilities and expanded component libraries that facilitated more complex application development. This version refined the language's syntax and integration with external libraries, broadening its appeal for desktop software creation.[13]
A pivotal shift occurred with Gambas 3.0 in January 2012, which underwent a major rewrite to boost performance through optimized bytecode interpretation and increased modularity in its component architecture. This overhaul allowed for better extensibility and efficiency, laying the groundwork for subsequent iterative improvements in the 3.x series.
| Version | Release Date | Key Developments |
|---|
| 3.19.0 | February 16, 2024 | Interpreter optimizations for faster execution and reduced memory usage.[3] |
| 3.20.0 | Early 2025 | Enhancements to the development environment, including improved project management tools and updated packaging support.[14] |
| 3.21.0 | October 13, 2025 | Bug fixes across components, along with initial Qt6 support for modern GUI rendering.[15] |
Over the course of its evolution, Gambas transitioned from exclusive reliance on the Qt toolkit in early versions to dual support for both Qt and GTK starting in the mid-3.x series, enabling greater compatibility with diverse desktop environments like GNOME and KDE. Additionally, later 3.x releases introduced experimental Just-in-Time (JIT) compilation, beginning with version 3.12.0, to accelerate code execution by translating Gambas bytecode to native machine code on the fly.[16][17]
As of November 2025, the project remains actively developed under Benoît Minisini's leadership, with efforts progressing toward a potential Gambas 4.0 that prioritizes expanded cross-platform capabilities, including better Windows and macOS integration via ongoing component refinements; however, no firm release date has been set.[4]
Language Features
Syntax and Core Elements
Gambas employs a BASIC-like syntax that emphasizes readability and simplicity, featuring keywords such as PRINT for output, IF...THEN...ELSE for conditional statements, and FOR...NEXT for iteration loops.[18] The language is case-insensitive for keywords and identifiers, allowing developers to write Print or print interchangeably while maintaining consistency in code style.[19] This design draws from traditional BASIC dialects, enabling straightforward procedural programming without mandatory semicolons for statement termination or explicit type declarations in all cases.
Core data types in Gambas include the Variant for dynamic typing, which can hold any value and defaults to NULL, accommodating automatic type conversion similar to Visual Basic.[20] Other fundamental types encompass Integer (32-bit signed, range -2,147,483,648 to 2,147,483,647, default 0), String (variable-length Unicode, default NULL), Boolean (true/false, 1 byte, default FALSE), and Date (8 bytes for date and time, default NULL).[21][22] Conversion between types occurs seamlessly via built-in functions like CInt, CStr, and CBool, facilitating flexible data handling without explicit casting in many operations.[20]
Control structures support modular code organization through subroutines, declared as PUBLIC SUB or PRIVATE SUB for accessible or module-restricted procedures, respectively, with optional typed parameters (e.g., AS String).[23] Error handling utilizes a TRY...CATCH...FINALLY block, where TRY encloses potentially erroneous code, CATCH processes exceptions, and FINALLY ensures cleanup execution regardless of errors.[24] Arrays are declared using DIM, such as DIM arrayName AS New Type[dimension], supporting multi-dimensional structures with zero-based indexing.[25]
Built-in functions provide essential operations, including string manipulation with Left$ (extracts prefix characters), Mid$ (substrings), and InStr (substring position); mathematical utilities like Abs (absolute value), Sqr (square root), and Max (greater of two values); and basic file I/O via OPEN (file access), LINE INPUT (line reading), and CLOSE (resource release).[26] A distinctive feature is event-driven programming support, where custom events declared with EVENT are triggered using RAISE EVENT, optionally returning a boolean to indicate handler cancellation.[27]
Object-Oriented Capabilities
Gambas provides robust support for object-oriented programming through its class-based system, where classes serve as blueprints for creating objects that encapsulate data and behavior. An object in Gambas is instantiated using the NEW operator and consists of properties, variables, methods, and events, allowing developers to model real-world entities effectively.[28]
Inheritance is implemented via the Inherits keyword, enabling a class to derive from a parent class and inherit its methods, properties, constants, and events, with a maximum inheritance depth of 16 levels to prevent excessive hierarchies. This mechanism promotes code reuse, as child classes can override inherited methods to provide specialized implementations while maintaining compatible signatures, thus supporting polymorphism through virtual method dispatching. For example, a derived class can redefine a parent's Draw method to handle specific graphics rendering without altering the base behavior elsewhere in the program.[28][29]
Encapsulation is achieved primarily through visibility modifiers for methods and variables: Public (the default, accessible from outside the class) and Private (restricted to within the class only), ensuring internal state management while exposing necessary interfaces. Properties, however, are always public, providing controlled access to data via getter and setter methods if needed. This design hides implementation details, reducing complexity and enhancing maintainability in larger projects.[28][30]
Built-in classes number over 100, including the Collection class for dynamic key-value storage, Stream for input/output operations, and Timer for handling asynchronous events like periodic tasks.[28]
These object-oriented features integrate seamlessly with Gambas components, which are reusable class libraries extending core functionality; for instance, the gb.db component provides classes for database connectivity to systems like MySQL and PostgreSQL, while graphics components such as gb.qt offer classes for UI elements and rendering.[31]
GUI and Component Integration
Gambas facilitates the creation of graphical user interfaces through its integrated development environment, which includes a visual form designer enabling developers to build forms using a drag-and-drop interface for widgets such as buttons, textboxes, labels, and other controls. This designer allows for intuitive placement, resizing, and alignment of elements on forms, streamlining the process of prototyping and refining user interfaces without manual coding for layout. The designer supports properties editing panels for customizing appearance, behavior, and data binding directly within the IDE, promoting rapid application development similar to traditional BASIC environments.[32]
Event handling in Gambas GUI applications is tied directly to controls via a convention-based system, where developers define methods named after the control and event, such as Button1_Click() for responding to a button click or TextBox1_Change() for detecting text modifications. These events, including Click, Change, KeyPress, and MouseDown, are raised automatically by the underlying toolkit and executed in the context of the form's class, allowing for responsive, event-driven programming. This approach integrates seamlessly with Gambas's object-oriented features, where controls are instances of classes that can inherit and extend event behaviors.[33]
The component system in Gambas extends GUI capabilities through pre-built, loadable libraries that provide specialized classes for common tasks, enhancing integration without requiring external dependencies. For multimedia, the gb.media component offers classes like VideoPlayer for playback of audio and video files using GStreamer, supporting formats such as MP4 and WAV. Networking is handled by the gb.net component, which includes classes for HTTP requests via HttpClient, socket communications with Socket, and email via SmtpClient. Database integration is supported by gb.db, enabling connections to systems like MySQL, PostgreSQL, and SQLite through unified classes such as Connection and Result, abstracting vendor-specific details for SQL operations. These components are selected in the project settings and compiled into the application, ensuring modular and extensible GUI development.[34][35]
Gambas achieves cross-toolkit support for GUIs via an abstraction layer in its gb.form and related components, allowing developers to write toolkit-agnostic code while selecting the underlying implementation at compile time. The gb.gtk component leverages GTK+ version 3 for native integration on GNOME-based desktops, providing widgets with theming and accessibility features. Alternatively, gb.gui.qt dynamically loads Qt5 or Qt6 based on the runtime environment, such as KDE, offering high-performance rendering and advanced effects like animations. This selection is configured in the project properties, ensuring compatibility across Linux desktops without code changes, though performance and appearance may vary slightly between toolkits.[6][36]
For deployment, Gambas compiles projects into standalone executables using the gba3 archiver, which bundles bytecode from forms, classes, and modules into a single binary file marked as executable. The resulting application embeds the Gambas interpreter via memory-mapped access to the archive, eliminating the need for a separate runtime installation and enabling distribution as self-contained binaries on Linux systems. This process preserves debugging information if needed and supports icon embedding for desktop integration, facilitating easy sharing and execution of GUI applications.[37]
Development Environment
IDE Structure
The Gambas Integrated Development Environment (IDE) features a modular layout centered around several key components that facilitate project management, code authoring, graphical interface design, and debugging. The primary interface includes a menu and toolbar at the top for global operations, a Project Browser (also known as the Project Explorer) on the left displaying a tree view of project files such as forms, modules, classes, and resources, and a central workspace for editing forms or code. This structure allows developers to navigate and organize projects efficiently, with the ability to switch between design and code views seamlessly.[38]
The code editor, integrated into the central workspace, provides syntax highlighting for Gambas BASIC code and auto-completion suggestions based on language keywords, class members, and project-specific elements to streamline coding. When editing event handlers or procedures, the editor supports indentation, error underlining, and context-aware prompts, enhancing productivity during development. The form designer, also in the central area, enables drag-and-drop placement of controls from a built-in toolkit (e.g., buttons, labels, text boxes), with resizing handles, alignment tools, and a properties panel for configuring attributes like position, size, and events. This visual tool is particularly suited for rapid prototyping of graphical user interfaces. The debugger, accessible via toolbar buttons or keyboard shortcuts like F5 for execution, offers breakpoints, variable inspection, call stack tracing, and runtime error highlighting directly within the IDE, allowing step-by-step program analysis. In version 3.21.0 (released November 2025), the debugger panel can be undocked and placed on another screen, and it highlights values that have changed.[38][39][7]
Gambas supports multiple project types, including console applications for text-based programs, graphical applications with form-based UIs, and libraries for reusable code modules, selectable during project creation. Projects are organized hierarchically in the Project Explorer using modules for grouping procedures and functions, and classes for object-oriented structures, enabling modular development and easy file management without imposing rigid hierarchies.[38]
Built-in tools include an incremental compiler that translates Gambas source code into architecture-independent bytecode for efficient execution, an interpreter console for interactive testing of code snippets in console projects, and an integrated profiler introduced in version 3.2 for analyzing performance metrics such as execution time and function calls. These tools are invoked directly from the IDE's menus or toolbars, supporting a streamlined workflow from writing to optimization.[37][40]
Customization options encompass editor color themes that adapt to system dark mode preferences for better visibility, and extensibility through the component system, where developers can load plugins as shared libraries (e.g., gb.qt for Qt-based GUIs) to add new classes or features without modifying the core IDE. An integrated help browser provides context-sensitive documentation, including class references and examples, accessible via F1 or menu navigation to assist during development. Version control integration includes basic Git support added in version 3.20, with enhancements in 3.21.0 (November 2025) for committing individual files and cherry-picking commits, enabling repository pulls, pushes, and options like rebasing directly from the IDE's project menu.[41][14][7]
The development workflow in Gambas typically begins with creating a new project through the IDE, where developers select a project type such as a graphical application or console program. Forms and user interfaces are then designed visually using drag-and-drop tools, allowing components like buttons and text fields to be placed and configured without manual coding for layout. Event-driven code is written in response to user interactions, such as button clicks, leveraging the IDE's code editor for syntax highlighting and auto-completion. The project is subsequently compiled and tested within the IDE, with options to run in debug mode or generate a standalone executable for distribution.[1]
Debugging tools in Gambas include setting breakpoints by pressing F9 on a code line, which pauses execution for inspection, and variable watches that monitor expression values, stopping the program when changes occur. Step-through execution is supported via shortcuts such as F8 for single-stepping into code, F5 for running or continuing execution, and SHIFT + F5 for running to the current line, enabling precise traversal of code paths. An error console displays runtime outputs, including Print, Debug, and Error messages, along with stack traces for unhandled exceptions to facilitate rapid issue identification.[42][43]
For testing and profiling, Gambas provides the gb.test component, a framework for unit testing and test-driven development that allows creation of automated test suites to verify program functionality. Profiling tools, enabled via the IDE's "Debugging > Enable Profiling" menu or the System.Profile property, analyze runtime performance by measuring memory usage, CPU time complexity, and function call frequencies and durations, with results saved to a profile file limited to 512 MiB by default.[44][43]
Collaboration features support exporting projects as .gambas archive files for sharing via email or file transfer, and importing them into other instances of the IDE to continue development. Components can be shared through the Gambas contrib directory in the source repository or by packaging them as installable libraries, allowing reuse across projects without full source disclosure.[45]
Best practices in Gambas emphasize modular design by encapsulating functionality into reusable classes and modules to promote maintainability and code reuse. Developers should also account for cross-platform differences, such as varying desktop environments, by testing on multiple supported systems and using conditional compilation directives where necessary.[1]
Availability
Gambas primarily supports Linux distributions, where it is available through native packages for major releases such as Ubuntu 20.04, 22.04, 24.04, and 24.10; Debian 11 and 12; Arch Linux; openSUSE Tumbleweed and Leap 15.6; Fedora; and Mageia.[3][5] It compiles and runs reliably on these systems, leveraging the standard package managers like APT, DNF, or Pacman for straightforward integration. Fedora and Mageia provide packages through their standard repositories.
Support extends to other Unix-like operating systems, including FreeBSD, OpenBSD, and NetBSD, where Gambas 3 compiles successfully, though some components like gb.inotify may require adjustments.[5] Solaris has experimental ports, but functionality remains unconfirmed, while macOS has limited support; compilation is not officially supported and may encounter stability issues.[5] Windows lacks native support; however, experimental compatibility is achieved through Cygwin or Windows Subsystem for Linux (WSL), allowing Gambas to operate in a Unix-like environment.
Gambas targets common architectures including x86, x86-64, and ARM, with dedicated ports enabling deployment on devices like the Raspberry Pi for embedded applications.[46][47] There is no official support for mobile platforms such as Android or iOS as of 2025, due to limitations in the underlying C library features required for compilation and execution.
The runtime environment depends on graphical libraries such as GTK+ (version 2.16 or 3.4) or Qt (version 4.5 or 5.3) for GUI development, alongside core dependencies like libffi and cairo for rendering.[48] These ensure compatibility with desktop environments while maintaining a minimal installed footprint, typically under 50 MB for the core interpreter and essential components on Debian-based systems.[49]
Gambas supports cross-compilation, permitting the creation of standalone Linux executables on other Unix-like systems using tools like the built-in compiler, which generates native binaries without runtime dependencies beyond standard libraries. This facilitates development workflows across compatible environments, with installation methods detailed separately via distribution repositories.
Installation Methods
Gambas can be installed via binary packages, which are the recommended method for most users on supported Linux distributions, as they handle dependencies automatically. Binary packages are provided through distribution repositories or official builds hosted on the openSUSE Build Service. For Debian-based systems like Ubuntu, users can add the appropriate repository and install using the package manager; for example, on Ubuntu 24.04 or later, add the stable repository with echo 'deb http://download.opensuse.org/repositories/home:/gambas:/stable/xUbuntu_24.04/ /' | sudo tee /etc/apt/sources.list.d/home:gambas:stable.list, import the signing key via curl -fsSL https://download.opensuse.org/repositories/home:/gambas:/stable/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_gambas_stable.gpg > /dev/null, then run sudo apt-get update followed by sudo apt-get install gambas3. Users should select the repository path matching their specific Ubuntu version from the openSUSE Build Service. Similar steps apply to other distributions such as Arch Linux, openSUSE, and Debian, where repositories are added to pacman.conf, zypper, or apt sources, respectively, before installing the gambas3 package. For newer versions on Ubuntu, a Personal Package Archive (PPA) may be available, such as the Gambas stable PPA, to access updates beyond the default repositories. Source tarballs for stable releases are also downloadable from SourceForge, though compilation is required after extraction.
For users needing the latest development features or custom builds, installation from source code is possible by cloning the Git repository from GitLab. Prerequisites include development tools like gcc, g++, automake (version 1.11.1 or later), autoconf (version 2.68 or later), libtool (version 2.4 or later), and libraries such as libffi-dev, libbz2-dev, libcairo2-dev (version 1.6.0 or later), with exact dependencies varying by distribution and listed in the project's .gitlab-ci.yml file for reference. After installing prerequisites—for instance, on Ubuntu with sudo apt-get install build-essential g++ automake autoconf libtool libffi-dev libbz2-dev libcairo2-dev and additional libraries as needed—clone the repository using git clone https://gitlab.com/gambas/gambas.git, navigate to the directory, run ./reconf-all to generate configuration scripts, then ./configure -C (optionally with flags like --enable-nonfree for certain components), followed by make -j$(nproc) for compilation and sudo make install for installation. Stable versions can be obtained as tarballs from the official website instead of Git for a release-specific build.
Version management in Gambas distinguishes between stable releases (e.g., 3.21) available via binary packages or tagged Git commits, and development branches from the Git master, which may introduce experimental features but require recompilation for updates. Distributions typically provide stable versions through their package managers, allowing seamless updates with commands like [sudo](/page/Sudo) apt-get upgrade gambas3 on Debian-based systems, while Git users pull changes with [git](/page/Git) pull before rebuilding.
Post-installation setup involves launching the Gambas IDE with the gambas3 command and configuring GUI toolkits if needed for development. Gambas supports both GTK+ and Qt toolkits for creating graphical user interfaces, selectable during project creation in the IDE or by including specific components like gb.gtk or gb.qt. Additional contrib components, such as extensions for databases or web views, can be downloaded directly within the IDE using the built-in component manager under the Tools menu, which connects to the online repository hosted on the project's servers. No further system-wide configuration is typically required, as toolkit dependencies are resolved during installation.
Common installation issues often stem from unresolved dependencies on older distributions, where missing libraries like libgtk-3-dev or qtbase5-dev prevent compilation or runtime errors occur. Troubleshooting involves running sudo apt --fix-broken install on Debian-based systems to repair package conflicts, verifying and installing all prerequisites from the .gitlab-ci.yml file, or enabling universe/multiverse repositories in Ubuntu with sudo add-apt-repository universe before retrying. For source builds on legacy systems, users may need to adjust configure flags or use a containerized environment to match supported platforms.
Adoption and Community
Usage and Impact
Gambas primarily appeals to a niche audience of hobbyists, educators, and small-scale developers who value its accessible BASIC-inspired syntax for creating graphical user interfaces on Linux systems. This targeted adoption stems from its design as a lightweight alternative to more complex environments, enabling quick prototyping without steep learning curves.[50][51]
The language's impact lies in bridging the gap for BASIC-style rapid application development (RAD) tools on open-source platforms, where it supports object-oriented programming (OOP) in an intuitive manner. In educational contexts, Gambas serves as an effective entry point for teaching OOP principles and GUI design to novice programmers, fostering hands-on learning through its integrated development environment.[51][52]
Adoption has remained steady yet gradual, with some interest in Raspberry Pi integrations for hobbyist electronics and embedded projects. This reflects Gambas' compatibility with ARM architectures, allowing seamless deployment in low-resource scenarios like IoT prototypes.[47][53] The release of Gambas 3.21.0 in late 2025 continues to support ongoing community engagement.[54]
Despite these strengths, Gambas' ecosystem lags behind established languages such as Python or Java, resulting in minimal commercial uptake and reliance on community-driven components. Its user base is a small but dedicated community worldwide, gauged from forum engagement and distribution patterns, underscoring its role as a specialized rather than mainstream tool. Metrics include over 10,000 cumulative forum posts across dedicated communities and consistent activity on hosting platforms like SourceForge.[55][56][57]
Resources and Projects
The Gambas project maintains several official resources to support developers and users. The Gambas wiki at https://gambaswiki.org/ serves as the central documentation hub, offering language references, tutorials, code snippets, and an application repository that catalogs over 70 medium- to large-scale applications and demos written in Gambas. Mailing lists hosted at https://lists.gambas-basic.org/ facilitate discussions, with dedicated lists for general user queries, bug tracker notifications, and Git commit updates.[58][59][60]
Community-driven sites extend these official channels. The Gambas One forum at https://gambas.one/ acts as the primary English-language platform for discussions, troubleshooting, and sharing user experiences. The SourceForge project page at https://sourceforge.net/projects/gambas/ hosts downloads, file releases, and a discussion archive, serving as a longstanding hub for the community. User-contributed resources include tutorials scattered across the wiki and external books, such as A Beginner's Guide to Gambas by John W. Rittinghouse, which introduces core concepts for newcomers.[8][61]
Notable projects built with Gambas demonstrate its versatility across domains. Desktop utilities like the BumbleBee Launcher and MV1SysTray provide system integration tools, while educational software such as MyEduBase for student management and Multiple Diploma Builder for certification handling support learning environments. Math tools, including the Azeotrope Chemical Calculator, enable scientific computations. Simple 2D games like Tetris, Checkers, and Tic Tac Toe showcase graphical capabilities. Specific standouts include KediCAD, a CAD application for 2D and 3D design similar to AutoCAD, and Xt7-player-mpv, a GUI frontend for the mpv media player included in various Linux distributions.[62][63]
Contributions to the Gambas project follow a structured process using Git and GitLab. Developers fork the main repository at https://gitlab.com/gambas/gambas, implement changes in their branch, and submit merge requests for review, adhering to guidelines for code organization and testing. This workflow ensures external code pieces and artifacts are integrated efficiently.[64]
The support ecosystem around Gambas includes third-party libraries and components for specialized needs, though options remain limited compared to more mainstream languages. Web integration is handled through built-in components like gb.web for basic server-side functionality, with community extensions for HTTP handling. Hardware interfacing is supported via gb.serial for serial communication, enabling projects with devices like Arduino, as demonstrated in wiki examples for sensor data visualization and control.[65]
Examples
Simple Script Example
To illustrate the core syntax of Gambas in a non-graphical context, consider a basic console script that prompts the user for their name and age, performs string concatenation for a personalized greeting, applies conditional logic to validate the input, and incorporates error handling for invalid data such as empty name, non-numeric age entries, or out-of-range ages. This example highlights Gambas's interpreted nature, where the script is dynamically compiled to bytecode upon execution, enabling rapid prototyping without manual compilation steps.[66]
The following code defines a complete, standalone script saved as greeting.gbs:
gambas
#!/usr/bin/env gbs3
Public Sub Main()
Try
Dim sName As String = Input("Enter your name: ")
If sName = "" Then
Throw "No name provided."
End If
Dim sAge As [String](/page/String) = Input("Enter your age: ")
If Not IsNumber(sAge) Then
Throw "Age must be a number."
End If
Dim iAge As Integer = Val(sAge)
If iAge < 0 Or iAge > 150 Then
Throw "Invalid [age](/page/Age) entered."
End If
Print "Hello, " & sName & "! You are " & Str(iAge) & " years old."
Catch
Print "Error occurred: " & Error.Text
End
End
#!/usr/bin/env gbs3
Public Sub Main()
Try
Dim sName As String = Input("Enter your name: ")
If sName = "" Then
Throw "No name provided."
End If
Dim sAge As [String](/page/String) = Input("Enter your age: ")
If Not IsNumber(sAge) Then
Throw "Age must be a number."
End If
Dim iAge As Integer = Val(sAge)
If iAge < 0 Or iAge > 150 Then
Throw "Invalid [age](/page/Age) entered."
End If
Print "Hello, " & sName & "! You are " & Str(iAge) & " years old."
Catch
Print "Error occurred: " & Error.Text
End
End
This script begins with a shebang line (#!/usr/bin/env gbs3) to specify the Gambas scripter interpreter, allowing direct execution as a shell script.[66] The Public Sub Main() declares the entry point subroutine, which Gambas automatically invokes when running the script.[66]
The Try block initiates protected execution, encompassing the core logic. Dim sName As String = Input("Enter your name: ") declares a string variable sName and assigns it the result of the Input function, which reads a line from standard input after displaying the prompt. The subsequent If sName = "" Then Throw "No name provided." End If uses an If conditional to check for an empty string, raising a custom error with Throw if unmet, demonstrating basic control flow and explicit error raising. Similarly, Dim sAge As String = Input("Enter your age: ") captures the age as a string, followed by If Not IsNumber(sAge) Then Throw "Age must be a number." End If to validate that the input is numeric before conversion. Then, Dim iAge As Integer = Val(sAge) performs the numeric conversion with Val; non-numeric inputs are already caught. The If iAge < 0 Or iAge > 150 Then Throw "Invalid age entered." End If applies another conditional for range validation.
If validation passes, Print "Hello, " & sName & "! You are " & Str(iAge) & " years old." outputs the greeting, employing the & operator for string concatenation and Str to convert the integer back to a string for inclusion. The Catch block handles any exceptions raised within Try, accessing the error details via Error.Text and printing them.[24] This structure ensures the script terminates gracefully rather than crashing on errors like non-numeric input.
The purpose of this minimal script is to showcase Gambas's interpreted execution model, where the gbs3 command compiles the source to temporary bytecode, caches it for reuse, and runs it via the underlying interpreter (gbx3), recompiling only on changes for efficiency.[66] Basic error handling via Try...Catch prevents abrupt halts, promoting robust console applications. To execute, make the file executable with chmod +x greeting.gbs and run ./greeting.gbs, or invoke directly with gbs3 greeting.gbs; for persistent bytecode, convert the script to a full project using gbs3 --convert-script and compile via gbc3.[66][67]
GUI Application Example
A simple yet illustrative GUI application in Gambas is a basic form that allows user input via a text box and displays a dynamic greeting upon button activation, demonstrating core concepts like event handling and control manipulation. This example leverages Gambas' visual form designer and its integration with toolkits such as Qt or GTK+ for cross-platform rendering.
To build this application, launch the Gambas IDE and create a new graphical project by selecting "Graphical application" (typically using the Qt backend for broader compatibility). A default main form (FMain) is automatically generated, serving as the primary window. Open the form in the designer view, then access the toolbox (via F6) to drag and drop three controls: a TextBox for input, a Button for interaction, and a Label for output display. Arrange them vertically—place the Label at the top (e.g., at position X=10, Y=10), the TextBox below it (X=10, Y=50, Width=200), and the Button adjacent to the TextBox (X=220, Y=50, Width=80). Set the Button's Text property to "Greet" and ensure the form's Title is "Hello Gambas". These steps utilize the IDE's property editor (F4) for precise control placement and styling without manual coding.[68][11]
Next, implement the logic in the form's class file (FMain.class). In the Form_Open event, which triggers when the form loads, initialize the Label's text to prompt user input:
gambas
Public Sub Form_Open()
Label1.Text = "Enter your name below:"
End
Public Sub Form_Open()
Label1.Text = "Enter your name below:"
End
This sets a static message upon startup, showcasing string assignment and control properties. For interactivity, double-click the Button in the designer to auto-generate the Button1_Click event handler. Add the following code to read from the TextBox and update the Label dynamically:
gambas
Public Sub Button1_Click()
If TextBox1.Text <> "" Then
Label1.Text = "Hello, " & TextBox1.Text & "! Welcome to Gambas."
Else
Label1.Text = "Please enter a name."
End If
End
Public Sub Button1_Click()
If TextBox1.Text <> "" Then
Label1.Text = "Hello, " & TextBox1.Text & "! Welcome to Gambas."
Else
Label1.Text = "Please enter a name."
End If
End
This snippet employs conditional logic (If statement) to validate input, concatenation (& operator) for building strings, and property access (e.g., .Text) to link controls. The empty string check prevents blank greetings, highlighting basic error handling.[11]
Running the project (F5) launches a windowed application where users type into the TextBox and click the Button to see the Label update in real-time. This event-driven model—where the button click raises an event processed by the handler—exemplifies Gambas' object-oriented approach to GUI development, similar to Visual Basic but extended for Linux environments. The application can be extended by adding features like focus events (e.g., TextBox1_Focus to clear prior input) or persistence via the gb.db component, but this core example establishes foundational workflow for more complex interfaces.[37]