Why use @Singleton over Scala's object in Play Framework?
<p>I have been using <a href="https://www.playframework.com/">Play! Framework</a> for <a href="http://www.scala-lang.org/">Scala</a> for nearly a year now. I am currently using version <a href="https://www.playframework.com/documentation/2.5.x/Highlights25">2.5.x</a>.</p>

<p>I am aware of the evolution of controllers in Play and how developers have been forced away from static <code>object</code> routes.</p>

<p>I am also aware of the <a href="https://github.com/google/guice">Guice</a> usage in play.</p>

<p>If you download <a href="https://www.lightbend.com/activator/download">activator</a> and run:</p>

<pre><code>activator new my-test-app play-scala
</code></pre>

<p>Activator will produce a template project for you.
My question is specifically around <a href="https://github.com/playframework/playframework/blob/master/templates/play-scala/app/services/Counter.scala">this</a> file of that template.</p>

<p><strong>my-test-app/app/services/Counter.scala</strong></p>

<pre><code>package services

import java.util.concurrent.atomic.AtomicInteger
import javax.inject._

/**
 * This trait demonstrates how to create a component that is injected
 * into a controller. The trait represents a counter that returns a
 * incremented number each time it is called.
 */
trait Counter {
  def nextCount(): Int
}

/**
 * This class is a concrete implementation of the [[Counter]] trait.
 * It is configured for Guice dependency injection in the [[Module]]
 * class.
 *
 * This class has a `Singleton` annotation because we need to make
 * sure we only use one counter per application. Without this
 * annotation we would get a new instance every time a [[Counter]] is
 * injected.
 */
@Singleton
class AtomicCounter extends Counter {  
  private val atomicCounter = new AtomicInteger()
  override def nextCount(): Int = atomicCounter.getAndIncrement()
}
</code></pre>

<p>You can also see its usage in <a href="https://github.com/playframework/playframework/blob/master/templates/play-scala/app/controllers/CountController.scala">this</a> file:</p>

<p><strong>my-test-app/app/controllers/CountController.scala</strong></p>

<pre><code>package controllers

import javax.inject._
import play.api._
import play.api.mvc._
import services.Counter

/**
 * This controller demonstrates how to use dependency injection to
 * bind a component into a controller class. The class creates an
 * `Action` that shows an incrementing count to users. The [[Counter]]
 * object is injected by the Guice dependency injection system.
 */
@Singleton
class CountController @Inject() (counter: Counter) extends Controller {

  /**
   * Create an action that responds with the [[Counter]]'s current
   * count. The result is plain text. This `Action` is mapped to
   * `GET /count` requests by an entry in the `routes` config file.
   */
  def count = Action { Ok(counter.nextCount().toString) }

}
</code></pre>

<p>This means every controller which has the constructor of <code>@Inject() (counter: Counter)</code> will receive the same instance of <code>Counter</code>.</p>

<p>So my question is:</p>

<p>Why use <code>@Singleton</code> and then <code>@Inject</code> it into a controller, when for this example you could just use a Scala object?<br>
Its a lot less code.</p>

<p>Example:</p>

<p><strong>my-test-app/app/services/Counter.scala</strong></p>

<pre><code>package services

trait ACounter {
  def nextCount: Int
}

object Counter with ACounter {
  private val atomicCounter = new AtomicInteger()
  def nextCount(): Int = atomicCounter.getAndIncrement()
}
</code></pre>

<p>Use it like so:</p>

<p><strong>my-test-app/app/controllers/CountController.scala</strong></p>

<pre><code>package controllers

import javax.inject._
import play.api._
import play.api.mvc._

import services.{Counter, ACounter}

/**
 * This controller demonstrates how to use dependency injection to
 * bind a component into a controller class. The class creates an
 * `Action` that shows an incrementing count to users. The [[Counter]]
 * object is injected by the Guice dependency injection system.
 */
@Singleton
class CountController extends Controller {
  //depend on abstractions
  val counter: ACounter = Counter

  def count = Action { Ok(counter.nextCount().toString) }

}
</code></pre>

<p>What is the difference? Is injection the preferred, and why?</p>