A bit less flippantly: My opinion is that code can be art, but isn't necessarily. This is unconnected to its quality, because both bad art and good non-art also exist. It *is* connected to its purpose.
In this sense, it's just like writing. Some writing is art and some isn't. A terrible airport novel is bad art, but art nonetheless. An administrative memo can be very well-written, but is not art.
(Incidentally: People had been writing for over a thousand years before anyone realized writing could be for artistic purposes. The bronze age Mesopotamians had been writing census reports, tax records, legal proceedings and other administrivia for at least a millennium before they started writing down poetry and stories.)