RSS RSS feed | Atom Atom feed
Popular Articles: Tom Riddle's Magical Diary | AJAX Lego Robot | AJAX CAPTCHA | SQL Multisets

The DaMusic Code

Writing software with music and using more of our senses

Writing software today uses only one of our 5 senses, namely sight which is our primary sensor and probe for most of the things we do.

In general, doing things using more than one sense will yield a better result. For example a chef may perhaps look at a cookie dough to see if is ready along with feeling if the consistency is right before smelling or tasting it.

Each sense helps in determining if the dough is "correct". If the chef uses 4 out of five senses successfully in his trade, software developers ought to be able to use at least one more.

Composer vs. Engineer

In a way, there is a programming language for making music. Below is an example of that programming language.
A musician (a CPU that can execute the program above) reads and execute each note (instruction). The end result will be a tune called Mozart's Star Song (also more commonly known as Twinkle Twinkle Little Star). The CPU executes each note by making air molecules vibrate with specified attributes such as length, amplitude (strength), and frequency.

The Composer

The composer who wrote the code did it for a purpose. In one way or another he wants to project feelings and emotions on people who listen to it. A good composer knows what response his notes will yield to a listening human. Music is a very important ingredient in, for example, movies, in which it helps put the viewer and listener in a certain mood by making him cry or scream or what have you.

In a way a composer is a coder for code which will be executed by a musician on his instrument, producing sound which will cause a response in a human's soul.

The Engineer

The software engineer writes code to determine the flow of ones and zeros to the CPU. Different combinations of ones and zeros are executed differently, causing a different ouput, from a technical sense all very similar to the composer. The difference is that an engineer writes code which will cause reproducible, deterministic results.

The Composing Engineer

The composing engineer will write music which can be translated to CPU instructions. The advantages of using a musical language are many. I'm imagining writing code in such a language using an "instrument" instead of a keyboard. The notes from the instrument can be detected in various ways and not necessarily through spectral analysis and Fourier transforms. Below are some of those advantages -- I'm sure there are more than I can think of.
  1. Human Nature. Humans are intuitive. They can easily recognize and produce patterns. Programming with musical code/patterns/harmonies is more intuitive than having to fiddle with semicolons, end brackets etc.
  2. Faster. In general humans can produce patterns and notes faster than typing on a keyboard since good musicians do it instinctively. Today's computer languages are designed to be easily translated/compiled, etc into something a CPU can understand. I can't wait for the day when there is a computer language designed for humans, and not the other way around.
  3. Bug Listening. Developers will be able to listen to their code and hear if there are any bugs. For example a for-loop might be implemented as a scale of notes. By just listening to your code it could be determined that you for example forgot to decrement instead of increment.
  4. Doubling the Senses. Using hearing to assist in programming means the double of number of senses "guarding" against bugs while writing/reading code.
  5. Extreme XP. XP (Extreme Programming) teams usually do their programming with the developers physically close to one and other, so in the event any pair encounters a problem etc, the other team members can overhear them and help out. Taking the overhearing to a extreme level, team members can literally overhear the other team members code.
  6. Simultaneous Thread Debugging. Another variant of bug listing might be useful while debugging multi thread application by listening to them at the same time, the same way a skillful maestro conducts and listens to his orchestra.

Sketching on the DaMusic Code

All of this sounds like it might be useful, but is it possible and the question is how would a musical language look like? I certainly lack the musical education and musical talent to approach this. (Maybe if I had those abilities I could even clearly see why it wouldn't work). Nevertheless, some ideas:
  • Each measure could represent one line of code.
  • Chords or harmonies could represent the various keywords/statements such as for/if etc.
  • I know there is a certain mathematical aspect in writing and understanding music. The notes legal to program with have to be according to a certain predefined "genre" of music.

What is the sound of your one hand clapping?

Probably writing code with music is more of a Sci-Fi thing than anything else. But, if you who come across this are a musician and think it might be viable and have some ideas about it, I'd be happy to help out any way I can.

Until such a day arrives where we can program with music, I think I'll continue meditating over what the sound of my one hand clapping is, instead of my for loops.
slashdot digg del.icio.us technorati [more]



Re: The DaMusic Code

I wouldn't confuse music with music notation; and while there is an analogy between computer code and musical notation, it is an imperfect one. A program and a piece of music notation are each capable of producing a wide variety of outputs, but the reasons for this differ. For a piece of music notation, the variety of outputs stems from the imperfection of the machine which will interpret the music. The interpretation process involves a human to read the music notation, and a musical instrument to play the music. Even if the human is trying to play the music mechanically, flaws in the human's technique, and in the instrument, will make the result unpredictable. For a program, the factor which causes the different outputs is the input to the program, not the machine running the program. A computer program produces different outputs for different inputs, but for a given input, the output will always be the same. I suppose a computer program could produce the same output for all inputs -- say, always send the same impulses to the sound chip, or print the same text on the screen -- but such a program is so trivial that we'd usually call it a 'recording' or a 'document'. Computer programming languages are more expressive than musical notation. In order to be able to generate a large set of outputs, computer programming languages have a set of powerful control flow constructs such as 'for' loops, 'if' statements, and recursive functions. Music notation, by contrast, has only simple repetition constructs, such as "da capo al fine", and other symbols such as the "57 bars rest" symbol seen in orchestral scores. All of these constructs are basically just shorthands. The essence of music is not musical notation. Most people would consider a folk song, passed down over generations without being written down, to be more musical than a pianola reel, and I would agree. A pianola reel is pure notation, and no soul is required to interpret it. The medium of music is the human mind, while musical notation is a convenient but not essential representation of music. -- Julian

Add a comment Send a TrackBack