IT Strategy

How to Use Brainf-ck as an AI Programming Language

As technology evolves, we hear about specific jobs being replaced by machines. Could the same be true for software developers? Although the thought may seem quite far out, it’s actually much closer to becoming a reality.

Artificial intelligence (AI) has been steadily growing over the years and it’s starting to show that it’s capable of developing its own programming languages by utilizing self-improving and self-modifying code in a genetic algorithm.

One programming language that you probably never heard of makes AI a possibility. It’s an obscure programming language called Brainfuck (yeah you read that right!). Created by Urban Muller in 1993, this esoteric programming language with only eight simple commands was developed to challenge coders and not for any practical use (and this, in turn, makes the name appropriate).

What makes AI possible now?

What really makes AI a possible reality today is the fact that computer technology, CPU speed, memory, and hardware have improved significantly. As a result, as machines start to compute faster, computation intensive processes that are vital for AI algorithms are now possible.

In other words, AI requires a lot of code to learn stuff and the technology needed to be powerful enough to handle the process.

What are Genetic Algorithms?

A genetic algorithm is basically AI that’s inspired by biological evolution. A genetic algorithm starts with zero knowledge about a particular subject and only has access to instructions and available tools.

What AI does here is it picks out various series of instructions randomly and checks the validity of the result. It can do this for approximately a hundred programs to find the best fit. With each generation, it will become better and more diverse.

The process is continuously repeated until the target solution is identified. Branf-ck isn’t the only AI programming language out there, for example there are others such as Assembly (ASM), but unfortunately the latter has far too many variations that complicate matters.

Brainf-ck was developed as a joke as it’s quite difficult for humans to work with. However, when it comes to computers, it turns out that it comes with several specific merits.

The following are the advantages of using brainf-ck as an AI programming language:

  • Turing complete (in theory, is capable of solving any computational problem)
  • Simple set of 8 instructions (reduces the search space and allows AI to run significantly faster)
  • Makes building an interpreter easy (as the instruction sets are easy to understand)
  • 1 byte per instruction (makes it easy to map out each gene to the programming code)
  • There’s potential to expand instructions (as the interpreter can be expanded to include support for file-system access, network capability, and graphics)

How does it work?

Think of it like a biological genome that’s made up of a group of doubles with each gene linked to an instruction in the programming language. So it starts with a random population of genomes and decodes each by converting each double into an instruction to execute the program.

The output is then basically ranked to come up with a fitness score for the program. The best genomes are paired together randomly and then crossover and mutate to create a new generation. This process will keep repeating until the desired fitness score is achieved.

This is the part that is resource intensive as the program code has to be executed for each genome. Found in .NET 4.5, this AI programming language uses Parallel to execute multiple fitness algorithms. This will use multiple CPU cores and save every ten thousand generations (in case the computer shuts down).

In the beginning, most generated programs will have difficulty to even compile and will be abandoned for a program that has some sort of output. This will then evolve until the output gets closer to the target solution.

The 8 commands used by Brainf-ck are as follows:

  • – Increment the data pointer
  • < – Decrement the data pointer
  • + – Increment
    • – Decrement
  • . – Output the Byte
  • , – Accept Input of One Byte
  • [ and ]

Although it’s AI, like all genetic algorithms, you will have to put in some work to design the fitness function. However, don’t be surprised if AI starts designing its own fitness functions in the future.

It’s the evolution of technology that makes Brainf-ck as an AI programming language possible today. So as technology evolves and becomes more powerful and faster than what’s available now, in the future, you can expect significantly larger search spaces to be computed in a matter of minutes.

What’s your experience with AI? Have you experimented with Brainf-ck? Share your thoughts and experience in the Comments section below or send us a tweet to @Intersog.

IT Storyteller and Copywriter
Andrew's current undertaking is big data analytics and AI as well as digital design and branding. He is a contributor to various publications with the focus on emerging technology and digital marketing.
Intersog does not engage with external agencies for recruitment purposes. Learn more about this here.