I can hear it now. "Ohhh lord Jeebus, not another programmer who thinks code is art." Problem is, everyone who is an artist loves to play this hypocritical game where everything they do is art, even if it's chicken strapped to their underwear. Yet, anyone else who's not in the artist club can't call anything they do art. They want to dance on the edge where they can sell any random pile of garbage to rich wealthy douchebags, but if you try to say that the C++ code you slaved over for a year is art then you're wrong. Sorry nerd, you don't have neck tattoos and heroin track marks so you can't possibly be doing art.
I'm sorry but if an artist can strap poultry to her panties, pile garbage on the floor, or do literally nothing, then everything anybody does is art including my very finely crafted C code, the turd I squeezed out this morning, and my pastel paintings. Basically, if you want to call what you do art, then it's art. If anyone tries to tell you it's not, then they're not artists. QED. Moving on now.
What I actually want to talk about though is not why code is art from an external perspective that requires the judgements of the tattoo class, but rather a view on what is art from the perspective of what it does to you when you do it. I hadn't thought of this view of "what is art" until I started learning to paint. Painting and drawing had a very familiar sensation I've experienced while deep in the throes of programming, writing, dancing, or playing music. This intense feeling of concentration where time stops and everything in my body and mind works seamlessly as if my self doesn't exist. Leaps of intuition, euphoria, and relaxation are all things that programmers, musicians, artists, and writers experience when they're very deep in their craft. A sensation of flow is a common thread through all of them and most likely many more activities that require intense concentration in an altered state of brain activity.
In Gary Marcus' book Guitar Zero he discusses how there is no special "music part" of your brain. Instead the research suggests that playing music involves your entire brain using many parts in cooperation, but that each part is doing a different thing than its normal function while you play. During its day job a part handles language, then when you play music it detects note intervals. Another part's day job is tracking moving objects, then when you play music it handles timing. When you're done playing music they switch back to their day jobs and you snap back to normal.
I believe that this same phenomenon happens with (but not limited to) programming, visual art, music, dancing, and writing. These are all activities that are fairly recent in human history, not innate natural things we do but require education, and all seem to require this same altered brain function. In addition to this, it's possible that receivers of the output from these activities also experience the same sensations when they're listening to music, viewing visual art, or reading.
This phenomenon could explain both the sensation of flow, and it could explain why people like doing these activities. It could be that flow is simply the ability to make the parts of your brain do something different for a little while. A kind of vacation for your hippocampus. That would also explain why it takes training, is tiring, and in many ways why it is difficult to recover from. Many programmers, artists, and musicians talk about the difficulty of interacting with others after an extended period of this altered brain function.
In addition to this, people may enjoy the sensation because it provides a similar altered consciousness that they'd get from drugs, alcohol, meditation, religious experiences, but with much less effort or negative results. Instead of having to sit quietly for hours praying or meditating you can do some art, read, write, or code. In Europe there was a tradition of art being used as a sort of meditation device for worshippers to visualize parts of the bible while they prayed, and it was thought that artists channeled God when they painted or sculpted. It could be the origins of this are in the phenomenon of flow. It would explain why art, music, and religion are so commonly combined.
I now believe that an activity is an art if it causes this feeling of flow and requires an altered brain function to do. Not what the output of this activity is, but what creating that output does to your brain. What makes coding an art is that it requires making your brain do something it's not normally designed to do which then causes a sensation similar to meditation and requires effort but feels effortless.
I also have this vague idea that this could be a key to improving art education. Currently art education is about the outward result of the artist. Can they produce a painting that looks like a thing? Can they pile garbage on the floor? Can they play Jazz standards? Can they analyze an Algorithm? However, what if art, music, and programming education had the additional higher purpose of using that art to help students learn this skill of flow? That if the student is able to do this little mental trick then they'll get much more enjoyment out of the activity than just what they produce. It would be a goal of mental health through teaching a practical skill. Although that sounds kind of crazy now that I write it.
Now I think that if what you do gives you flow, then it's art. I could even go so far as to say that the best art causes this flow in others, and if you've ever seen someone play a video game or browse the internet for days on end, then you know programming beats everything in that department.