Author Topic: Code that plays with itself  (Read 61 times)

0 Members and 1 Guest are viewing this topic.

Offline slinks

  • A little bit strange
  • DBF Aficionado
  • ******
  • Posts: 3964
  • Karma: 43
    • View Profile
Code that plays with itself
« on: June 26, 2026 »
Just had my mind blown by this https://github.com/uellenberg/Insert. It's a programming language that allows for self-modifying code, and the main example is of a game of pong that is displayed as the code itself! I'm getting a headache just trying to understand the concept
I love semi-colons way too much ^^;
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1219
  • Karma: 230
    • View Profile
    • Homepage
Re: Code that plays with itself
« Reply #1 on: June 26, 2026 »
Dude, that is 2 cool, thanks for sharing!  :cheers:

Reminds me a bit me of that oroborus code thing, which coded itself into another language and another going through many languages only to end up in it’s original state. The code was shaped as an oroborus as well. This takes that conept to a whole other level!
www.kirl.nl
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1384
  • Karma: 83
    • View Profile
Re: Code that plays with itself
« Reply #2 on: Yesterday at 06:10 AM »
Neat link!

I've been using Lisp for something like 13 years and it's the OG self modifying high level language.
Essentially during the early days of AI in the 60s and 70s they designed a language (family) that was programmable because the nature of what they were creating wasn't well known so the language had to be supremely flexible. You can define new pieces of syntax and abstractions while it runs (and newer implementations even compile without stopping).

One area of classic era AI research was the ability to write functions that defined themselves and optimised themselves.
This can be done if the function has the ability to redefine parts of itself over N many trials of a task where some variations are found to be more efficient.
One practical use today would be a function that "learns" which approaches are best and then rewrites an internal strategy while testing every once in a while.

But, all this is possible because the entire syntax tree is left open and the language is made of lists which naturally can be modified by the language itself. It also helps that the language can delay evaluation and functions can be used to build and return new first class functions through combinations of other functions.
« Last Edit: Yesterday at 06:21 AM by Pixel_Outlaw »
Challenge Trophies Won: