Description #
GolfScript is a stack-based esoteric programming language designed specifically for code golfing—writing the shortest possible programs. It borrows from PostScript and Forth, using concise syntax and powerful built-in functions to achieve complex logic with minimal characters.
History #
GolfScript was created by Dominik Buro in 2007 to dominate competitive code-golfing platforms like Code Golf StackExchange. Though originally a tool for golfing, it gained popularity for its expressiveness and unconventional syntax.
Hello World Code #
"Hello, world!"
Yes—that’s it. Simply pushing a string to the stack prints it automatically. Many solutions to complex problems in GolfScript are just a few characters long.
How to Run #
Option 1: Online
Option 2: Local
Install Ruby
Clone interpreter:
Run:
ruby golfscript.rb hello.gs
Key Concepts #
- Stack-based computation
- Concise syntax for math, loops, and logic
- Uses strings, arrays, and blocks as core data types
- Implicit output of top stack item
- No variables (everything stack manipulated)
- Designed for brevity, not readability
- Functional operations over arrays
- Perfect for competitive programming
- Not Turing complete without recursion hacks
- Inspired languages like Jelly and Pyth
Try It Online #
Fun Facts #
- Entire FizzBuzz solution in GolfScript is ~18 characters
- Led to the creation of derivative languages like Jelly, Pyth, and 05AB1E
- The interpreter itself is just a few hundred lines of Ruby code