BaCon - BASIC to C converter

Easy to learn

BaCon syntax is based on old-school BASIC.

Fast and powerfull

You can use the power and speed of C.


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. 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 by other C compilers), but also by C++ compilers like g++ or clang++.


  • December 1, 2019: BaCon 3.9.3 released - see CHANGES. Documentation updated.
  • September 8, 2019: BaCon 3.9.2 build 3 released - see CHANGES.
  • September 5, 2019: BaCon 3.9.2 build 2 released.
  • September 1, 2019: BaCon 3.9.2 released - see CHANGES. Documentation updated.
  • July 1, 2019: BaCon 3.9.1 released - see CHANGES. Documentation updated.
  • May 1, 2019: BaCon 3.9 released - see CHANGES. Documentation updated.
  • March 15, 2019: Today BaCon celebrates 10 years of existence!
  • January 6, 2019: It came to my attention that the original PDKSH website does not exist anymore. I made a copy and a patch here.

Older news can be found here.


BaCon Sources version 3.9.3

  • Autoconf source package for BaCon here 
  • Screenshots of GTK-based BaConGUI in action here, here and here. Screenshots of the FLTK version here, here or here in Mac OSX

BaCon Precompiled Binaries and Packages

  • Debian/Ubuntu/Mint/Bodhi
    • BaCon .deb install package here version 3.9.3 (64bit). 
    • BaCon .deb install package here version 3.9.3 (32bit). 

  • Redhat 6.x, 7.x, Fedora, CentOS, Mageia
    • BaCon .rpm install package here version 3.9.3 (64bit). 

  • MacOSX 10.8 and higher
    • BaCon .pkg install package here version 3.7.2 (64bit).

  • Other distributions
    • Install packages for OpenBSD, Tiny Core Linux and Puppy Linux are available in their repositories.

IDE Related


  • Current development versions of BaCon are in the fossil repository - cloning instructions are here.
  • Some older BaCon versions can be found in the museum.
  • Also take a look at M4BASIC - a Basic-to-C converter written in M4!


  • BaCon reference documentation in English online or as PDF or as a plain txt file or as a genuine manpage.
  • Some gory details on string optimization here.
  • Need more information about BaCon? Ask the forum.
  • Additional info at the BaCon Bitz website.


  • 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
  • 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
  • The Game of Life here
  • Obtain daytime here
  • Play MIDI files here
  • ASCII Art demonstration here and here or here needs the STB public domain library.
  • Slash esoteric language interpreter here
  • LZW Encoder here and a Decoder here
  • BaCon propriety compressor here and a decompressor here
  • A Minimal Browser here 
  • New mail indicator here 

More BaCon examples can be found on the Rosetta Code Wiki pages.



Wrappers are BaCon functions built around external libraries.


Interfaces are straight imports from external libraries into BaCon.


  • Which version of Kornshell is required? Which version of ZShell is required? Which 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 MIT License.

  • Why does BaCon need BASH or Kornshell, a.k.a. why was BaCon implemented in shell script?

    1. Shell script was chosen to ensure maximum Unix compatibility; on each Unix version and Linux distribution a Kornshell or BASH can be found.
    2. 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.

  • 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 generates C code which does a lot of things for you. For example, when using string variables, BaCon adds code which makes sure that sufficient memory is allocated. And if the string gets bigger, BaCon also includes code to enlarge that memory. Another example is that BaCon can break out 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.

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

  • 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?
  • No.

  • Are you the author of the GTK-server project?
  • Yes, I am.

  • 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:  

  • Which platforms are supported?

Last update: December 2, 2019 - © Peter van Eerten.

BaCon uses Fossil for its software versioning and revision control.

  to help the ongoing development of BaCon.

  tracks the site usage.

Copyright © 2019 by Peter van Eerten, template by BLACKTIE.CO, implementation by Tomaaz