Menu

Differences from GolfScript

aditsu
There is a newer version of this page. You can find it here.

While similar to GolfScript in many ways, CJam also has the following differences (probably an incomplete list):

  • Support for double (floating point) numbers
  • Character type, which also enables a clear distinction between strings and arrays of numbers
  • Simplified string syntax, using only double quotes and minimal escaping (similar to single-quoted strings in GolfScript)
  • Only standard variables (uppercase letters) can be assigned, and they are initialized with various useful values
  • No support for comments; you can write comments as strings and pop them immediately, like this: "This is a comment";.
  • The input is not automatically placed on the stack; instead, there are operators for reading the input ("l", "r", "q")
  • Support for setting array values (using the "t" operator)
  • Support for converting values to specific types (using operators "a", "c", "d", "i", "s")
  • Support for "for" loops with a loop variable ("f" operator)
  • Support for "do-while" loops that do not pop the condition ("h" operator)
  • Support for short map and fold operations (":" operator)
  • The "?" (power) operator is renamed to "#"
  • The "do" operator is renamed to "g"
  • The "if" operator is renamed to "?"
  • The "." operator is renamed to "_"; dots are now used for double literals
  • The "n" built-in is replaced with the "N" variable (pre-assigned to the newline string)
  • The "base" operator is renamed to "b"
  • A number of operators are not (yet) implemented, or do not (yet) have all the meanings they have in GolfScript

MongoDB Logo MongoDB