GolfScript

GolfScript is a stack oriented esoteric programming language aimed at solving problems (holes) in as few keystrokes as possible. It also aims to be simple and easy to write.

Short code is achieved by using single symbols to represent high level operations (such as map, join, array size, etc). Being stack based allows for functions and other manipulations to work without the need for explicit variables, however variables still exist and are useful for more complicated stack manipulations.

To learn GolfScript, start with the tutorial and download the implementation. After you are comfortable with it, you may want to check out exactly how code is parsed and see all of the built ins.

If you have any suggestions or find any bugs please email me at Image:email.png

News

  • Behavior of negative exponentiation varied depending on Ruby version used to interpret Golfscript. Now it has been changed to always result in a float. However some people enjoyed exploiting the rationals that were present in Ruby 2.0+, and so that can still be done using the -r option (golfscript filename.gs -r).
      Another caveat is that previously 1**(negative integer) would result in 1 but this is rarely what you would want and there is at least one ruby version (1.9 I believe), where this would have been a rational. Now regardless of what option you use 1**(negative integer) will not be an integer. I do not wish to change the language at this point, but Ruby's inconsistency is annoying and this behavior was somewhat ill defined in golfscript to begin with.
  • Change download link to github. See commit changes for future updates.
  • Jan 7, 2021: I don't expect to have received many emails, but I just tried to wade through 8 years worth of spam. If I missed yours, please try emailing again, sorry about that.
  • Jan 7, 2021: Tem Taime wrote an unofficial interpreter in D which can run all examples on this site. It is missing some features, but check it out!
  • April 30, 2013: Peter Taylor provided a patch to speed up the operation of flatten, which was really inefficient (this has been merged to main version now).
  • Jan 6, 2013: Be sure to check out Rebmu another new human-readable code golf language by Brian Dickens, but with a completely different execution model.
  • Dec 5, 2012: Fixed behavior of array slicing when indexing out of bounds, []1> now returns [] instead of causing errors. Thanks again Ilmari.
  • Dec 3, 2012: Fixed a bug with nested do loops (ie "{ {0}do 1} do }" terminating). Thank you Ilmari Karonen!
  • Oct 31, 2011: Happy Halloween! '?' operator now works correctly for finding substrings in strings, or strings in arrays. Thank you Peter Taylor!
  • Dec 31, 2007: Ah major bug with new input method fixed.
  • Dec 26, 2007:
    • Interpreter made compliant with ruby 1.9.
    • If no input is provided, uses empty string instead of waiting for user input.
    • New operators ( ) added.
    • ~ applied to an array now dumps elements onto stack.
    • New % behavior added. Array Array % now acts like / but with empty results removed.
  • Dec 19, 2007: Bug fix, unpack('c*') caused binary characters to be negative.
  • Dec 14, 2007: GolfScript is 53rd language added to shinh's golf server. Thanks shinh! Currently the number one ranked language's average score is about 7000, let's see how much we can make it drop.
  • Dec 13, 2007: GolfScript released!