Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Is there a code golf community but for performance instead of size?
29 points by is_true on Dec 18, 2022 | hide | past | favorite | 17 comments
I like code golf because you usually can learn more about a language, but I think focusing on performance might be a better use of time.


Advent of Code progresses to the point where simple/brute force solutions fail to work and you have to use better datastructures/algorithms.

Other performance work has dependencies tending to be tied to a database, networked services, etc that's not so bite-sized and sharable.

My early descent into programming was constantly battling with performance getting a 1.79 MHz Atari 8-bit to do interesting things in a 1/30 second. Maybe retrocomputing and writing software for vintage machines or recreated new machines that work like them might be a good challenge.


PICO-8 is a good competitive ground for performance coding: it's Lua, but with intentional limiters on size, performance, and source token counts. Writing good PICO-8 code generally means code golfing, with the side effect of the performance limiters being designed to make small code also be fast code - so optimizations are often whole-program.

Real-world performance on modern hardware is often a lot more dull and consists of finding the inner loops, parallelizing what you can, organizing the data to be cache friendly, then getting the loop fast at instruction level. You don't learn the same lessons from that because the majority of the codebase is "dark" and run too infrequently to show up as a bottleneck.


Unlike code drag racing, code golf can be scored independently of the hardware substrate.

(a supercomputer is a device that turns your compute-bound job into io-bound; a mainframe turns io-bound jobs into compute-bound)


Is there a tool where you can check how many instructions your program, with a set input, required to execute the task?

Imagine this, given an x86 C/C++/Rust compiler we all agree upon, and a set of inputs we also share, produce a program that counts - say - the median length of the arrays given or something. After which we'll run our programs in a profiler of sorts that tells us 'this program achieved the task in 1,104,687 cumulative instructions' and we'll compete based on that metric.

It wouldn't really matter what processor you use because the target is the same and so is the compiler.

Is what I suggest possible? It'd be a nice conciliation between platform independence and speed measuring.


Doesn't GDB allow you to step through code instruction by instruction?

I imagine Ghidra or IDA Pro could be souped up to "referee" pretty reasonably.

I would imagine in-lined assembly could circumvent any kind of compiler restriction (just compile it with an optimized compiler and inline the relevant assembly it produces).


Yeah, let's just agree on the used architecture, the compiler(s) version(s) and call it a day!


I know it is nonsensical for real world applications but golfing isn't real world programming, so why not eliminate some variance ourselves and try measuring what's left?

Don't just laugh, try and tell me why this is not possible for you. This performance golf seems like an interesting idea.


like sailboat classes


How about one for maintainability?


You'll only find competitions for things which are easy to measure. You won't find one for maintainability.


See also “Someone improved my code by 40,832,277,770%” <https://m.youtube.com/watch?v=c33AZBnRHks> by Matt Parker. It can be a really fun game!


ty


Leetcode tells you if you are in the top x% in terms of speed. It might scratch that itch.


Such a thing can be used in specific systems e.g. NES/Famicom, or the original IBM PC with 8088, but I think not for portable code.


Computer science in general?


Surely computer science is code golf for axioms, or for size of proof?


um. big O notation?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: