Meta Intelligence - Writing Programs That Write Programs (Part 1: Genetic Evolution)

Metaprogramming with AI

Greg Surma
5 min readJun 4, 2019

In today’s article, we are going to learn how to write programs that write programs. The notion of programs that can generate other programs is called metaprogramming and by the end of this article, you will be able to create your own code-generating system.

Take a look at the following example of a self-generated program that prints ‘HI’ to the console.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+.

Brainf*ck

If you are confused by the above code, don’t worry - you are not alone. It’s written in an esoteric, though Turing complete programming language called Brainf*ck which is notorious for i’s unreadability. However, while being extra hard to understand for humans, it’s very simple to understand for computers.

It has only 8 instructions

“>” Increment the pointer.
“<” Decrement the pointer.
“+” Increment the byte at the pointer.
“-” Decrement the byte at the pointer.
“.” Output the byte at the pointer.
“[“ Jump forward past the matching ] if the byte at the pointer is zero.
“]”] Jump backward to the matching [ unless the byte at the pointer is zero.
“,” Input a byte and store…

--

--

Responses (3)