15
\$\begingroup\$

Can you recommend any freely available books about code golfing in general and especially in Java and C++?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ @Joey: So are you saying that no books on leisure activities are ever published? \$\endgroup\$ Commented Jan 29, 2011 at 17:44
  • 1
    \$\begingroup\$ Relevant: see the tips tag \$\endgroup\$
    – moinudin
    Commented Jan 30, 2011 at 9:19
  • 3
    \$\begingroup\$ @Joey "Code Golf is essentially a discipline that is of no use in the real world." That's completely wrong. I'm always amazed when I hear people say this. Code golf is an excellent tool for in-depth exploration of a language, poking about in the nooks and crannies as it were. This can be immensely useful to real world programming and has been for me numerous times. \$\endgroup\$
    – Mike Bethany
    Commented Jan 31, 2011 at 19:48
  • \$\begingroup\$ Due to the evolution of this site over the years, I would say PPCG is now the best resource for learning code-golf in almost any language it's practiced in. \$\endgroup\$
    – lirtosiast
    Commented Feb 7, 2019 at 20:34

4 Answers 4

9
\$\begingroup\$

There are at least two books about golfing:

  • "Short Coding" by Ozy (only available in Japanese I think, search for it on www.amazon.co.jp)

  • The Perlgolf History book, available here.

Other recommended reading:

  • Andrew Savige's (eyepopslikeamosquito) articles on golf, accessible from his node on perlmonks

  • The language specific forums over on codegolf.com

  • The solutions to finished challenges on golf.shinh.org (look for "post-mortem").

\$\endgroup\$
7
\$\begingroup\$

Mark Byers maintains a golfing tips site. It's not a book per se, but, you may find some gems there!

\$\endgroup\$
2
  • \$\begingroup\$ Unfortunately, it hasn't been updated in quite a while. I will eventually update the Python section a bit, but don't hold your breath... \$\endgroup\$
    – hallvabo
    Commented Jan 30, 2011 at 15:26
  • \$\begingroup\$ @hallvabo: I should add a Scheme golfing tips section once I collect a few, too. :-P \$\endgroup\$ Commented Jan 30, 2011 at 15:28
7
\$\begingroup\$

When it comes to golfing in Java, it's not to be recommended.

Actually, I would go so far as to say (paraphrasing E. W. Dijkstra) that it cripples the mind, and therefore should be regarded as a criminal offense.

If you insist on doing codegolf in Java, all the basic stuff you need is found in java.util.Scanner (parsing input), java.math.BigInteger, and java.lang.String. In addition, the syntax for regexes and print formatting will come in handy.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Having fun while exploring the depths of a language only cripples an already weak mind incapable of creative thought. \$\endgroup\$
    – Mike Bethany
    Commented Jan 31, 2011 at 19:49
4
\$\begingroup\$

"the zen of optimization" by Michael Abrash has a few sections on optimizing assembly code for size. I remember there was a chapter where he squeezed every spare byte out of a ridiculously small sort function.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.