Thats about the distance I regularly ride (17-25 miles, each way) and I've commuted mostly on a mtb, last 6 months on a Trek Soho IGH, rarely on a road bike (old trek 1200)
I found that I could careless which bike style (mtb, Soho, road bike) I ride because, in due time, your muscles will adjust. What really matters is the time you have available to do the commute. If you are stressed for time, or find annoyances due to the commute, then adjust those first. I found that regular maintenance really started to bug me, so I switched to the Soho IGH for, the IGH, the belt, and the roller brakes.
I also added heavy tires and thorn resistant tubes to essentially eliminate flats.
In other words, I like the bike commute and am willing to spend the time on the biking part of the commute, but not associated hassles with regular bikes. 40 miles a day adds up real fast to 200 miles a week, 40 weeks a year, for 8,000 or so miles a year, which is pretty tough on a regular bike rode in all types of weather, not just sunny weekend rides.
There are some folks who comment in this forum who think anything over 10 miles each way puts commuting bikes out of reach and recommend road bikes with, or without igh. Personally, I think its more like 25 miles each way even in moderately hilly areas. But I'll stick to my original premise and suggest its more about your time constraints since a commute bike as in a 30-40 lb commute bike that is upright, heavy, loaded for bear, may be slower on long stretches of traffic light free road than a 7 lb brittle carbon frame rocket.