title: Event-driven programming: callback vs message polling
body: <p>I've been looking into OpenGL programming as a C++ programmer, and have seen two primary ways of dealing with event-driven programming: message polling or callback functions.</p>
  
  <ul>
  <li><p>I see that the native Win32API uses a callback function, which is triggered by the DispatchMessage function.</p></li>
  <li><p>SDL (based on the tutorials) also use some sort of callback or callback-like programming.</p></li>
  <li><p>GLFW also uses callbacks.</p></li>
  <li><p>SFML lets the programmer poll for individual messages anywhere in the code, usually in a loop, forming the message loop.</p></li>
  <li><p>The X Window system, based on what I have seen, also uses message polling.</p></li>
  </ul>
  
  <p>Clearly, since event systems exist in prominent environments, each must have an advantage. I was hoping someone could tell me the advantages and disadvantages of each. I am thinking of writing some programs which would heavily depend on event-driven programming, and would like to make the best decision on which path to take.</p>