FreeBASIC

Last updated
FreeBASIC
Fblogo.gif
FreeBasic help.png
Paradigm Procedural, object-oriented
Designed by Andre Victor [1]
Developer The FreeBASIC Development Team
First appeared2004;20 years ago (2004)
Stable release
1.10.1 / December 25, 2023;7 months ago (2023-12-25)
Typing discipline Static
OS MS-DOS, FreeBSD, Linux, Microsoft Windows
License GNU GPLv2+, Standard libraries licensed under the GNU LGPLv2+
Website www.freebasic.net
Influenced by
QuickBASIC, C

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]

Contents

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]

Compiler features

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.

Syntax

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.

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 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.

Language dialects

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:

Example code

Standard programs, such as the "Hello, World!" program are done just as they were in QuickBASIC.

Print"Hello, World!"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.

TypeVectorPrivate:xAsIntegeryAsIntegerPublic:DeclareConstructor(nXAsInteger=0,nYAsInteger=0)DeclarePropertygetXAsIntegerDeclarePropertygetYAsIntegerEndTypeConstructorVector(nXAsInteger,nYAsInteger)x=nXy=nYEndConstructorPropertyVector.getXAsIntegerReturnxEndPropertyPropertyVector.getYAsIntegerReturnyEndProperty
DimAsVectorPtrplayer=NewVector()*player=Type<Vector>(100,100)Printplayer->getXPrintplayer->getYDeleteplayerSleep'Prevents the program window from closing instantly

In both cases, the language is well suited for learning purposes.

Related Research Articles

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with Apple II computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC because of the Apple DOS command FP used to invoke it, instead of INT for Integer BASIC.

<span class="mw-page-title-main">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

<span class="mw-page-title-main">Blitz BASIC</span>

Blitz BASIC is the programming language dialect of the first Blitz compilers, devised by New Zealand-based developer Mark Sibly. Being derived from BASIC, Blitz syntax was designed to be easy to pick up for beginners first learning to program. The languages are game-programming oriented but are often found general purpose enough to be used for most types of application. The Blitz language evolved as new products were released, with recent incarnations offering support for more advanced programming techniques such as object-orientation and multithreading. This led to the languages losing their BASIC moniker in later years.

<span class="mw-page-title-main">Dylan (programming language)</span> Multi-paradigm programming language

Dylan is a multi-paradigm programming language that includes support for functional and object-oriented programming (OOP), and is dynamic and reflective while providing a programming model designed to support generating efficient machine code, including fine-grained control over dynamic and static behaviors. It was created in the early 1990s by a group led by Apple Computer.

<span class="mw-page-title-main">GW-BASIC</span> Dialect of the BASIC programming language

GW-BASIC is a dialect of the BASIC programming language developed by Microsoft from IBM BASICA. Functionally identical to BASICA, its BASIC interpreter is a fully self-contained executable and does not need the Cassette BASIC ROM found in the original IBM PC. It was bundled with MS-DOS operating systems on IBM PC compatibles by Microsoft.

<span class="mw-page-title-main">Oberon (programming language)</span> General-purpose programming language

Oberon is a general-purpose programming language first published in 1987 by Niklaus Wirth and the latest member of the Wirthian family of ALGOL-like languages. Oberon was the result of a concentrated effort to increase the power of Modula-2, the direct successor of Pascal, and simultaneously to reduce its complexity. Its principal new feature is the concept of data type extension of record types. It permits constructing new data types on the basis of existing ones and to relate them, deviating from the dogma of strict static typing of data. Type extension is Wirth's way of inheritance reflecting the viewpoint of the parent site. Oberon was developed as part of the implementation of an operating system, also named Oberon at ETH Zurich in Switzerland. The name was inspired both by the Voyager space probe's pictures of the moon of the planet Uranus, named Oberon, and because Oberon is famous as the king of the elves.

Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal.

<span class="mw-page-title-main">Lua (programming language)</span> Lightweight programming language

Lua is a lightweight, high-level, multi-paradigm programming language designed mainly for embedded use in applications. Lua is cross-platform software, since the interpreter of compiled bytecode is written in ANSI C, and Lua has a relatively simple C application programming interface (API) to embed it into applications.

<span class="mw-page-title-main">QuickBASIC</span> IDE for the BASIC programming language

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 also a short-lived version for the classic Mac OS. It is loosely based on GW-BASIC but adds user-defined types, improved programming structures, better graphics and disk support and a compiler in addition to the interpreter. Microsoft marketed QuickBASIC as the introductory level for their BASIC Professional Development System. Microsoft marketed two other similar IDEs for C and Pascal, viz QuickC and QuickPascal.

<span class="mw-page-title-main">PowerBASIC</span> Software compiler

PowerBASIC, formerly Turbo Basic, is the brand of several commercial compilers by PowerBASIC Inc. that compile a dialect of the BASIC programming language. There are both MS-DOS and Windows versions, and two kinds of the latter: Console and Windows. The MS-DOS version has a syntax similar to that of QBasic and QuickBASIC. The Windows versions use a BASIC syntax expanded to include many Windows functions, and the statements can be combined with calls to the Windows API.

Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first version of BASIC published by Microsoft as well as the first high-level programming language available for the Altair 8800 microcomputer.

<span class="mw-page-title-main">F Sharp (programming language)</span> Microsoft programming language

F# is a general-purpose, high-level, strongly typed, multi-paradigm programming language that encompasses functional, imperative, and object-oriented programming methods. It is most often used as a cross-platform Common Language Infrastructure (CLI) language on .NET, but can also generate JavaScript and graphics processing unit (GPU) code.

IDL, short for Interactive Data Language, is a programming language used for data analysis. It is popular in particular areas of science, such as astronomy, atmospheric physics and medical imaging. IDL shares a common syntax with PV-Wave and originated from the same codebase, though the languages have subsequently diverged in detail. There are also free or costless implementations, such as GNU Data Language (GDL) and Fawlty Language (FL).

Object Pascal is an extension to the programming language Pascal that provides object-oriented programming (OOP) features such as classes and methods.

C# and Visual Basic (.NET) are the two main programming languages used to program on the .NET framework.

This comparison of programming languages (array) compares the features of array data structures or matrix processing for various computer programming languages.

<span class="mw-page-title-main">QBasic</span> IDE for the BASIC programming language

QBasic is an integrated development environment (IDE) and interpreter for a variety of dialects of BASIC which are based on QuickBASIC. Code entered into the IDE is compiled to an intermediate representation (IR), and this IR is immediately executed on demand within the IDE.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

<span class="mw-page-title-main">Cg (programming language)</span> Shading language

Cg and High-Level Shader Language (HLSL) are two names given to a high-level shading language developed by Nvidia and Microsoft for programming shaders. Cg/HLSL is based on the C programming language and although they share the same core syntax, some features of C were modified and new data types were added to make Cg/HLSL more suitable for programming graphics processing units.

References

  1. "freeBASIC about page". freeBASIC compiler. Retrieved 5 February 2012.
  2. FBWiki : FaqPgxbox
  3. freeBASIC Programming Language: Official Web site
  4. "freeBASIC official website downloads page". freeBASIC compiler. Retrieved 13 May 2017.
  5. "freeBASIC dialects". coderJeff's home page. Retrieved 5 February 2012.
  6. "Differences from QB". freeBASIC.net documentation. Retrieved 5 February 2012.
IDEs