FreeBASIC
From Wikipedia, the free encyclopedia
![]() |
|
Paradigm: | Procedural |
---|---|
Appeared in: | 2004 |
Developer: | Andre Victor |
Latest release: | 0.16 Beta / 2006-06-11 |
Typing discipline: | Static |
Dialects: | BASIC |
Influenced by: | QuickBASIC, C |
OS: | DOS, Linux, Windows |
License: | GNU GPL |
Website: | http://www.freebasic.net |
FreeBASIC is a free/open source (GPL), 32-bit BASIC compiler for Microsoft Windows (32-bit), protected-mode DOS (DOS extender), the Xbox and Linux (x86), and is being ported to other platforms.
It makes use of the GNU binutils programming tools as backends and can produce console, QuickBasic-compatible graphical and GUI executables, besides dynamic and static libraries. A GCC frontend is currently being developed, which will enable compilation for many more operating systems than currently supported.
Currently, software libraries like GTK+, GSL, SDL, Allegro, Lua and OpenGL can be used directly (read: No wrappers, only function and structure prototypes), and more are being added on every new release. A complete set of the Windows API headers is also included.
Contents |
[edit] Syntax
FreeBASIC attempts to stay as close to the BASIC syntax as possible, specifically QuickBASIC's syntax. While FreeBASIC does attempt to stay true to its predecessor syntax-wise, it has added the following features:
- Unicode support
- User-defined Types (UDT's)
- Pointers
- Unsigned data types
- Function overloading
- Inline Assembly
- Typedefs
- Variable initializers
- Preprocessor
- Name spaces
Lines of code are ended with either a colon, or when the line ends. Comments can be made either to comment an entire line, or a block of code such. Full line comments are made with ', while blocks of commented code are created via /' and ended with '/.
UDT's and child types are separated by .'s (as in many other languages). Pointers are dereferenced via * or ->, as in C; taking the address of an object is done with @ (roughly equivalent to C's &).
The latest version in development, 0.17, adds object orientation support, but removes support for the following features if the -lang qb or -lang deprecated command-line options are not used:
- implicit variables
- suffixes (! # $ % &)
- default BYREF parameters
- OPTION's of any kind
- periods in symbol names
- GOSUB/RETURN
- ON .. GOSUB|GOTO
- ON ERROR | RESUME
- '$DYNAMIC, '$STATIC, '$INCLUDE meta-commands
- CALL or LET
- Numeric labels
[edit] Hello, World! example
Print "Hello, World!" Sleep
[edit] Graphics
More recent builds of FreeBASIC have a built-in 2d graphics library that provides graphics primitives (such as rectangles, lines, and circles), blitting, and alpha blending, among other things. Graphics in FreeBASIC is highly optimized, providing a fast, practical framework without the developer having to worry about specific implementation issues. For this reason, one of the most common uses for FreeBASIC is game development.
[edit] Future plans
Currently, there are plans to incorporate object-oriented syntax into FreeBasic. As of January 20, 2007, FreeBasic supports nearly all aspects of object-oriented programming, with the exceptions of inheritance and polymorphism.
[edit] Trivia
- The FreeBASIC compiler is self-hosting and is nearly 90,000 lines of code.
- The first version of the compiler was written in Visual Basic for DOS.