views:

727

answers:

6

I am not really a fan of code golf, but I have to wonder, is there an esoteric language designed for it?

I mean a language with following properties:

  • Common programs may be expressed in very short amount of characters

  • It uses ASCII character set effectively (for example, common operators are not identifiers, so they don't have to be separated by whitespace, character usage is distributed more or less evenly because we cannot use Huffman coding and so on)

  • Except the terse syntax, it should have very expressible and clean semantics (like, let's say, Python or Scheme); it shouldn't be difficult to program in

  • It doesn't need features for large scale programs, such as OOP, but it definitely should allow custom functions and data structures

  • It should have a large standard library, identifiers in this library should be as short as possible

Maybe it should be called CG? Languages that can be a source of inspiration are Forth, APL and Joy.

+11  A: 

GolfScript

Quoting their site:

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.

The other one could be J but it is not designed to code golf

Andrea Ambu
Just hit a sample code on stackoverflow at http://stackoverflow.com/questions/1575096/code-golf-musical-notes
Etan
Seems cute. Thanks.
J S
Although, inexplicably golfscript has a dozen or so predefines that could have been abbreviated to single chars.
gnibbler
+9  A: 

I thought this was called "Perl."

Chuck
hehehehe :)))))
ldigas
+3  A: 

It used to be APL where it was considered bad form to need two lines for a program.

Though I'm not really qualified to talk about APL, as I didn't take the course Structured Programming in APL our EE department offered as part of my EE minor.

starblue
+10  A: 

Another example is HQ9+. It is not Turing-complete, so it cannot be used to solve every Code Golf challenge, but it can solve three common ones very easily in just a single character: the language only has three commands, H, which prints "Hello, world!", Q, which prints the running program's source code (quine) and 9, which prints the lyrics the the song "99 bottles of beer". It also has a fourth command, +, which increments the accumulator register. However, since there is no command for reading, testing, or otherwise accessing the accumulator register, this command is useless.

There is also an object-oriented extension of HQ9+, called HQ9++. It adds a fifth command, ++, which instantiates a new object (and, for reasons of backwards compatibility, also increments the accumulator register twice), but again, there's nothing you can actually do with that object.

Jörg W Mittag
Yes, I heard of it, but didn't remember the name. Glad you mention it, even though it doesn't fit my specs.
J S
ROFL that cracked me up. But here's a serious one - Brainfuck is Turing-complete: http://en.wikipedia.org/wiki/Brainfuck
Allon Guralnek
@Allon, Writing a BF interpreter in language X is a relatively easy way to show that X is Turing Complete
gnibbler
That is seriously crazy.
Kugel
The cool thing about HQ9+ is that it is a great example of the power of Domain Specific Languages.
Jörg W Mittag
+3  A: 
Hostile Fork
That's disgusting and I love it.
Daenyth
@Daenyth: I just submitted my first Rebmu solution to a code golf. Since there's no matrix library it didn't perform as well as I would have liked on character count, but I do think it has potential to win some of these games. :) http://stackoverflow.com/questions/3034331/code-golf-rotating-maze/3060396#3060396
Hostile Fork
@Daenyth: And now I've got a solution in that's 2 characters shorter of a perl solution in a connect-the-dots: http://stackoverflow.com/questions/2527477/code-golf-connecting-the-dots/3066878#3066878
Hostile Fork
A: 

It uses ASCII character set effectively

I have to ask: why only ASCII ? APL for example used a special character set. Dijkstra is said to have said: "It is the language of the future for the programming techniques of the past". Now that we have Unicode, we'll soon have languages of the future using modern programming techniques. Languages in which a quine would be just "✍㉂", for example. And imagine a functional language which would make a good use of all those nice mathematical symbols in the block "Miscellaneous Mathematical Symbols". That could be a code golfer's dream...

Raf