About
The name 'BaCon' is an acronym for 'Basic Converter'. It is a free BASIC to C translator for Unix-based systems, which runs on most Unix/Linux/BSD platforms, including MacOSX. It intends to be a programming aid in creating tools which can be compiled on different platforms (both 32bit and 64bit), while trying to revive the days of the good old BASIC.
BaCon is implemented in shell script and in itself. The shell version can convert the BaCon version of BaCon. The resulting binary has an extremely high conversion rate. On newer systems, the average conversion rate usually lies above 10.000 lines per second. BaCon can also translate itself and is therefore a self-translating translator.
The shell script version uses a common script syntax which is compatible with either BASH version 4.x and higher, or versions of KornShell released after 2012. Alternatively, the KornShell emulation in ZShell can be used to execute the shell version of BaCon as well.
The output of the converter consists of plain C code which can be compiled by various compilers, for example Clang, GCC, TCC, and the Compaq C compiler. Binaries have been produced successfully for different 32-bit and 64-bit architectures, like x86, x86_64, Arm, DEC Alpha, PowerPC and SPARC. The emitted C code also can be compiled by a C++ compiler like G++ or Clang++ which allows development with object oriented toolkits as well.
The syntax of BaCon is compliant to structured BASIC and therefore does not need line numbers. BaCon covers a common set of BASIC instructions inspired by QuickBASIC and ScriptBasic and has been expanded with modern extensions to allow network programming, regular expressions, delimited string operations, associative arrays and hash tables. It also is able to implement GUI programming for Xaw, Xaw3D, Motif, TK, and GTK version 2, 3 and 4. Next to this, BaCon can interface with existing 3rd party libraries and can easily merge with 3rd party C or C++ code.
BaCon was brought to you by a community of old-school BASIC users and took more than 15 years of development.
News
- March 15, 2024: Today BaCon exists 15 years! Celebrating BaCon 4.8 anniversary release - see CHANGES.
- January 2, 2024: BaCon 4.7.2 containing an emergency hotfix was released - see CHANGES.
- January 1, 2024: BaCon 4.7.1 released - see CHANGES. Documentation updated.
- June 1, 2023: BaCon 4.7 released - see CHANGES. Documentation updated.
- Older news can be found here
Downloads
BaCon sources version 4.8
- Autoconf source package for BaCon here or here including all GUI versions
- BaCon CHANGES
- Screenshots of BaConGUI: Legacy here, GTK4 here, GTK3 here, FLTK here, TK here and the built-in editor for ANSI compliant terminals here.
BaCon Precompiled Binaries and Packages
Debian/Ubuntu/Mint/Bodhi
Redhat 7.x, Fedora, CentOS, Mageia
- BaCon .rpm install package here version 4.8 (64bit).
Other distributions
- Install packages for OpenBSD, Tiny Core Linux, Slackware Linux and Puppy Linux are available in their repositories.
- Please verify the information from Repology to find a suitable package.
Other
- Development versions of BaCon are in the fossil repository - cloning instructions are here or download a tarball here.
- The current BaCon BETA CHANGES.
- Some older BaCon versions can be found in the museum.
- Also take a look at M4BASIC - a Basic-to-C converter written in M4!
Real World
- A project to enable Plain Shell Access to Library Modules - PSALM - fully implemented in BaCon.
- The Radio Application GUI created for several graphical toolkits here - all created with BaCon.
Documentation
- BaCon reference documentation in English online or as PDF or as Markdown Wiki.
- Still need more information about BaCon? Ask the forum.
- Additional info at the BaCon Bitz website.
Demonstration programs
- A pack of demonstration programs can be downloaded here.
- Another pack of demonstration programs at this link.
- Some BaCon reference GUI programs can be found here or here.
- More programs can be found at the Rosetta Code Wiki Pages.
FAQ
Which version of Kornshell is required? Which version of ZShell is required? Which version of BASH is required?
- For Kornshell, a recent version later than 2012 is required. For ZShell, version 4.x or higher is required. For BASH, version 4.x or higher is required.
How is this converter licensed?
- BaCon is licensed under the MIT License.
Why does BaCon need BASH or Kornshell, a.k.a. why was BaCon implemented in shell script?
- Shell script was chosen to ensure maximum Unix compatibility; on each Unix version and Linux distribution a Kornshell or BASH can be found. Now only one program has to be downloaded to perform Basic-to-C conversion, so no hazzle to download different kinds of binaries for all the different Unix versions with their particular binary formats and dependencies. If you think this is impossible or strange or lame, refer to the common Kornshell website where Kornshell is described as a command and programming language. Note that a standalone BaCon binary always can be created by compiling the BaCon version of BaCon.
When I use the MirBSD Kornshell or Public Domain Kornshell, conversion does not work!
- That's right. Even though these implementations call themselves "kornshell", there are huge differences between the various versions of Kornshell. The BaCon shell script code uses associative arrays and therefore requires a Kornshell version which supports this functionality. Until now, only KSH93 releases after the year 2012 and the KSH emulation in ZShell were found to be suitable. Please make sure to use the correct Kornshell version in order for BaCon to function correctly. Alternatively, BASH versions 4.x and higher also work fine.
Do we really need to write BaCon keywords in capitals?
- This is the default. It is a consequence of the fundamental decision to pass expressions as-they-are to the C compiler, which otherwise can cause name conflicts with existing C keywords and C functions from external libraries. For example, the Libc function 'exit' would conflict with 'EXIT', 'read' with 'READ', 'free' with 'FREE', etc. However, BaCon can accept lowercase also by using the '-z' command line option. Feel free to do so at your own risk. Your mileage may vary.
The generated C code is hard to read!
- That maybe so, but, contrary to other BASIC to C converters, BaCon is a semantic converter which attempts to translate the intention of BASIC code. Therefore, BaCon generates C code which does a lot of things for you. For example, when using string variables, BaCon automatically adds code to make sure that sufficient memory is being allocated. And if the string gets bigger, BaCon also includes code to enlarge that memory. (And BaCon also includes the required garbage collection, in case you were wondering.) Another example is that BaCon can break out nested loops to any preferred level. To achieve such functionality, loops like 'while' and 'repeat' contain extra code. And there is much more going on behind your back, to make the BASIC program work as it should. Therefore, the generated C code may look confusing and complicated.
Which platforms are supported?
- BaCon intends to be compliant with the POSIX.1-2008 standard, which can be found in any recent Unix-based platform. Examples of such platforms are Linux, BSD, Solaris, MacOSX, Haiku OS and so on. Each may be installed on any type of either 32bit or 64bit hardware.
How about a Windows Version?
- That will never be. This project started just because there was no decent BASIC to C converter for Unix. However, BaCon reportedly works in a Cygwin environment. For Windows, a native Basic to C converter can be found at the "Links to similar projects" section below.
Where can I find more free BASIC interpreters and compilers?
- Check out the website of The Free Country, they have a lot of programming tools for all kinds of languages!
Is there any relation with this BACON Basic converter or the Bacon programming language or this bacon code checker?
- No.
How to provide feedback on this project?
- There is a Message Board where all issues and problems can be logged.
Is there some other way I can help?
- You might consider to provide a donation to keep BaCon free: Paypal
Are you the author of the GTK-server project?
- Yes, I am.
Links to similar projects
- QB64 - QuickBasic 4.5 compatible C++ emitter for Windows XP, Vista, 7, 8, 8.1 and 10, Linux and Mac OSX
- UbxBasic - BASIC to C/C++ Translator based on BCX supporting Linux as well
- BCX - The Open Source BASIC to C Translator for Windows (Win32)
- Agora BASIC - BASIC compiler for POSIX systems using intermediate C code (Unix - 2008)
- GNU/Liberty Basic Compiler Collection - produces C source code from Liberty Basic source code (Unix/Win32 - 2001)
- qbcc - an open source BASIC to C translator (Win32/DOS - 2000)
- qb2c: QuickBASIC to ANSI C translator (Unix - 1998)
- Translate BASIC programs into obfuscated C programs (Unix - 1991)
- Nostalgia: Commodore BASIC V2 as a scripting language (Unix, MacOSX, Win32)
Site Info
BaCon proudly uses Fossil for its website, software versioning and revision control.
You can help to keep BaCon free by either sending a donation to the hosting site Chiselapp or to this project using Paypal.
Last update: May 4, 2024 - © Peter van Eerten.