This project is an open sourced implementation of a BASIC language interpreter, which was originally based upon the Berkeley DB software. In addition to supporting file based Berkeley databases, it now includes PostgreSQL support with the new USING statement.
New users should plan on using the PostgreSQL database only. Use of the Berkeley DB is now depreciated and may be omitted from future releases.
- Installing on Linux and Cygwin (Supported Platforms and General Install Notes)
- Installing on FreeBSD
- Installing on Darwin (Mac OSX)
- Installing on Solaris (SunOS)
- Installing on HP-UX
- Installing on IBM's AIX
- The 'make install' step
- Installing the distributed BASIC applications
Using bdbbasic Resources
If you are experiencing difficulties with the present release, check back here regularly. These documentation resources get updated as platform related issues are resolved. Another important resource is the Change Log.
Change Log and CVS Notes
Release 0.77 is available. This release supports the PostgreSQL database, which will be the focus of all future development. This is allows development of multi-user systems in a transactional environment.
If you are looking for a "student edition" without the added complexity of administration of the PostgreSQL database server, you can build a Berkeley DB only version of bdbbasic. However, the disadvantage of this approach is that the distributed diagnostic utilities require the PostgreSQL database server.
The latest developments are found in the ChangeLog. This is updated regularly.
If you are looking for information about how to use PostgreSQL from bdbbasic, see USING Statement.
With literally hundreds of other BASIC dialects out there, you need to know how bdbbasic differs. Listed below are some of the features supported by the bdbbasic project:
- Open sourced
- Designed to be simple to program by non-programmers, whether SOHO operators, hobbyists, scientists, or engineers.
- Designed to be "database powerful" with a minimum of programming.
- Supports stand alone Berkeley DB databases and PostgrSQL for multi-user based systems.
- Modular - ability to call external BASIC modules and pass arguments to local subroutines.
- Simple for writing screens, complete with attribute and colour control (a screen generator application is included).
- Automatically dumbs down for monochrome dumb terminals (no need to IF-out colour controls for monochrome terminals).
- Few if any, hard-coded constants. The interpreter provides a few built-in structures with constants that can be referred to by name.
- Functionality and simplicity first (not necessarily compactness or execution speed)
- Business and programmer friendly features (for example the PIC$() function to format numbers)
- Error handler friendly (renumbering the program does not upset line number references in the handler).
The addition of the PostgreSQL database interface permits the end user to build large/shared multi-user applications. The programs saved in the database are endian neutral, ensuring that they will be executable on all connected platforms.
The following diagram shows the possibilities:
In the above diagram:
- One or more database servers can be housed in separate hosts dedicated to the task (Postgres servers A, B and C)
- Laptops and desktops can run bdbbasic directly, connecting to the database servers, or database servers on their local machines.
- Servers can host bdbbasic (left) using dumb terminals in a warehouse.
- The same servers with bdbbasic installed can also be used by laptops and desktops using remote sessions (this saves installing bdbbasic on each desktop)
- All bdbbasic sessions will share the same basic code stored on the Postgres database(s).
Bdbbasic code is designed to be endian neutral, so that any hardware can host bdbbasic and use the shared basic code on a given database.
- Data General's MICOS BASIC was the initial inspiration for some interpreter concepts.
- Ada95 inspired the implementation of arrays, array slicing and the enumerated data type.
- The built-in records and constants are the author's own innovation for BASIC.
The following paragraphs apply to bdbbasic's original Berkeley DB interface. Release 0.77 also supports an SQL interface to Postgres database servers.
The Data General MICOS BASIC had this concept of a "random" file and the optional use of one or more "indexes". The way an indexed record was created was done with multiple steps in the BASIC program:
- "slot" a record to have a record assigned (a record address was returned)
- Write the record contents (although this could be done in one step using the SLOT statement)
- Use one or more "insert index" statements to add the necessary index entries pointing to this record
While this process was simple, it placed the burden of managing indexes on the programer. Frequently an erroneous program would fail to delete certain indexes when a record was deleted. Alternatively a record's key field would be updated, but the secondary indexes would retain stale key values because the program wasn't written properly to manage this. Ultimately this would lead to data integrity issues in the underlying database.
No Indexing Burdens
Bdbbasic completely eliminates the burden of maintaining indexes. A small amount of extra effort is required when the database table is initially created. But once created, the programmer is freed entirely from the burden of managing indexes.
When PostgreSQL is used, the database engine does all of the work. This makes for a very useful multi-user based system.
No Record Format Burdens
In bdbbasic, the programmer is also free of having to redefine the table's record format (columns) in every referencing program. MICOS BASIC required programs to define the physical record layout. Then the program had to extract and update the various portions of the physical record based upon a fixed format. This was tedious and error prone, especially when a record needed to be expanded.
Bdbbasic manages the definition of the columns of the table, much like an SQL database. When a bdbbasic table is opened, a "RECORD" type is created automatically by the interpreter to manage the input/output of values to and from that table. The programmer is never required to declare this record in his program. This permits the table to be expanded at a later date, without changes to the existing programs.
Berkeley Database Features:
Since bdbbasic was initially based upon the Berkeley DB software, it's DB features are heavily influenced by Berkeley's features and operation. Note that Berkeley's own documentation uses different database terminology than will be used here in connection with bdbbasic.
Note that the Berkeley DB access methods are now depreciated in bdbbasic now that PostgreSQL is supported. But it remains in the project because it may still be suitable for "student editions".
In the context of bdbbasic, the following terms apply:
- A "database" is a collection of "tables" (and sequences)
- A table is a collection of "rows" (records), which are subdivided into "columns"
The interpreter supports the following basic database concepts for the Berkeley DB:
- Each database is stored in one physical file (*.db)
- Zero or more tables, reside in the database
- Columns are managed by the interpreter for each table in the database
- Secondary indexes are also managed by the interpreter for each table
- Sequences can be defined and used by the user in BASIC programs
- One implicit cursor is provided with each opened table
- A table may be opened for read only, or for update (the statements are self documenting about their access)
Bdbbasic uses SQL terminology that is consistent with PostgreSQL support found in release 0.77 or later.
One feature of the Data General's MICOS basic was that all string variables were fixed in length. This was especially useful for use with their indexed records. There are times however, when a variable length string is simply more convenient to an application writer. For this reason, bdbbasic supports both fixed and variable length strings.
A summary of some of the non-database features of bdbbasic are listed below:
- Fixed length strings are supported (for COBOL like processing)
- Variable length strings are supported (with a defined maximum length)
- Arrays of strings (unsupported by MICOS BASIC)
- All variables must be declared prior to use (this leads to better programming practices)
- SHORT numeric data type (signed 16-bit integers)
- LONG numeric data type (signed 32-bit integers)
- FIXED numeric data type (gmplib big integers, scaled)
- DIM numeric data type (floating point real numbers -- "C double type")
- RECORD data type (a collection of string and numeric data items)
- Assignment of RECORD variables (copy one record to another)
- Comparison of RECORD variables (equality or inequality only)
- Strongly typed Enumerated types and variables (See ENUM)
- Arrays to 3 dimensions.
- Sparse array support.
- Ada95 inspired choice of subscript ranges (0 to N-1 by default)
- Ada95 Array "slicing" of string values
- INPUT and OUTPUT statements to support spreadsheet CSV format file I/O (not just input).
- Like arrays may be assigned using the LET statement (like any variable assignment)
- UNIX script friendly with file unit numbers (standard input, output, error and others)
- Supports full screen I/O (curses) in addition to tty mode for shell like processing.
- Should be usable with dumb terminals in a warehouse, for example.
- Supports windowing and menus for ease of use.
- Uses line numbers (see below for the reasons)
- Programs are "SAVEd" into the MASTER database for quick access, and allows calling and chaining of programs.
The built-in support for Berkeley DB database files, make bdbbasic an excellent choice for those just wanting a personal productivity tool.
Those wishing to share database resources and bdbbasic programs, should plan on using Postgres database services.
PostgreSQL database support means that bdbbasic can be used as a multi-user system. This allows many users to concurrently access and update common database resources. All connected systems will enjoy shared access to both the data and bdbbasic programs.
The fact that bdbbasic already supports dumb terminals, opens the possibility of using it for small business and warehouse scenarios without the high PC level costs. Alternatively, low cost/discarded PC hardware can be used running Linux or FreeBSD to host the bdbbasic client program.
Why Use Those Dreaded Line Numbers?
One criticism that might be raised is that this interpreter uses line numbers on every program statement. Based upon the material at wikipedia, this BASIC dialect would be classified as a "First Generation Basic". Given that wikipedia lists the current generation as "Third Generation BASIC", this may seem like a backward step. So why does a modern project use these line numbers?
End User Simplicity
The main reason bdbbasic uses line numbers, is to make things easier for the end-user. That's right-- the end user. The focus of this project is to put the power of database technology into the hands of the non-programmer. Not everyone wants to make a career out of every application programming assignment.
Line numbers simplify documentation and end-user learning. When using line numbers, it is not necessary to show screen shots of how to find and use everything. All the user needs to be shown is to "type this" and then it works! Simplicity at its best.
BASIC Has Lost Its Way
Presently it seems that it is necessary for people like business analysts and other non-programmers to take night school courses on Microsoft's Visual Basic (or its modern equivalent). There is something really wrong when "special training" is necessary to get someone started in BASIC programming. The very roots of the language was based on simplicity. Consequently, I believe that BASIC has lost its way.
It started off being simple to use and simple to learn. Then it later became more complicated to accommodate additional "programmer" wants and needs. Simplicity for the non-programmer was lost accommodating experienced programmer prejudices against line numbers.
Line Number Simplicity
Line numbers simplify four major areas:
- Editing of the program
- The programming itself
- Programming text(s) that describe programming concepts
- Mode-less dialog with the interpreter
The original design of BASIC was clever in its use of line numbers. This is perhaps the simplest editor that can be imagined. Any child or adult can very quickly learn to insert, replace or delete lines with numbers. Minimal instruction, lists of rules or procedures need to be given. Just a few very basic principles and the user is able to list and edit a program.
The Simplicity of Text
Text commands are also much simpler to describe and understand. This greatly aids self-training. Text based illustrations are very good ways of teaching computer concepts when graphic menus and a mouse are not required. It is much simpler to train someone to "use this command or statement" than it is to show them around a GUI interface.
Finally, this last advantage should not be overlooked. When typing a line into the interpreter, lines starting with line numbers edit the current program. Otherwise they are interpreted and acted upon immediately. This is a very natural way of working with the BASIC interpreter. In fact, it is so natural, that it barely needs to be described. Once the user has seen it once, they will never forget it. It doesn't get any easier than that.
Who Should Use bdbbasic?
This project was created to scratch an itch like many open sourced projects. As the author gets older and finds available programming time scarcer, the need for a simplified but powerful programming environment became desirable. I was looking for an open sourced package that provides rapid "screen" and a "database" facilities in one cohesive environment. One that doesn't require you to memorize gui library API and objects.
There are several dialects of BASIC available, but many of them are proprietary and require a purchased license. I didn't want to lock my efforts into products whose future is uncertain. The author found few, if any opened sourced BASICs that included any kind of database facility. Database facilities are simply mandatory in today's software world. The simple random file just isn't good enough.
It has also been recognized that small home and office (SOHO) users have similar needs. They need to manage increasing amounts of information. The challenge is to create and maintain custom software without hiring programming staff.
This dialect of BASIC is designed to provide powerful database functionality with simple to program screen capabilities (sometimes the development cost of a GUI interface is just not worth it). A non-programmer should find this dialect of BASIC to be easy to learn. Certainly the interactive nature of the interpreter goes the extra mile in self-learning.
It should be so easy to learn, that the user can learn this from a book with some tutorial examples. Just like the good old days when people were working with Dartmouth BASIC. This should permit most small business owners to use bdbbasic to manage everything from basic accounting to invoicing and inventory control.
Accountants will love the FIXED data type for precise storage of monetary values. Precise monetary calculations can be performed as if they were integers. This means not suffering with round off errors that are so common when using floating point data types. Because FIXED values are implemented as big integers (gmplib), they have unlimited precision. This makes them perfect for tracking those corporate executive bonuses.
Scientists and technologists should also find bdbbasic useful. They too are more interested in having the computer serve them in research and engineering needs. Sparse arrays and the Gnu Scientific Library resources enhance this capability.
All too often we end up slaves to the computer. The bdbbasic interpreter puts the computer to work for the end user instead.
Applications for bdbbasic
In short, if you don't want to make a career out of programming but have some custom programming needs, then bdbbasic may be just what you need. Especially given that it is open sourced and will install on most modern platforms, including Microsoft's Windows (under Cygwin). Linux, FreeBSD, Mac OSX, Solaris, HPUX and IBM's AIX are all known to host bdbbasic successfully.
Some of the uses for this software may include:
- Small or larger SOHO database system(s)
- Accountants needing precise FIXED(2) data types for monetary storage and computation
- An engineering tool to test out mathematical ideas
- Scientists that need to calculate and store data in databases
- Quick and dirty utilities to just "get things done"
- An alternative to UNIX shell scripts, but with some real programming capability
- Learn programming and database concepts
Don't forget one of the major advantages of this project-- it is open sourced! This means that it will never be unavailable. No matter what operating system you use in the future, you can rest assured that you will be able run this product on it. If you can run bdbbasic, then your application programming investment will also be safe.
To keep up to date on the latest changes and developments, be sure to visit the ChangeLog from time to time. As changes and bugs are fixed, they are documented online through this log.