FreeBASIC
![]() |
|
| Paradigm(s) | Procedural, object-oriented |
|---|---|
| Appeared in | 2004 |
| Designed by | Andre Victor[1] |
| Developer | The FreeBASIC Development Team |
| Stable release | 0.23 (August 7, 2011) |
| Typing discipline | Static |
| Influenced by | QuickBASIC, C |
| OS | DOS, FreeBSD, Linux, Microsoft Windows |
| License | GNU GPL, Standard libraries licensed under the GNU LGPL |
| Website | www.freebasic.net |
FreeBASIC is a free/open source (GPL), 32-bit BASIC compiler[2] for Microsoft Windows, protected-mode DOS (DOS extender), Linux, FreeBSD and Xbox (no longer maintained).[3]
According to its official website,[4] FreeBASIC provides syntax compatibility with programs originally written in QuickBASIC. Unlike QuickBASIC, however, FreeBASIC is a compiler only and users must manually download, install and configure their IDE of choice.[5] IDEs specifically catered to FreeBASIC include FBide and FbEdit.
Contents |
[edit] Compiler Features
On its backend, FreeBASIC makes use of GNU binutils in order to produce console and GUI 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 x86 native development environments.
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.
[edit] Syntax
Initially, FreeBASIC emulated QBASIC syntax as closely as possible. However, as the language evolved, breaking away from this was necessary. As a result, FreeBASIC now offers several language dialects.[6] New features include support for types as objects, operator overloading, function overloading, namespaces and others.[7]
End-of-line characters indicate the termination of programming statements. Multiple statements may be written on a single line by separating each statement with a colon.
FreeBASIC supports block commenting as well as end of line remarks. Full line comments are made with an apostrophe ', while blocks of commented code begin with /' and end with '/.
[edit] Graphics library
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 GNU/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.
[edit] Language dialects
As FreeBASIC has evolved, changes have been made which required breaking older-styled syntax. In order to continue supporting programs written using the older syntax, FreeBASIC now supports the following dialects:
- The default dialect (-lang fb as a command-line argument) supports all new compiler features and disallows archaic syntax.
- The FB-lite dialect (-lang fblite) permits use of most new, non-object-oriented features in addition to older-style programming. Implicit variables, suffixes,
GOSUB/RETURN, numeric labels and other features are allowed in this dialect.
- The QB dialect (-lang qb) attempts to replicate QuickBASIC behavior and is able to compile many QuickBASIC programs without modification.
[edit] Example code
Standard programs, such as the hello, world program are done just as they were in QuickBASIC.
Print "Hello, World!"
FreeBASIC adds to this with support for object-oriented features such as methods, constructors, dynamic memory allocation, properties and temporary allocation.
Type Vector Private: X As Integer Y As Integer Public: Declare Constructor (nX As Integer = 0, nY As Integer = 0) Declare Property GetX As Integer Declare Property GetY As Integer End Type Constructor Vector (nX As Integer, nY As Integer) X = nX Y = nY End Constructor Property Vector.GetX As Integer Return X End Property Property Vector.GetY As Integer Return Y End Property Dim as Vector ptr Player = new Vector() *Player = type<Vector>(100, 100) Print (*Player).GetX Print (*Player).GetY delete Player
[edit] Future development
Using the GCC as a back-end remains on the FreeBASIC TODO list.[8] However, since 2008, official updates to the compiler have been anywhere from six months to years apart.[9]
Inheritance has been added to the FreeBASIC source repository and should be available in the next stable product release.[10]
[edit] References
- ^ "FreeBASIC about page". FreeBASIC compiler. http://www.freebasic.net/about. Retrieved 5 February 2012.
- ^ Lee Seats. "FreeBASIC the Successor to QuickBASIC". About.com. http://freebies.about.com/od/computerfreebies/qt/freebasic.htm. Retrieved 2008-08-17.
- ^ FBWiki : FaqPgxbox
- ^ FreeBASIC Programming Language: Official Website
- ^ "FreeBASIC official website downloads page". FreeBASIC compiler. http://www.freebasic.net/get. Retrieved 5 February 2012.
- ^ "FreeBASIC dialects". coderJeff's home page. http://www.execulink.com/~coder/freebasic/compare.html. Retrieved 5 February 2012.
- ^ "Differences between QBASIC and FreeBASIC". FreeBASIC.net documentation. http://www.freebasic.net/wiki/wikka.php?wakka=LangQB. Retrieved 5 February 2012.
- ^ "FreeBASIC Todo List on SourceForge". http://fbc.svn.sourceforge.net/viewvc/fbc/trunk/FreeBASIC/src/compiler/TODO.txt?view=markup. Retrieved 2007-07-31.
- ^ "FreeBASIC compiler news". FreeBASIC.net official forum. http://www.freebasic.net/forum/viewforum.php?f=17. Retrieved 5 February 2012.
- ^ "FreeBASIC 0.22 released". FreeBASIC forum. http://www.freebasic.net/forum/viewtopic.php?f=1&t=17813. Retrieved 5 February 2012.
[edit] External links
| Wikimedia Commons has media related to: |
- Official website
- Official forum
- SourceForge homepage
- FreeBASIC Documentation in Wiki Format
- German website
- Russian website
- Русскоязычный сайт
|
||||||||||||||||||||||||||||||||
- BASIC programming language family
- BASIC compilers
- Free compilers and interpreters
- Object-oriented programming languages
- Procedural programming languages
- Free computer libraries
- Self-hosting software
- Free software programmed in BASIC
- DOS software
- Windows software
- Linux programming tools
- Programming languages created in 2004
