Code Monkey home page Code Monkey logo

bf-it's Introduction

BF-it logo

BF-it

A compiler from a C-like language to Brainfuck

Always heard that Brainfuck is Turing complete but still had doubts about its computational power? Those days are over

What is this?

BF-it is a Compiler of a C-like language to Brainfuck, written in Python

You give it C-like code, and it gives you Brainfuck code with the same functionality :)

Why did you create it?

There are several reasons why I chose to create this

  1. I always heard that Brainfuck is Turing complete, and therefore as strong as any other language
    • I wanted to put that to the test, and find a concrete proof that it is true
  2. I find it beautiful how a seemingly bunch of nonsense characters can have a logical meaning / functionality
    • I wanted to take it to the extreme
  3. I wanted to practice my developing skills
  4. It seemed to be like a real challenge (and it was!)
  5. But mostly, and most importantly, I did it for teh lulz

What can I use it for?

Create a Brainfuck code of your choice, send it to your friends, and tell them to run it (on some online interpreter, for example)

When they receive a bunch of nonsense which does something meaningful, they will (maybe) be amazed

How do I use it?

  1. Write a C-like code (example programs included) into a file
  2. Open your favorite command line interface
  3. Run BF-it.py <path_to_code_file>
    • This will compile your file and create a .bf file with Brainfuck code
    • (optional parameters: -o for output file, and -r for running the compiled file)
  4. Run Interpreter.py <path_to_bf_file>, this will execute the Brainfuck code

Example:

$ cat helloworld.code
int main()
{
    print("Hello World!\n");
}

$ ./BF-it.py helloworld.code
Compiling file 'helloworld.code'...
Compiled successfully to 'helloworld.bf'
$ cat helloworld.bf 
>[-]>[-]<>++++++++[-<+++++++++>]<.>++++[-<+++++++>]
<+.+++++++..+++.>++++++[-<------------->]<-.>+++++[
-<+++++++++++>]<.>++++[-<++++++>]<.+++.------.-----
---.>++++++[-<----------->]<-.>+++[-<------->]<--.<

$ ./Interpreter.py helloworld.bf
Hello World!

For a more interesting example, check out Tic-Tac-Toe!

Tic-Tac-Toe

  1. Take a look at tic_tac_toe.code in the 'examples/games' directory
  2. Run ./BF-it.py examples/games/tic_tac_toe.code -r
  3. Play around
  4. If you're brave, take a look at the generated Brainfuck code
  5. If you're very brave, try to understand it (I can't)

How do I write code?

Please refer to the 'examples' directory. It contains examples and explanations for syntax, operations, flow, and more

I would like to add a feature / fix a bug

If you would like to add a feature yourself, perform a pull request and add your changes. I will review them

If you found a bug, or have an idea for a feature, open an issue

References I used:

bf-it's People

Contributors

elikaski avatar makolath avatar mrkct avatar neeeoo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.