August 17th, 2024

Code as Art

The article explores computer programming as an art form, emphasizing its aesthetic potential alongside functionality, highlighting examples like generative AI, esoteric languages, and contests celebrating unreadable code.

Read original articleLink Icon
Code as Art

The article discusses the concept of computer programming as an art form, highlighting how code can be used not just for functional purposes but also for aesthetic expression. While programming typically serves practical tasks, there are instances where the primary goal is to create visually or conceptually appealing works. Examples include generative AI applications and platforms like dwitter.net, where short JavaScript programs generate intricate visual art. The piece also touches on the readability of code, emphasizing that while functionality is crucial, the aesthetics and elegance of code are increasingly valued. It mentions the International Obfuscated C Code Contest, where programmers intentionally create unreadable code, and explores esoteric programming languages that prioritize aesthetic qualities over traditional programming norms. The article concludes that programming can be both a medium for artistic expression and an art form in itself, reflecting the creativity and individuality of programmers.

- Computer programming can serve both functional and aesthetic purposes.

- Readability and elegance in code are important, alongside functionality.

- Esoteric programming languages often prioritize aesthetics over practicality.

- The International Obfuscated C Code Contest celebrates unreadable code as a form of art.

- Code can be considered a medium for artistic expression, similar to traditional art forms.

Link Icon 22 comments
By @n4r9 - 5 months
This post is nice, but I think it misses one of the key ways in which code is art: the structured expression of creative thought.

When I have thought long and hard and really truly understand how to implement a solution to some tricky problem, I have often broken it down in my head into conceptual functions that make it easy to understand how it works. These conceptual functions often map on to functions in the code. Physically writing out the code is equivalent to saying to someone (and the computer!) "hey, you can think about this problem like this".

It's similar in nature to a mathematical proof. Sometimes when I'm reading someone's code, I see a seemingly difficult task accomplished in a few simple lines. When I pore over those lines, I have a lightbulb moment. The same can happen when reading a mathematical proof. In Lockhart's brilliant essay A Mathematician's Lament[0], the author talks about teaching the formula for the area of a triangle to school students. There is a brilliantly simple and pretty proof of the formula (in the case of unslanted triangles) on p.3. Looking at this diagram is like looking at the code implementing an ingenious short algorithm for solving a thorny problem.

I see a lot of discussion about readability in the sense of making the code as easy as possible for another person to understand with as little thought as possible. And that's very valuable. But I think there's also a lot of value in occasionally encouraging the reader to think in a new way.

[0] https://worrydream.com/refs/Lockhart_2002_-_A_Mathematician%...

By @tromp - 5 months
My homepage [1] shows two different kinds of code as art. One is this

    ┬──────────
    ┼─────┬────
    ┼─────┼─┬──
    │ ──┬─┼ ┼ ┬
    │ ┬─┼─┼ │ │
    │ │ ├─┘ │ │
    │ ├─┘   │ │
    └─┤     │ │
      └─────┤ │
            └─┘
graphical notation for the predecessor function λn.λf.λx.n(λg.λh.h(g f))(λu.x)(λu.u) on Church numerals. The others use the freedom in formatting of regular C code to depict a (binary) lambda calculus interpreter shaped like a greek letter lambda, or a Hilbert curve generator shaped like a Hilbert curve.

[1] https://tromp.github.io/

By @kchr - 5 months
The IOCCC[1] (International Obfuscated C Code Contest) often features submissions where the source code is formatted to be works of art in itself. Sometimes the source code is also used as input to the program, where the formatting affects how the program behaves.

For example this program, which approximates the decimal digits of pi while having source code formatted to look like a circle:

https://www.cise.ufl.edu/~manuel/obfuscate/pi.c

[1] https://www.ioccc.org/

By @abeppu - 5 months
An idea that I have mused over but haven't attempted to pursue is a code repo (with history, pull requests, etc) as a vehicle for epistolary fiction. There are short stories as sequences of news articles or letters, novels given as diaries, etc -- so why not a story told through issues, pull requests, and the code base? In comparison to code as the text at a given point in time, the whole repo and its presentation of history would let you see both concepts and characters (contributors) changing over time, and a let a reader/user infer certain events outside of the repo (e.g. a merge is followed an hour later by a PR to revert it, with a curse-laden description and rapid approval lets us know that something broke).

Making something that really works in this form both involves a creative insight (What's the story that makes this format shine? What's the code that our characters are building?) and some technical nuggets (writing scripts+tools that generate git history and/or github/gitlab/whatever API calls, acting as multiple parties).

By @fhd2 - 5 months
I find this incredibly hopeful.

I love programming. But I'm a CTO. My job is to make sure business goals are met through tech - not the other way around. I'm OK with this, but part of me always found it sad.

