简体   繁体   中英

Is there a programming language where every function is essentially run as a separate actor?

Is there a programming language where you don't have to define actors yourself - every function is just ran as a separate actor (which can mean a separate thread if there are free cores available) by default?

For example it means that if I write something as simple as

v = fA(x) + fB(y)

then fA and fB could be calculated simultaneously before the sum of their results was assigned to v.

I don't think there is anything this extreme, since the context switching and comunication overhead would be too big.

The closest I can think of to what you are asking is data-parallel programing, where the program is mostly written in the same style as a sequential version but parts of it are ran in parallel where possible.

Examples are loop vectorization in Fortran and "par" magic in Haskell.

Haskell's par combinator lets you evaluate expressions concurrently (which can mean in separate threads if there are free cores available). All you have to do is:

x `par` y

Which will evaluate x and y concurrently, and return the value of y . Note that x and y can be programs of arbitrary complexity.

Joule is a pure asynchronous message passing language:

http://en.wikipedia.org/wiki/Joule_%28programming_language%29

http://www.erights.org/history/joule/MANUAL.BK5.pdf

ActorScript is a pure Actor message-passing language, but appears to only exist as a specification:

http://arxiv.org/abs/1008.2748

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM