XCODX |

GolfScript Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About GolfScript

Code golf as a language-design problem essentially starts with GolfScript, which Darren Smith published in 2007 as a stack-based language implemented in Ruby. Every printable character is an operator or literal, blocks are first-class, and the interpreter prints whatever remains on the stack at exit, so many answers need no explicit output at all. GolfScript dominated Anarchy Golf and the early years of Code Golf Stack Exchange, and its stack model directly inspired CJam, and through it much of the modern golfing-language family tree. On XCODX the Ruby interpreter runs inside an authentic terminal, so programs that slurp stdin get your typed input live and there is no local Ruby environment to configure.

Hello World in GolfScript

# GolfScript prints whatever remains on the stack when the program ends
"Hello, World!"

When to use GolfScript

GolfScript remains a fine daily driver for string and list golf: fold, map, and zip are single characters, and implicit output trims the boilerplate that kills scores in mainstream languages. It is also the natural starting point for anyone studying golfing-language history before moving to CJam, Pyth, or the codepage generation. Teachers use it to introduce concatenative programming, since the whole semantics is visible as values moving through one stack.

Common questions

Why is GolfScript so terse?

Every design decision serves byte count: one-character operators, implicit stdin available as a string, implicit printing of the final stack, and heavy operator overloading so the same symbol acts sensibly on numbers, arrays, strings, and blocks. There are no keywords and almost no mandatory syntax, so program length approaches the information content of the algorithm itself.

Is GolfScript still used on Code Golf Stack Exchange?

Yes, though it rarely tops leaderboards anymore. Jelly, 05AB1E, and Vyxal typically beat it thanks to larger built-in vocabularies and compression. It still appears in new answers because it is easy to learn, well documented by thousands of old solutions, and occasionally optimal for stack-shuffling problems. On Anarchy Golf it retains a strong historical record.

How does GolfScript handle input?

All of standard input is read at program start and placed on the stack as a single string, so a program that begins executing already holds its input. Golfers then split on newlines or spaces and evaluate numbers as needed. If nothing consumes it, the input string simply gets printed back out as part of the final stack.

How GolfScript runs on XCODX

Sandbox filename
main.gs
Entry point
single main source file
Editor grammar
plain text — no highlighter ships for this language
Reading stdin
no standard input construct
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

"Hello from GolfScript!"