Gandalf can be fabulously grumpy, if I was to look for his 'character failings' I'd say having a tendency to be sarcastic and a bit 'short' could be one of them. He is what my grandad would have termed
ornery. Maybe this was Tolkien writing the effects of lack of nicotine to the smoker into his story?
But he'd never hit a Hobbit! For one, they aren't children but people and Gandalf recognised this more than most (I dread to think what might have happened had The Shire been closer to Rohan, after the Rohirrim record with hunting the Woses

). What
Authority would Gandalf have to do such a thing?! And that's laying aside his personality.
I think the films have led people astray somewhat...