Talk programs are a little bit less complex, so we will start with them. All they really need to have is a way of contacting the recipient, a way of answering when you are called, and a way of tracking the conversation as it is going on. Most talk programs divide the screen in two windows. One window represents the local machine, the other window is the remote machine. As you type, you see your comments in the top window, and your recipient simultaneously sees that message in his bottom window.
Chat programs are pretty much the same, except there may be many more people on at the same times. Usually you will connect to the name or location of a group, rather than a specific individual. Once you are connected to the group, you will see a screen with the conversation scrolling along, and often you will have some way of determining who else is taking part in the conversation.