A 4yo isn’t going to accidentally stumble onto a masterpiece on composition either.
In any case, the utility of the code is not in question here. Ugly code can have the same utility as beautiful code. Utility is not completely separated from beauty but it is neither necessary nor sufficient. If it were, only applied math would be considered beautiful, but plenty of other math is beautiful too.
After typing out my response I don’t know if I totally agree with what I’m saying here. And I don’t know if it even makes much sense but here it is anyway:
I think what I’m getting at is you wouldn’t call a proof with an error in it beautiful. Just like you wouldn’t call a useless python class beautiful. The purpose of pure math is finding truths. The purpose a python class is to do something useful. For something to be beautiful it has to complete its purpose (I don’t think I would go so far as utility) as well as be of a beautiful form. Relating this back to traditional art the question becomes what is the purpose of traditional art? Here by traditional art I mean making things with the intention of it being “art” and for people to look at/ hear/feel and doesn’t have other utility.
In any case, the utility of the code is not in question here. Ugly code can have the same utility as beautiful code. Utility is not completely separated from beauty but it is neither necessary nor sufficient. If it were, only applied math would be considered beautiful, but plenty of other math is beautiful too.