Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Do Scala Actors have "spawn"

 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • 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.
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic