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.

About

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, then the free Public Domain Korn Shell can be installed, 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.



News

  • December 1, 2016: BaCon 3.5 released - see CHANGES. Documentation updated.
  • November 27, 2016: Thanks to forum member Tomaaz we have a new website!
  • October 1, 2016: BaCon 3.4 released - see CHANGES. Documentation updated.
  • August 10, 2015: an OpenBSD package is available thanks to Juan Francisco Cantero Hurtado.
  • June 30, 2016: BaCon 3.3.1 released - see CHANGES. Documentation updated.
  • May 29, 2016: BaCon 3.3 released - see CHANGES. Documentation updated.
  • May 25, 2016: James Fuller has released UbxBasic, providing a Linux port of BCX! More details on the UbxBasic website.
  • January 1, 2016: BaCon 3.2.2 released - see CHANGES. No documentation changes.

Older news can be found here.



Downloads

BaCon Sources version 3.5

BaCon Precompiled Binaries and Packages

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

  • Redhat 5.x, 6.x, Fedora, CentOS
    • BaCon .rpm install package here version 3.5 (64bit). 

  • Tru64Unix
    • Setld install package for Tru64 Unix v5.1 here version 3.5. 

  • Puppy Linux
    • Install packages for Puppy Linux here.

IDE Related

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.
  • Some gory details on string optimization here.
  • Need more information about BaCon? Ask the forum.
  • Additional info at the BaCon Bitz website.
  • More questions about various BASIC dialects can be asked here.

Other



Examples

  • 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
  • The Game of Life here
  • Obtain daytime here
  • Play MIDI files here
  • ASCII Art demonstration here and here needs the STB public domain library.
  • Slash esoteric language interpreter here  



Extensions

Wrappers

Wrappers are BaCon functions built around external libraries.


Interfaces

Interfaces are straight imports from external libraries into BaCon.



FAQ

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

  • 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?
  • You might consider to provide a donation to keep BaCon free:  

  • Which platforms are supported?







Last update: December 6, 2016 - © 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 © 2016 by Peter van Eerten, template by BLACKTIE.CO, implementation by Tomaaz