Your sentence is an exclamatory sentence which is used more frequently in spoken language
to show a vast range of emotions…love, anger, happiness, confusion,
elation or any other typed of exuberant emotion... Exclamation marks
are reserved for powerful feelings. They deliver a jolt of
feeling, which is why they’re so common in everyday speech and part
of exclamatory sentences. (from the K12reader site)
The type of emotion denoted by a particular exclamatory sentence is dictated by what follows what:
What a mess! (negative emotion)
What a man! (meaning What an amazing man!).
Note that if you put "neutral" nouns like boy, book, man etc., the connotation may be inferred as positive ("what an amazing...!") unless connoted differently by the surrounding context:
- Think of a mother who is angry at her daughter because instead of getting better at housework, she likes fixing cars. If she exclaims:
What a boy!
it is clear that the emotion expressed is negative (irony, disappointment, exasperation).
- Think of a student who hands in an essay which the teacher finds far too long. If he says:
What a book!
the emotion expressed is clearly negative, though trying to remain polite (irony, reprimand)