High and Low Complexity
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:
FNrZhTNFirst, 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.
Subscribe to:
Posts
(
Atom
)
4 comments :
Post a Comment
Please be appropriate and respectful.