There are a lot of jokes about morning and night people, but studies show there is validity to this. I learned to work with this when teaching special ed and later, when I ran my own software company, where I did all the programming, I saw a dramatic illustration of some of those issues.
Morning people get up and are perky and ready to start. However, they're the ones who often need a nap in the afternoon and work well with an 8 hour day, but do not do well with marathon sessions. Night people do not start quickly. They wake up and need time to adjust to the world again and often are not ready to really focus until the afternoon. But they gain in strength and focus over time. They can often work marathon sessions, working all through the night and into the next morning.
I found that when I was coding and could work on my own schedule, I could get some work done in the afternoon and this is when I set things up, did simpler tasks, and caught up on things. But my real work hours started about 8:00 pm, when I could start focusing and I would often work through until sunrise or longer. 18 hour coding sessions were not unusual for me, but, of course, if I did a few in a row because I was working on something difficult, then I'd need several days to just recover. But I might be able to do 5 days straight of mega-sessions if needed. It's also worth noting this was in my 40s, not when I was some over-energetic teen or 20-something. In fact, in one month, when I was over 45, I did more all-nighters (with good code as a result) than I did in all my time in high school and college combined.
It does vary according to the person. Forcing night people to try to work in the morning will always be an issue for them and will not produce the good code they can produce. Forcing morning people who tend not to do well in marathons to stay for 10 hour days four times a week is just as bad.
Corporations don't understand these things, which is one reason I never wanted to be involved with any larger corporations. If you want coders to do their best work, you can't regiment them and dictate how they work. You need to let them find their style. Let them work on their own schedule. If they need music, let them have it. If they need silence, find a way to make quiet places available. Some need neat work spaces, others need chaos.