In my 20 years of professional coding, I've seen a lot more problems with people promoting code to shared status, attempting to build a foundation, before it's been used and before it's even remotely ready than I've ever seen with people throwing away good code. We're taught in CS school to always abstract and generalize, way too many people run with that and write code that abstracts away their specific problems, and build foundations that aren't sitting on the bedrock of solving a real problem. Almost all open source projects that start with the aim to build foundations are thrown away.
On the flip-side, one of the common goals of a hackathon is to build the best and most useful idea you can, quick and dirty, without getting mired in foundation building. The utility of that is to prove the idea is useful first, and if that succeeds for someone, what better starting place is there for building a foundation?
I'm not against throwing code away. I'm just not sold that the results of hackathons provide value.
Some code is doing useful work after 30 years, some after 10. Hipster stuff is called "ancient" after 1 year. Most hackathon stuff is dropped after 2 days.