pronounced "drupal-art", noun referring to Drupal code that is both beautiful and artistic.
At my first Drupal event, a company retreat in Amsterdam in Fall 2006, we went to the Van Gogh museum. This was the first time I discovered a painter whose work was so versatile and I enjoyed so much. Flowers, fields, faces; I enjoyed them all. Vincent van Gogh is a master artist and, at that moment, he became my favorite painter.
I am now on an extended Drupal project in London and I've seen a dozen shows while here. I've always liked musicals. I remember the first time I saw The Who's Tommy, it is still one of my favorites; but I've also discovered other rock musicals, such as Spring Awakening and We Will Rock You. Recently I saw Les Misérables and it's a new favorite!
I am talking about Art: visual, musical, and performance; traditional, modern, and popular. My preferences are subjective and personal.
If the maxim "Beauty is in the eye of the beholder" is true, and we each have our own eyes, I wonder what makes some art and some artists more beautiful not just to the one or the few, but to the majority?
All creative processes are artistic: painting, sculpting, writing, performing (singing, dancing, acting), even designing—such as jewelry design and fashion design. And since research-and-development is also a creative process, I suggest that it is artistic too. Architecture is the best-recognized of the engineering arts; consider Antoni Gaudí (DrupalCon Barcelona) and Frank Lloyd Wright (DrupalCon Chicago). Few would argue they were not also artists. And while one underlying task of architecture is to provide shelter, architects have elevated their task from simple shelter to that of creating pleasing spaces.
Software is probably the most flexible of the engineering arts. This regular column will explore what makes software artistic, why Drupal is beautiful, and how to hone your software artistry.
Let's Start by Looking at Art as a Layman
I have no drawing skills, but I do enjoy paintings. I find some colors, shapes, and patterns pleasing, but I also like art that evokes emotion or intellectual thought. I know what I like and how it makes me feel. But I have no understanding of what it really takes to create a painting that I like. My appreciation is an emotional connection to what I find pretty.
Consider software as a layman and consider aesthetics. I have two partners on one of my projects, who know no programming, but are experts in their field. We peer-develop remotely, making heavy use of voice calls and screen sharing. We discuss ideas, then I write the code while they watch. My partners are not programmers, but they often comment about the beauty of the code. This code is uniform, the indentation follows the logic, and the variable names and comments make the code easy to follow. Layman programmers find this pretty.
Still appealing to the layman, let's look at some pseudo code.
Which do you like more?
i = 0;
j = 1;
i = 0;
j = 1;
I hope you like the second example more than the first example. Why is one better than the other? They do exactly the same thing. I think it has something to do with the symmetry of the layout. It's visually pleasing.
Consider another example:
i = 0;
j = 1;
I hope you like the second example more. Again, they are identical, but the second example is more compact. I like things that do more with less.
Lastly, consider this:
While the new variable names are longer and less compact, violating the generalization above, by using descriptive variables, the code is easier to read and, in my opinion, prettier.
The difference between the first example and the last example is purely aesthetic. But I feel that the final example is the best one. It's compact, it's easy to read, it's pleasing on the eyes.
These examples hopefully demonstrate that alignment, simplicity, and readability are part of the aesthetic beauty of software.
Let's Next Look at Art as an Artist
Writing is a commonly accepted art form. I read quite a bit and dabble at writing, so let's presume I can speak of writing from the artist's perspective. Robert A. Heinlein is my favorite author. I appreciate his imagination and his technical skill. I appreciate that he creates complex stories with few words. I admire his use of unconventional words, such as "grok." I appreciate that his stories have layered social messages. My appreciation of written art is deeper than my appreciation of painted art because I have studied and labored with it.
Now think about software as a software artist. An elegant solution has beauty. Recursion, object overloading and Drupal's hook system are all beautiful because they distill complex problems into simple solutions. Elegance and beauty are not measured in lines of code, but in complexity simplified.
You probably are familiar with PHP. The language itself is not special. What it does well is mimic other procedural languages while being easy to use and avoiding the fight inherent in lower-level languages. I think perl as a language is more elegant; you can disagree. Perl's downfall is PHP's strength. Perl is difficult to read and arguably more difficult to write. What both these languages do exceptionally well is store and retrieve keyed arrays.
So, what I find most beautiful in PHP is that it is familiar, easy to read and write, and handles key-value arrays exceptionally well. The overloaded += array operator is beautiful. In a single readable and understandable statement, an entire set of key values can be initialized with defaults.
What I find most beautiful about Drupal isn't core or the code per se, but its clean API's and usage of PHP's strong point, namely the array. Specifically, functions like l(), t(), url(); helpers like drupal_map_assoc(); but mostly hooks for forms, menus and schemas. Anyone who was around before 4.7 likely remembers the older form functions and the upgrade to forms API. The FAPI transition was a lot of work. But it was during this transition to an elegant form solution that Drupal became really beautiful—not just to me, but to many other developers—and Drupal took off as a platform.
In coming issues we will look more at PHP, Drupal, aesthetics, algorithms, beauty and some ugliness: that is Drupl'Art.