BaCon 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 (including 64bit environments), while trying to revive the days of
the good old BASIC.
BaCon can be described as a translator, a converter, a source-to-source compiler, a transcompiler or a transpiler. It also can be described as a very elaborate preprocessor to C.
BaCon is implemented in generic shell script and in itself. Therefore, to start using Bacon, the target system must have either Korn Shell, or ZShell, or Bourne Again Shell (BASH)
available. If none of these shells are available, download and install the free Public Domain Korn Shell
which can execute BaCon also. Furthermore, BaCon also works with a newer Kornshell implementation like the MirBSD Korn Shell.
The shell script implementation can convert and compile the BaCon version of BaCon. This will deliver the binary version of BaCon which has an extremely high conversion performance. On newer systems, the average conversion rate usually lies above 10.000 lines per second.
Code converted by BaCon can be compiled by GCC, the Compaq C Compiler, TCC,
the clang/LLVM compiler and possibly also by other C compilers.
- May 1, 2015: BaCon 3.0.3 released - see CHANGES. Documentation updated.
- December 1, 2014: BaCon 3.0.2 released - see CHANGES. Documentation updated.
- August 1, 2014: BaCon 3.0.1 released - see CHANGES. Documentation updated.
- May 1, 2014: BaCon 3.0 released - see CHANGES. Documentation updated.
- January 1, 2014: BaCon 2.4.0 released - see CHANGES. Documentation updated.
- October 1, 2013: BaCon 2.3.0 released - see CHANGES. Documentation updated.
- August 1, 2013: BaCon 2.2.0 released - see CHANGES. Documentation updated.
- April 1, 2013: BaCon 2.0 build 1 released - see CHANGES. Documentation updated.
- February 1, 2013: BaCon 1.0 build 29 released - see CHANGES. Documentation updated.
Older news can be found here.
BaCon Sources version 3.0.3
BaCon Precompiled Binaries and Packages
- BaCon .deb install package here version 3.0.3 (64bit).
- Redhat 5.x, 6.x, Fedora, CentOS
- BaCon .rpm install package here version 3.0.3 (64bit).
- Setld install package for Tru64 Unix v5.1 here version 3.0.2.
- Puppy Linux
- Install packages for Puppy Linux here.
Documentation and tutorials
- BaCon reference documentation in English online or as PDF or as a plain txt file or as a genuine manpage.
- BaCon reference documentation in Japanese is available here.
- Need more information about BaCon? Ask the forum or consult the BaCon WIKI pages.
- Additional info at the BaCon Bitz website.
- More questions about various BASIC dialects can be asked here.
- Base64 encoder here
- Base64 decoder here
- The Zeller algorithm here
- UTF8 encoder here
- Simple calculator program here
- CGI demonstration here
- GTK-server demo here and a Glade file here
- Brainfuck interpreter here
- Respace files here
- ROT13 encoder/decoder here
- Mastermind game here and a screenshot
- My favorite oneliner
- Recursive fibonacci and factorial functions
- Walk through a directory tree here
- Generate prime numbers here
- Generate m3u files here
- Convert decimal to Roman here and vice versa here
- A Quine program here, a smaller Quine here, even smaller here, and smaller here
- DPI calculator here created by Vovchik
- A simple GOPHER client here
- System boot time here
- Binary file dumper here
- BaCon Bullshit Bingo here created by Vovchik
- Password generator here created by Vovchik
- Testing randomness program here created by Vovchik
- The Soundex algorithm here created by Vovchik
- The Metaphone algorithm here created by Vovchik
- The Double Metaphone algorithm here created by Vovchik
- BaCon On This Day here created by Vovchik
- Calculate netmask here
- Console sinus waves here
- Check remote site here modified version here by Vovchik
- Get the weather here created by Vovchik
- Benchmark program for BaCon, for BCX and for newLisp
- Binary downloads here
- Simple BaCon Shell here
- Some goniometric functions here created by Vovchik
- Picture scaling here created by Vovchik
- Whois lookup here
- Fetch all BaCon programs here
- 99 beers on the wall here created by Vovchik
- Haiku generator here
- Genetive Algorithm here
- Print Unicode here
- Expanded 'which' here created by Vovchik
- BMI calculator here created by Vovchik
- Happy Numbers here created by Vovchik
- Play an MP3 file here
- How to use small BaCon keywords here and a full lowercase mapping here
- An MD5 calculator here created by Vovchik
- SuperFastHash here by Peter Fedorow
- Run-Length Encoder here and a Decoder here
- LZ77 Encoder here and a Decoder here
- SCTP scan here
- A simple webserver here
- Calculate md5sum here
- Console based editor here
- BaCon indent here
- BaCon sanity here
BaCon language extensions
Wrappers are BaCon functions built around external libraries.
- INCLUDE: Highlevel Universal GUI here
- INCLUDE: SQLite Database Engine here
- INCLUDE: GNU Multiple Precision Arithmetic Library here
- INCLUDE: Beep the PC Speaker here
Interfaces are straight imports from external libraries into BaCon.
- INCLUDE: OpenAL library here
- INCLUDE: ALUT library here
- INCLUDE: CURL library here created by Doyle Whisenant
- INCLUDE: MySQL Database Engine here
- INCLUDE: Lua Library here
- INCLUDE: POSIX Threads Library here
- INCLUDE: nCurses Library here
- INCLUDE: Form Library here
- INCLUDE: Panel Library here
- INCLUDE: GD Drawing Library here
- INCLUDE: Glade library here
- INCLUDE: Gtk library here
- INCLUDE: Gdk library here
- INCLUDE: GtkGlArea library here
- INCLUDE: GtkGlExt library here
- INCLUDE: GLUT library here
- INCLUDE: GLU library here
- INCLUDE: GL library here
User contributed functions
- TXT2BIN function here
- WORD$ function here
- STRCMP function here
- Many conversion functions here
- EXTRACT function here
- LTRIM function here
- PARSECOUNT function here
- PARSESTR function here
- REMAIN function here
- REPLACE function here
- RTRIM function here
- TALLY function here
- TRIM function here
Similar projects and other links
- What version of Kornshell is required? What version of ZShell is required? What version of BASH is required?
For Kornshell, any version will do. For ZShell, version 4.x or higher is required. For BASH, version 3.2 or higher is required,
version 4.x recommended.
- How is this converter licensed?
BaCon is licensed under the GPL version 3 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
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
may cause name conflicts with existing C keywords and C functions from external libraries. However, BaCon can accept lowercase also
by using the '-z' command line option.
The generated C code is hard to read!
That maybe so, as it never has been the intention to generate perfect readable C source code. However, the generated code is
portable and compilable on most Unix flavors (see below).
How to compile GTK programs in OpenBSD?
Compile as follows: ./bacon -l pthread gtkprogram.bac
How about a Win32 Version?
That will never be. This project started just because there was no decent BASIC to C converter for Unix. However, BaCon
works in a Cygwin environment. For Windows, a native Basic to C converter can be found here.
So what is the difference between BaCon and the recently released Linux BCX?
Linux BCX needs a C++ compiler. Furthermore check out this list.
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?
Why are you maintaining this project? Who are you anyway?
The Finnish programmer Kristian Virtanen held an interview with me, read it here.
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?
Which platforms are supported?
You might consider to provide a donation to keep BaCon free: