Musical composition can happen in advance with an aim towards repeat performance or it can happen on the spot when musicians improvise or jam. Composition describes the formal construction of a piece of music, both its incarnation on paper and its performance incarnation. Originally Western music was composed for the church and for worship. Its function was to be repeated but the artistic/creative elements of musical composition were lacking as the music itself was more pedagogical in purpose. Once polyphonic sounds began to creep in, composers began to record music on paper for future performance. This begins to happen when the view of music starts to change from that of a form of worship to a form of worship that also provides audio pleasure.
There is a mathematical precision to musical composition that is present in most studies of musical theory. Though music is a creative art, its composition and performance is both scientific and mathematical and adheres to certain rules of rhythm and spacing on the page in order to sound a particular way.
Traditional Gregorian Chant notation, some of the first written music in Western culture, is written in neumes. Neumes are the most basic building block of musical notation and predate the introduction of the five line staff notation. These original notations were simple dashes on a page. They did not always indicate a note to be sung as far as the pitch was concerned, but, rather, were an indication in what kind of sound was to be made and sometimes in what order. Though neumes are visually reminiscent of their later incarnation in the five line staff notation, their rules were completely different.
The earliest neumes were actually Aramaic, and did not originate in the early Christian Church. They were originally used to indicate how and with what tonal attributes a religious text was meant to be read. The utilization of neumes was the first step towards the composition and formal construction of music.