title: Purpose of singletons in programming
body: <p>This is admittedly a rather loose question. My current understanding of singletons is that they are a class that you set up in such a way that only one instance is ever created.</p>
  
  <p>This sounds a lot like a static class to me. The main difference being that with a static class you don't / can't instance it, you just use it such as <code>Math.pi()</code>. With a singleton class, you would still need to do something like</p>
  
  <pre><code>singleton firstSingleton = new singleton();
  firstSingleton.set_name("foo");
  
  singleton secondSingleton = new singleton();
  </code></pre>
  
  <p>Correct me if i am wrong, but <code>firstSingleton == secondSingleton</code> right now, yes?</p>
  
  <pre><code>secondSingleston.set_name("bar");
  firstSingleton.report_name(); // will output "bar" won't it?
  </code></pre>
  
  <p>Please note, I am asking this language independently, more about the concept. So I am not worried about actually how to code such a class, but more why you would wan't to and what thing you would need to consider.</p>