GolfScript: Difference between revisions

Content deleted Content added
Created article about GolfScript
 
 
(8 intermediate revisions by 3 users not shown)
Line 1:
#REDIRECT [[Code golf#Dedicated golfing languages]]
'''GolfScript''' is an [[Esoteric programming language|esoteric]] [[programming language]] that is [[Stack-oriented programming language|stack-based]] and designed to allow programs to be written in as few keystrokes as possible. It aims to be simple and easy to write.<ref name="official website">{{cite web|title=GolfScript|url=http://www.golfscript.com/golfscript/|accessdate=20 June 2014}}</ref> The design of the language makes it easy to use in [[code golf]]ing contests.
 
== History ==
 
GolfScript was released on 13 December 2007 and added to shinh's golf server the next day.<ref name="official website" /> The GolfScript specification was originally implemented in [[Ruby (programming language)|Ruby]] by Darren Smith.<ref>{{cite web|title=Language::GolfScript - search.cpan.org|url=http://search.cpan.org/~mob/Language-GolfScript-0.04/lib/Language/GolfScript.pod|accessdate=20 June 2014}}</ref> A [[Perl]] implementation was released by Marty O' Brien on 11 July 2011.<ref>{{cite web|title=Marty O'Brien / Language-GolfScript-0.04 - search.cpan.org|url=http://search.cpan.org/~mob/Language-GolfScript-0.04/|accessdate=20 June 2014}}</ref>
 
== Language ==
 
Programs in GolfScript consist of lists of items, each of which is pushed onto the [[Stack (abstract data type)|stack]] as it is encountered with the exception of variables which have code blocks as their value, in which case the code is executed. When a variable assignment (carried out through the placement of a colon before the name of the variable) is encountered, the top item on the stack is popped and assigned to the variable.<ref>{{cite web|title=GolfScript - Esolang|url=http://esolangs.org/w/index.php?title=GolfScript&oldid=35741|accessdate=20 June 2014}}</ref>
 
GolfScript attempts to reach its goal of solving problems in as few keystrokes as possible through the use of single symbols to represent high-level operations.<ref name="official website" />
 
== Examples ==
 
=== Hello world ===
 
The traditional [[Hello world program]] can be written in GolfScript as:<ref>{{cite web|title=anarchy golf - Results by a language|url=http://golf.shinh.org/l.rb?gs|accessdate=20 June 2014}}</ref>
 
"Hello World!"
 
=== Other examples ===
 
A program to get two numbers from standard input, add them together, and print the result can be written in GolfScript as:<ref>{{cite web|title=popularity contest - Anti-golfscript anti-golf: create a task where GolfScript or J is outgolfed by your (conventional) lang - Programming Puzzles & Code Golf Stack Exchange|url=http://codegolf.stackexchange.com/a/18817/14551|accessdate=20 June 2014}}</ref>
 
n%'+'*'"#{
}"'n/\*~
 
== References ==
 
{{Reflist}}
 
[[Category:Esoteric programming languages]]