People use the language for communicating through coherent and cohesive stretches of language. In other words, they normally use more than a couple of words and sentences; they produce longer stretches of language by putting words and sentences together. These chunks of language must follow each other and be connected in a logical way in order to transmit a specific message. This process is called discourse, and its linguistic product is called text.
As people can communicate through the spoken and written means, there are spoken and written discourses and spoken and written texts. These discourses and texts develop different features due mainly to the different conditions in which they are produced, which relate to two factors: time and audience.
When speaking, time pressure does not allow much planning, while in writing there is usually plenty of time to plan. Regarding audience, when writing, the reader is not present, and this makes it almost impossible to get immediate feedback. This implies that when writing, we must compensate for this lack with clearer and explicit language, which makes written discourse more formal. On the other hand, when speaking, the listener is present and can give immediate feedback to what is being said. This implies that when speaking, the message can be understood with fewer words, which makes spoken discourse more informal.
It does not mean that speaking will always be spontaneous and informal, or that writing will be always formal and planned. Still, it is a good start to set the differences between spoken and written discourses relying on the factors of time and audience as established on the previous paragraph, as they are more evident in this way.
Written discourse includes some medium to keep record of the message. It can be edited to achieve grammar-free sentences. Audience is not known. Text cannot be adjusted to individual reader. No immediate response from