I have an 18 mile commute each way. I only do it 5 days a week during the nicest weather and when feeling the looniest (or when the car is at the shop). I used to have a buddy with a pickup truck who would drive me in, and I'd ride home -- that was the best. I didn't find weather or fatigue to be the biggest issues, but I don't commute year-round.
The biggest issue I find is lighting the road at 5:15 a.m. when the sunrise isn't until 6-something a.m. Also, my cycling budget is small (my wife thinks it's huge, but she has no idea the crazy gear I covet) so I've never bought the $200 lights that light up the road. I run a dynohub lighting setup which isn't super-bright but does have the advantage of no batteries. Peter White is the best web resource for that stuff. But I'd recommend a headlamp, especially to spot the bravest critters that may cross your path in the pitch dark. Plus a headlamp is an extra light placed nice and high up to be seen, and is very useful for changing flats or doing emergency repairs in the pitch black.
40 miles seems like an awful lot, though. However, when I do ride in in the morning I often feel more alert and refreshed for my work day. My workday starts at 7:15, ends at 3:00-4:00 depending. For me the ideal commute would be 10 miles, give or take a coupe of miles here or there... all downhill (both ways). I can dream, can't I?