Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relation between Akka and scala.actors in 2.10

  • The Scala 2.10 release notes says this: "Akka Actors now part of the distribution. The original Scala actors are now deprecated."
  • The latest Akka library ("Akka 2.1.0 for Scala 2.10") mentions the following dependency:          com.typesafe.akka:akka-actor_2.10:2.1.0
       and the following examples:
             import akka.actor.Actor
             class MyActor extends Actor {..}
             val system = ActorSystem("MySystem")

  • My project includes these libraries:
             org.scala-lang:scala-library:2.10.0
             org.scala-lang:scala-actors:2.10.0
  • In my classpath, I have no package called "akka". I do see instead scala.actors, but it doesn't seem deprecated.

    So, in which way are Akka Actors "part of the distribution"?
    If this is, indeed, the case, then am I still supposed to add the "akka-actor_2.10" library as a dependency?
    If so, do I use akka.Actor or the non-deprecated scala.actors.Actor ?

    like image 370
    teo Avatar asked Feb 12 '13 14:02

    teo


    People also ask

    How does Scala Akka work?

    Akka is written in Scala, with language bindings provided for both Scala and Java. Akka's approach to handling concurrency is based on the Actor Model. In an actor-based system, everything is an actor, in much the same way that everything is an object in object-oriented design.

    What are Scala actors?

    The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems.

    Are Akka actors single threaded?

    An actor processes messages sequentially and (in Akka, at least) presents a single-threaded illusion (that is to say that under the hood, the dispatcher may execute the actor's logic on different threads from message to message, but from the actor's perspective there's only one thread).

    How do you make an actor in Scala?

    This is a bit of a tricky problem, because Akka actors are started asynchronously when they're passed into the actorOf method using a Props . At the ActorSystem level of your application, you create actors by calling the system. actorOf method. Within an actor, you create a child actor by calling the context.


    1 Answers

    In scala 2.9.2 scala actors was part of scala-library.jar.

    If you download a scala-2.10.0 distribution it there are no actors in scala-library and both akka-actors.jar and scala-actors.jar are supplied.

    The latter is present for backwards compatibility and will be removed in a future major release.

    akka-actors is the replacement and what you should use for any new development (and look to move anything using scala-actors across when possible).

    If you have no current code in your project using actors you should probably reconfigure your project's dependencies to remove org.scala-lang:scala-actors:2.10.0 and instead depend on com.typesafe.akka:akka-actors_2.10:2.1.0 if you want to use actors.

    I am not sure why there's no deprecation annotation on the classes in scala-actors in 2.10.0 but I believe it's to be added in 2.10.1.

    You can find more info on the migration guide.

    like image 183
    Brian Smith Avatar answered Sep 22 '22 03:09

    Brian Smith