Mathematics also strives for correctness before aesthetics, but is often considered an art. Programming is little different imo.
When you have scoured your deepest understanding for hours - or days - in order to rewrite a function so that it is easier to read, shorter, more correct, and a thoughtful expression of your own insights and understanding; then you will see how programming can be art.