FreeBASIC
Encyclopedia
FreeBASIC is a free
/open source
(GPL
), 32-bit
BASIC
compiler
for Microsoft Windows
, protected-mode DOS
(DOS extender
), Linux
, FreeBSD
and Xbox
.
When used in its "QB" language mode, FreeBASIC provides a high level of support for program
s written for QuickBASIC
. Many programs written for QuickBASIC will compile and run in this mode with no changes needed. However, for compilation in the FreeBASIC default language mode, most substantial programs will require changes. FreeBASIC is not as related to Microsoft
's later Visual Basic
language. For that, Gambas
is the most relevant free software project.
FreeBASIC is the name for the compiler. It does not come bundled with an IDE. Most users will need to download an IDE such as FBide, FBedit, or Geany.
compiler, with roughly 120,000 lines of source code
, core only, not including libraries.
It makes use of the GNU
binutils programming tool
s as backends and can produce console and graphical/GUI
executables, besides dynamic and static libraries. FreeBASIC fully supports the use of C
libraries and partial C++
library support. This lets programmers use and create libraries for C and many other languages.
It supports a C style preprocessor
, capable of multiline macros, conditional compiling and file inclusion. However it is not a true preprocessor as it occurs at the same time as parsing. This means that it can access symbol information, and even set the dialect, which restarts parsing.
FreeBASIC has been rated close in speed with mainstream tools, such as GCC
.
syntax as possible, specifically that of QuickBASIC
. Although the syntax attempts to stay compatible with its predecessor, FreeBASIC follows modern standards and coding practices. Standard procedural features, along with object-oriented features such as types as object
s, operator overloading
, function overloading, namespace
s, etc., have been added in FreeBASIC.
FreeBASIC's lines end when the end-of-line characters are found, or with a colon
. Because of this, lines don't need a special character (such as the semicolon
in C
) to notify the compiler of the end of line. Multiple statements may be written on one line by separating each statement with a colon
FreeBASIC supports block commenting
along with end of line remarks. Full line comments are made with an apostrophe
programming language
. Changes were made during development to keep FreeBASIC compatible with modern utilities, and facilitate advanced programming features. In order to keep the compiler moving forward, GCC
compliant, and to also retain the ability to use a QuickBASIC-compatible language, the -lang option set was created.
, a program to write a line of text to the screen can be done with a simple statement:
However, FreeBASIC adds many object-oriented
features such as methods
, constructors, dynamic memory allocation, properties
and temporary allocation.
compatible, software graphics library
known as FBgfx (or Gfxlib), which provides simple graphics primitives (such as rectangles, lines, and circles), blitting, and more features which were not in QuickBASIC's graphics library. The library simply wraps the backend renderer. It uses OpenGL
on GNU/Linux and DirectX
on Microsoft Windows
, but can be forced to use OpenGL under Microsoft Windows. This abstraction makes the built-in graphics library portable across platforms.
Although the library is built-in, it is only included if users choose to use it, which is done simply by including a call to the FBgfx Screen command. Using common libraries such as OpenGL and creating a window
with an API (Microsoft Windows, GNU/Linux, etc.) for hardware acceleration
can be used without interfering with the FreeBASIC graphics library.
Another alternative to the built-in graphics library is Cairo
which can render vector images and raster images.
as a back-end, which would allow portability to nearly any modern system, and advanced optimizing
methods.
With the release of version 0.17, object-oriented programming
(OOP) was introduced by adding classes
and extending the basic type
. Further implementations are expected.
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...
/open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...
(GPL
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....
), 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....
BASIC
BASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....
compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
for Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
, protected-mode DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...
(DOS extender
DOS extender
A DOS extender is a computer software program which enables software to run under a protected mode environment even though the host operating system is only capable of operating in real mode....
), Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
, FreeBSD
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...
and Xbox
Xbox
The Xbox is a sixth-generation video game console manufactured by Microsoft. It was released on November 15, 2001 in North America, February 22, 2002 in Japan, and March 14, 2002 in Australia and Europe and is the predecessor to the Xbox 360. It was Microsoft's first foray into the gaming console...
.
When used in its "QB" language mode, FreeBASIC provides a high level of support for program
Computer program
A computer program is a sequence of instructions written to perform a specified task with a computer. A computer requires programs to function, typically executing the program's instructions in a central processor. The program has an executable form that the computer can use directly to execute...
s written for QuickBASIC
QuickBASIC
Microsoft QuickBASIC is an Integrated Development Environment and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was a short-lived version for Mac OS...
. Many programs written for QuickBASIC will compile and run in this mode with no changes needed. However, for compilation in the FreeBASIC default language mode, most substantial programs will require changes. FreeBASIC is not as related to Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
's later Visual Basic
Visual Basic
Visual Basic is the third-generation event-driven programming language and integrated development environment from Microsoft for its COM programming model...
language. For that, Gambas
Gambas
Gambas is the name of an object-oriented dialect of the BASIC programming language as well as the integrated development environment that accompanies it. Designed to run on Linux and other Unix-like computer operating systems, its name is a recursive acronym for Gambas Almost Means Basic...
is the most relevant free software project.
FreeBASIC is the name for the compiler. It does not come bundled with an IDE. Most users will need to download an IDE such as FBide, FBedit, or Geany.
Features
FreeBASIC is a self-hostingSelf-hosting
The term self-hosting was coined to refer to the use of a computer program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger...
compiler, with roughly 120,000 lines of source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...
, core only, not including libraries.
It makes use of the GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
binutils programming tool
Programming tool
A programming tool or software development tool is a program or application that software developers use to create, debug, maintain, or otherwise support other programs and applications...
s as backends and can produce console and graphical/GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...
executables, besides dynamic and static libraries. FreeBASIC fully supports the use of C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
libraries and partial C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
library support. This lets programmers use and create libraries for C and many other languages.
It supports a C style preprocessor
C preprocessor
The C preprocessor is the preprocessor for the C and C++ computer programming languages. The preprocessor handles directives for source file inclusion , macro definitions , and conditional inclusion ....
, capable of multiline macros, conditional compiling and file inclusion. However it is not a true preprocessor as it occurs at the same time as parsing. This means that it can access symbol information, and even set the dialect, which restarts parsing.
FreeBASIC has been rated close in speed with mainstream tools, such as GCC
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
.
Syntax
FreeBASIC syntax attempts to stay as close to the BASICBASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....
syntax as possible, specifically that of QuickBASIC
QuickBASIC
Microsoft QuickBASIC is an Integrated Development Environment and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was a short-lived version for Mac OS...
. Although the syntax attempts to stay compatible with its predecessor, FreeBASIC follows modern standards and coding practices. Standard procedural features, along with object-oriented features such as types as object
Object (computer science)
In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...
s, operator overloading
Operator overloading
In object oriented computer programming, operator overloading—less commonly known as operator ad-hoc polymorphism—is a specific case of polymorphism, where different operators have different implementations depending on their arguments...
, function overloading, namespace
Namespace
In general, a namespace is a container that provides context for the identifiers it holds, and allows the disambiguation of homonym identifiers residing in different namespaces....
s, etc., have been added in FreeBASIC.
FreeBASIC's lines end when the end-of-line characters are found, or with a colon
Colon (punctuation)
The colon is a punctuation mark consisting of two equally sized dots centered on the same vertical line.-Usage:A colon informs the reader that what follows the mark proves, explains, or lists elements of what preceded the mark....
. Because of this, lines don't need a special character (such as the semicolon
Semicolon
The semicolon is a punctuation mark with several uses. The Italian printer Aldus Manutius the Elder established the practice of using the semicolon to separate words of opposed meaning and to indicate interdependent statements. "The first printed semicolon was the work of ... Aldus Manutius"...
in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
) to notify the compiler of the end of line. Multiple statements may be written on one line by separating each statement with a colon
:
.FreeBASIC supports block commenting
Comment (computer programming)
In computer programming, a comment is a programming language construct used to embed programmer-readable annotations in the source code of a computer program. Those annotations are potentially significant to programmers but typically ignorable to compilers and interpreters. Comments are usually...
along with end of line remarks. Full line comments are made with an apostrophe
Apostrophe
The apostrophe is a punctuation mark, and sometimes a diacritic mark, in languages that use the Latin alphabet or certain other alphabets...
'
, while blocks of commented code begin with /'
and end with '/
.Compatibility
FreeBASIC is a successor to the QuickBASICQuickBASIC
Microsoft QuickBASIC is an Integrated Development Environment and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was a short-lived version for Mac OS...
programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
. Changes were made during development to keep FreeBASIC compatible with modern utilities, and facilitate advanced programming features. In order to keep the compiler moving forward, GCC
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
compliant, and to also retain the ability to use a QuickBASIC-compatible language, the -lang option set was created.
- When choosing Language Set FB (-lang fb as a command-line argument), all of the new features that FreeBASIC offers are available, and the "hackish" features from QuickBASIC (that were incompatible with modern programming practices) are disallowed.
- Choosing Language Set FB-Lite (-lang fblite) gives access to most of the new, non-object-oriented features of FreeBASIC, but allows a coding style similar to that of older types of BASIC. Syntax rules, such as allowing implicit variables, suffixes,
GOSUB
/GOSUBGOSUB is a command in many versions of the BASIC computer programming language. A GOSUB statement jumps to a line elsewhere in the program. That line and the following lines up to a RETURN are used as a simple kind of a subroutine without parameters or local variables.The GOSUB command may be used...RETURN
, numeric labelsLine numberIn computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.In the C...
, etc., are allowed in this lang option.
- Choosing Language Set QB (-lang qb) is similar to -lang fblite, but is more focused on specifically replicating QuickBASIC-like behavior. -lang qb is designed to make it easier to run programs originally written for QuickBASIC, and is useful in cases where -lang fblite is not compatible enough.
Example code
As in QuickBASICQuickBASIC
Microsoft QuickBASIC is an Integrated Development Environment and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was a short-lived version for Mac OS...
, a program to write a line of text to the screen can be done with a simple statement:
However, FreeBASIC adds many object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
features such as methods
Method (computer science)
In object-oriented programming, a method is a subroutine associated with a class. Methods define the behavior to be exhibited by instances of the associated class at program run time...
, constructors, dynamic memory allocation, properties
Property (programming)
A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field and a method. Properties are read and written like fields, but property reads and writes are translated to get and set method calls...
and temporary allocation.
Graphics library
FreeBASIC has a built-in 2D, QuickBASICQuickBASIC
Microsoft QuickBASIC is an Integrated Development Environment and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was a short-lived version for Mac OS...
compatible, software graphics library
Graphics library
A graphics library is a program library designed to aid in rendering computer graphics to a monitor. This typically involves providing optimized versions of functions that handle common rendering tasks. This can be done purely in software and running on the CPU, common in embedded systems, or being...
known as FBgfx (or Gfxlib), which provides simple graphics primitives (such as rectangles, lines, and circles), blitting, and more features which were not in QuickBASIC's graphics library. The library simply wraps the backend renderer. It uses OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...
on GNU/Linux and DirectX
DirectX
Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay,...
on Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
, but can be forced to use OpenGL under Microsoft Windows. This abstraction makes the built-in graphics library portable across platforms.
Although the library is built-in, it is only included if users choose to use it, which is done simply by including a call to the FBgfx Screen command. Using common libraries such as OpenGL and creating a window
Window (computing)
In computing, a window is a visual area containing some kind of user interface. It usually has a rectangular shape that can overlap with the area of other windows...
with an API (Microsoft Windows, GNU/Linux, etc.) for hardware acceleration
Hardware acceleration
In computing, Hardware acceleration is the use of computer hardware to perform some function faster than is possible in software running on the general-purpose CPU...
can be used without interfering with the FreeBASIC graphics library.
Another alternative to the built-in graphics library is Cairo
Cairo (graphics)
cairo is a software library used to provide a vector graphics-based, device-independent API for software developers. It is designed to provide primitives for 2-dimensional drawing across a number of different backends...
which can render vector images and raster images.
Future development
FreeBASIC continues to make development progress toward its goal of using GCCGNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
as a back-end, which would allow portability to nearly any modern system, and advanced optimizing
Optimization (computer science)
In computer science, program optimization or software optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources...
methods.
With the release of version 0.17, object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
(OOP) was introduced by adding classes
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...
and extending the basic type
Data type
In computer programming, a data type is a classification identifying one of various types of data, such as floating-point, integer, or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of...
. Further implementations are expected.
External links
- Official forum
- SourceForge homepage
- FreeBASIC Documentation in Wiki Format
- Freebasic portal Links & FAQ
- [ftp://ftp.linuxcenter.ru/pub/Mandriva/EduMandriva/educontrib/2009.0/i586/FreeBASIC-0.20.0b-1mdv2009.0.i586.rpm FreeBasic package for RPM-based distributions]
- German website
- Russian website
- Русскоязычный сайт
- FBide an IDE for use with the FreeBASIC compiler