High and Low Complexity

"This image illustrates part of the Mandelbrot set fractal. Simply storing the 24-bit color of each pixel in this image would require 1.62 million bits, but a small computer program can reproduce these 1.62 million bits using the definition of the Mandelbrot set and the coordinates of the corners of the image. Thus, the Kolmogorov complexity of the raw file encoding this bitmap is much less than 1.62 million bits in any pragmatic model of computation." —Wikipedia

Most programming languages are relatively easy to read, such as a C#, or Javascript. However, not all languages are designed to be this Human-Readable. Such languages (Such as Jelly, Pyth, GolfCode, etc.) at first glance look like someone generated a random string of characters, such as this Pyth code:
WtQ=Q@,/Q2h*3QQQ
(Returns all Collatz Sequence numbers starting at Q)

However, programs written with these are rarely very long. This is certainly not by chance. Instead, these languages are designed for Code Golfing, a recreational competition to see who can write a program to get the desired output with the lowest Kolmogorov complexity. (No, that's not a Scifi show alien or something; it's the length of the program.)
Let's dissect and examine this Pyth code:
FNrZhTN 
First, the F at the start. This simply says "Start a For loop". Then make a Variable N. Set this F loop's range from Z to T, zero to ten. the "h" says include the ten in the range. Then print N.
It outputs: 0 1 2 3 4 5 6 7 8 9 10

Want to play with Pyth yourself? Here's online interpreter: http://pyth.herokuapp.com/ 

Enjoyed this article? Tell me at @Cyborus.

Thank you to @Cyborus for writing this insightful article! It is out first guest-written post. If you would like to be a guest writer, please contact Stang. 

4 comments

4 comments :

  1. I am so confused and so proud right now.

    ReplyDelete
  2. Svízel přítula posted a very insightful comment but the name of a mentioned programming language contains obscene language, so here is a censored version:

    About human-readable languages... There is one called brain****, and it has only 8 commands with no parameters. It is Tuning complete.
    It has a list of data (all 0 at the beginning) and a data pointer, and a program with an instruction pointer.
    Each command is one of the following characters, other ones are ignored.

    > - Increment data pointer (move right)
    < - Decrement data pointer (move left)
    + - Add one to the number at the data pointer
    - - Subtract one from the number at the data pointer
    , - Accept one bite of input and store it at the data pointer
    . - Output the number at the data pointer
    [ - If there is a 0 at the data pointer, go to the matching ]
    ] - If there is a nonzero at the data pointer, go to the matching [
    After each command, the program pointer goes to the right.
    Good if you want a challenge and don't want to learn complex syntax.

    ReplyDelete
  3. Hey Stang it's HappyParakeet on Scratch. Eh, never mind, you don't know me. Anyway, I love the format of your blog and I happen to be looking for something like this. I have a weebly website, but it's formatting for blogging isn't great, at all! I love how you have different sections and such. I have visited blogspot.com, could you tell me which template I could use to get yours? (I'm thinking it's the Emporio theme but I'm not sure.)

    ReplyDelete
    Replies
    1. Hello! Thanks, I'm glad you like it! Huh I don't remember if or where I stored the info about this blog design... It was quite a while ago. I found it on a Blogger template website, though.

      Delete

Please be appropriate and respectful.