Could you explain for me what is the main difference between pragmatics in linguistics and discourse analysis? Both are related to study of use of language in real world.
As far as I understand it:
Speaker 1: would you like to go for a drink?
Speaker 2: great! what time?
The discourse analysist would be looking at how this communicative event works mechanically whereas the pragmatist would be looking at underlying (implicit) meanings (in this case 'drink' means trip to the pub, for example).
Considering the example given in user3072's answer:
Discourse Analysis: When we want to know that "what time" refers to what, it could be answered by discourse analysis. Only by looking at the previous sentence, we get to know that it refers to "going for a drink".
Pragmatic Analysis: It would, for example, intend to answer the question that to what does the "drink" refer? Pragmatic analysis focuses on the purpose or speech acts of the language. It may refer to "going to the pub", "drinking any liquid present there", or anything else.
"There is a car on road. Unfortunately, it has blocked the road for the ambulance to pass."
Pragmatic Analysis: Announcing this sentence clearly involves an implicit purpose (i.e., to inform the owner of the car to go and move the car from the road so that the ambulance may pass). Hence, pragmatic analysis involves analysis of that implicit purpose.
Discourse Analysis: Why "unfortunately"? "It" refers to what? There is a car on the road, "so what"? All these questions refers to the discourse analysis. It is to understand the meaning of one sentence or a part of it in the context of the whole chuck of sentences.
AFAIK Consider a paragraph of sentences, discourse analysis looks how the sentences are glued together while pragmatics looks on meanings that are not encoded in the sentences!
e.g The teachers allowed the children to play because they are busy in some work! The teachers allowed the children to play because they are too tired to listen to classes!
Here the word "they" means different in the above two sentences which requires external world knowledge! It appears to me that pragmatics is a deeper branch of discourse analysis!