Now, if you add the possibility that AI will replace programmers at some point in the future (I'm not on the hype train, but I definitely acknowledge the technical possibility that this could happen at some point in the future), and if I think a bit further and assume humanity will figure it all out and we'll all have more time for our hobbies, even then, what use is my hobby of programming? When all it was ever good for was to achieve business goals?

It's refreshing to think it's really not. That it can be art, human self expression, the exchange of ideas, experiences and feelings, a source of joy for me and others. I feel more OK about the future than before I read this, even though the notion wasn't entirely new to me.

By @periode - 5 months
I actually just finished writing a whole PhD thesis on that topic! You can skim it here: https://sourcecode.enframed.net

Some interesting parts were about the metaphors that people use to make sense of 'pretty' code (is code like prose? like poetry? like maths? like architecture? are any of those craft activities?), and about the role of tools (from IDEs to languages) in affecting what we consider to be nice or not.

By @vouaobrasil - 5 months
Code can have aesthetic value, but I don't think it's like other art. I think the analogy between code and an art like painting is that painting is "expression-complete" in the same way that C is a Turing-complete language, whereas code is not. Code "as art" cannot really express fully everything than painting as an art can, but it can represent some aspects.
By @jmkr - 5 months
> But aesthetically, the source code used to construct the latter array is more "readable" than the former.

Not aesthetically, visually.

Article has some pretty great links.

Programming and aesthetics (Art) are probably the two things that itch my mind the most.

There's a certain type of mindset that people that do and participate in creative programming/digital art have in common with other passionate/creative types. Part of it is the discovery, the inquisitiveness, the plasticity, and the unexpected.

In general sarcastic prose. When you focus more on the creative side you get the general purpose dynamic, memory managed languages. Just make something cool. When you focus more on the comp sci side you get the strongly functional languages, Haskell, Ocaml. And if you mix them together you get lisp.

By @mapcars - 5 months
I also see code as art, not in a simple visual sense but in a sense of elegant, clean and smart engineering solutions and use of language capabilities.

Visual text part is something a linter should take care of for practical reasons.

By @fao_ - 5 months
Some prior work by Knuth on this subject: https://dl.acm.org/doi/10.1145/361604.361612
By @lux - 5 months
Oh nice! I gave a PechaKucha talk with the same title back in 2019[0]. Love the illustrated examples here.

One thing I touched on in my talk was the idea that code is an art form that expresses the values of the artist by making something new possible in the world. The artist is saying "this should be possible for people to do" and then makes it so. I think that's really cool.

[0] https://www.johnluxford.com/blog/code-as-art/

By @myco_logic - 5 months
I've written on this matter before[1]. Code being appreciated as an artform would, to my mind, benefit greatly both the worlds of fine art and programming.

[1]: https://istigkeit.xyz/static/writing/essays/hello_artworld.p...

By @Retr0id - 5 months
To me, what's presented here is more "art as code" (not that there's anything wrong with that)

Code can be beautiful in its own right, regardless of syntax. "clean" and/or well-formatted code is nice, but the real beauty comes from the algorithmic logic and structure.

By @shahzaibmushtaq - 5 months
Whenever I look at code written by programmers there are always 2 types:

1. I read code, understand logic and appreciate it like an art and

2. I read code, try to understand the logic and move on

One thing is crystal clear, those who love coding do not consider it less than an art.

P.S. There is no need for dark mode feature on the website

By @cynicalpeace - 5 months
Did I misunderstand something? that "3x3" matrix isn't a 2 dimensional matrix. It's a 9 item array.
By @WillAdams - 5 months
The problem with this sort of thing is that there doesn't seem to be a consensus on:

>What does an algorithm look like?

I like to at least pretend that I'm a visual person (have to justify my BFA in graphic design _somehow_), and usually reach for:

- https://www.blockscad3d.com/editor/ (a Blockly version (think Scratch) of the 3D programming system OpenSCAD)

or

- https://github.com/derkork/openscad-graph-editor

and have been funding the guy behind http://nodezator.com/ for a while now. I suppose I should try https://ryven.org/ again...

The thing is, the ability to express complexity is sharply bounded by display size (and maybe some aspect of human cognition such as the gestalt theory about the number of objects which may be perceived at a glance) --- for a textual program, one has an essentially infinite 2D canvas which scrolls up/down --- for a visual program questions of which direction one moves and how much arise. Literate Programming as advocated by Donald E. Knuth at least allows one to add a TOC, Index, and suitable hyperlinks and so forth:

https://terrastruct.com/blog/post/draw-software-architecture...

If one tries to manage complexity by using modules, then one gets back to the textual representation one is trying to escape from --- it's just wrapped up in pretty coloured blocks and/or connected with lines.

And of course, there are the cautionary collections such as:

https://blueprintsfromhell.tumblr.com/

https://scriptsofanotherdimension.tumblr.com/

and one wonders if principles such as: https://terrastruct.com/blog/post/draw-software-architecture... would help.

I really wish that there was a desktop version of Blockly which could import arbitrary Python libraries....

By @antishatter - 5 months
More of a craft really
By @revskill - 5 months
Good code is the one you wants to keep maintainance.
By @awwsmm - 5 months
"The human desire to be creative and express one's individuality does not end where a keyboard begins... code can be used as a medium to create art, but it can also be art itself."