• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Do Scala Actors have "spawn"

 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An Erlang book I'm reading says Erlang has 3 main parts with concurrency: receiving a message, sending a message (!), and spawning a process.

So Erlang has this thing called spawn. Does something like this exist in Scala?
 
Ranch Hand
Posts: 376
Scala Monad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure of what "spawn" does, but I guess it will be equivalent to:
Although Scala implements the concept of actors, I think Erlang provides better support for low-cost concurrency and recovery.
On the other hand, running in the JVM is a big plus and with Terracota you can get almost free clustering.
[ August 07, 2008: Message edited by: Gabriel Claramunt ]
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're right, Gabriel.

Doesn't Scala still use Java-style threads? Aren't they kind of expensive to create?

The Erlang book encourages creating lots and lots of processes - to the point that I think having them in the thousands is good.

Has anyone seen any process-creation benchmarks of Erlang vs Scala? I have a funny feeling the JVM can't keep up on process creation... or at least not yet.
 
Gabriel Claramunt
Ranch Hand
Posts: 376
Scala Monad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually,I just found that Scala's event-based actors are threadless. Scala uses a pool of threads to serve all actor requests. If I recall correctly, Erlang does something similar.
In event based actors, messages are processed with the "react" keyword instead of "receive", the Actors tutorial explains how to use it
Also I found a detailed explanation of what happens behind the curtains in Event-Based Programming without Inversion of Control
Seems Scala's actors are almost like Erlang ones
[ August 11, 2008: Message edited by: Gabriel Claramunt ]
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Peabody:
Doesn't Scala still use Java-style threads? Aren't they kind of expensive to create?



Not if you use a thread pool. That's why they were put in Java long ago.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic