FreeBASIC | |
Paradigm: | Procedural, object-oriented |
Designer: | Andre Victor[1] |
Developer: | The FreeBASIC Development Team |
Latest Release Version: | 1.10.1 |
Typing: | Static |
Influenced By: | QuickBASIC, C |
Operating System: | MS-DOS, FreeBSD, Linux, Microsoft Windows |
License: | GNU GPLv2+, Standard libraries licensed under the GNU LGPLv2+ |
FreeBASIC is a free and open source multiplatform compiler and programming language based on BASIC licensed under the GNU GPL for Microsoft Windows, protected-mode MS-DOS (DOS extender), Linux, FreeBSD and Xbox. The Xbox version is no longer maintained.[2]
According to its official website,[3] FreeBASIC provides syntax compatibility with programs originally written in Microsoft QuickBASIC (QB). Unlike QuickBASIC, however, FreeBASIC is a command line only compiler, unless users manually install an external integrated development environment (IDE) of their choice.[4]
On its backend, FreeBASIC makes use of GNU Binutils in order to produce console and graphical user interface applications. FreeBASIC supports the linking and creation of C static and dynamic libraries and has limited support for C++ libraries. As a result, code compiled in FreeBASIC can be reused in most native development environments.
While not an optimizing compiler, FreeBASIC can optionally transcompile to C to compile with optimizations. FreeBASIC supports inline assembly, multi-threading, and does not use automatic garbage collection.
C style preprocessing, including multiline macros, conditional compiling and file inclusion, is supported. The preprocessor also has access to symbol information and compiler settings, such as the language dialect.
Initially, FreeBASIC emulated Microsoft QuickBASIC syntax as closely as possible. Beyond that, the language has continued its evolution. As a result, FreeBASIC combines several language dialects for maximum level of compatibility with QuickBASIC and full access to modern features.[5] New features include support for concepts such as objects, operator overloading, function overloading, namespaces and others.[6]
Newline characters indicate the termination of programming statements. A programming statement can be distributed on multiple consecutive lines by using the underscore line continuation char (_), whereas multiple statements may be written on a single line by separating each statement with a colon (:).
Block comments, as well as end-of-line remarks are supported. Full line comments are made with an apostrophe '
, while blocks of commented code begin with /'
and end with '/
.
FreeBASIC is not case-sensitive.
FreeBASIC provides built-in, QuickBASIC compatible graphics support through FBgfx, which is automatically included into programs that make a call to the SCREEN
command. Its backend defaults to OpenGL on Linux and DirectX on Microsoft Windows. This abstraction makes FBgfx graphics code cross-platform compatible. However, FBgfx is not hardware accelerated.
Users familiar with external graphics utilities such as OpenGL or the Windows API can use them without interfering with the built-in graphics library.
As FreeBASIC has evolved, changes have been made that required breaking older-styled syntax. In order to continue supporting programs written using the older syntax, FreeBASIC now supports the following dialects:
[[GOSUB]]
/ RETURN
, numeric labels and other features are allowed in this dialect.Standard programs, such as the "Hello, World!" program are done just as they were in QuickBASIC.
sleep:end 'Comment, prevents the program window from closing instantly
FreeBASIC adds to this with support for object-oriented features such as methods, constructors, dynamic memory allocation, properties and temporary allocation.
Constructor Vector (nX As Integer, nY As Integer) x = nX y = nYEnd Constructor
Property Vector.getX As Integer Return xEnd Property
Property Vector.getY As Integer Return yEnd Property
Print player->getXPrint player->getY
Delete player
Sleep 'Prevents the program window from closing instantly
In both cases, the language is well suited for learning purposes.