-5
\$\begingroup\$

The challenging nature of aggressively optimizing for program size has itself long been recognized
Wikipedia

In the old days, memory was very limited

The larger 360 models could have up to 8 MB of main memory, though main memory that big was unusual—a large installation might have as little as 256 KB of main storage, but 512 KB, 768 KB or 1024 KB was more common.
Wikipedia.

Optimising for every scrap of memory made sense in those days and earlier. Now that everyone's laptop is more memory rich than all but the largest mainframes, I see no point in the activity.

What we need now is programs that optimise for speed. A program that runs in 20 minutes instead of 20 hours is worth looking for.

Discussion points

(a) Do such speed contests exist and if so what are they called and where can they be found?

(b) If not, why not?

(c) Is code-golf an anachronism?

P.S. Fewer bytes of high-level code does not necessarily translate to fewer bytes of machine code. Languages that are designed for brevity rather than comprehensibility are always going to win - aren't they?

| |
\$\endgroup\$
  • 2
    \$\begingroup\$ We have [fastest-code] challenges. Are you looking for something like that? Besides, code golf is not about optimizing for memory, but about optimizing for code size, because producing a list of all permutations and choosing the lexicographically smallest one is considered a perfectly valid sorting algorithm here... \$\endgroup\$ – my pronoun is monicareinstate Jul 7 at 10:39
  • \$\begingroup\$ @mypronounismonicareinstate In comment, you can include a tag with a link to its information page with [tag:tag-name] e.g. fastest-code. \$\endgroup\$ – Adám Jul 7 at 10:42
  • \$\begingroup\$ @my pronoun is monicareinstate - but optimising for bytes of high-level code is meaningless unless this translates into fewer byes of machine code. See the P.S. I have added. \$\endgroup\$ – chasly - reinstate Monica Jul 7 at 10:46
  • \$\begingroup\$ What's the point of chess, football, or other sports? They are for fun. It's basically the same for code-golf. \$\endgroup\$ – HighlyRadioactive Jul 10 at 5:30
6
\$\begingroup\$

(a) Yes, speed contests exist. They are tagged . A variation is the seeking of . Click these tags for more information about them.

(b) N/A

(c) No. Code golf isn't just to conserve memory (indeed, golfed code can often use more memory at run time than otherwise optimised code). There are multiple benefits, some of which I discuss in this webinar.

P.S. It doesn't really make sense to talk of bytes of machine code for interpreted programming languages. While I realise the importance of compiled languages, there are still a few interpreted languages that are relatively popular, e.g. Python and JavaScript. And no, languages that are designed for brevity rather than comprehensibility do not always win. Indeed, my bounty for winning in a particular non-golf language has been claimed over 50 times!

| |
\$\endgroup\$
  • 1
    \$\begingroup\$ Thanks Adám, I don't think I could have asked for a more comprehensive answer. I watched your webinar - some nostalgia there from the discussion on Conway's Life. Apart from Hello World, it was the first program I ever wrote (in Fortran!). I'm not sure of the etiquette of posting on discussion threads. There are several lines I'd like to follow up on that won't suit comments so I'll submit an "answer" and see if anyone complains. \$\endgroup\$ – chasly - reinstate Monica Jul 7 at 17:56
  • \$\begingroup\$ @chaslyfromUK Don't post an answer, rather, come into our chat room and ping me there. That room is exactly for purposes such as this. \$\endgroup\$ – Adám Jul 7 at 20:06
  • \$\begingroup\$ Just a follow-up. After watching the webinar, and doing a but of circum-Youtubing, I keep seeing videos about Life. Here's a fascinating one. Wait for the recursive bit near the end! youtu.be/1l5ie_owyik \$\endgroup\$ – chasly - reinstate Monica Jul 11 at 19:33
7
\$\begingroup\$

People do code golf for fun and challenge. This is like asking why in the sport of golf do players hit the ball with a golf club when they could just carry it into the hole.

| |
\$\endgroup\$
  • \$\begingroup\$ There is a difference though. Amateur golf serves no purpose at all apart from getting fresh air and socialising in the bar. Even Tiger Woods couldn't put his skill at getting little balls into holes to any practical purpose. Similarly proficiency at chess or crossword puzzles has no transferable value. They are purely hobbies that a very few elite might profit from. However, computer coding has a real purpose. There are many problems that need solving and the activity of doing so can be just as rewarding in itself as an artificial problem focusing on shaving a few bytes off the source code. \$\endgroup\$ – chasly - reinstate Monica Jul 7 at 12:33
  • \$\begingroup\$ @chaslyfromUK I think we're agreeing about golfing being mostly just an impractical recreation? Are you saying that instead of doing a leisure activity, coders should be using that time applying their skills to important real-world tasks? \$\endgroup\$ – xnor Jul 7 at 12:39
  • \$\begingroup\$ Not really - I was just querying your This is like asking ... assertion about golf and code-golf being XNOR in this context. One is never practical, the other is primarily practical. \$\endgroup\$ – chasly - reinstate Monica Jul 7 at 12:55
  • \$\begingroup\$ @chaslyfromUK Maybe poetry would be a better analogy. Programming and writing are both skills with lots of practical applications. Code golf and writing poems are mostly useless, but many practice them for fun. \$\endgroup\$ – Zgarb Jul 7 at 16:28
  • \$\begingroup\$ @Zgarb - You're right, but then I don't much like poetry either! On the other hand I do listen to music that others have composed and that's pretty pointless when you come down to it. \$\endgroup\$ – chasly - reinstate Monica Jul 7 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .