Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 754
Ivan Avatar asked Dec 17 '11 19:12

Ivan


People also ask

Which programming language is used for all purpose?

General-purpose programming languages are more commonly used by programmers. According to a study, C, Python, and Java were the most commonly used programming languages in 2021 respectively.

What is function oriented programming?

Functional Programming. Object Oriented Programming. This programming paradigm emphasizes on the use of functions where each function performs a specific task. This programming paradigm is based on object oriented concept. Classes are used where instance of objects are created.

What is ballerina software?

Ballerina language is an open-source, cloud-native programming language designed to ease the burden of integration development associated with enterprise applications. Ballerina simplifies how a program talks over the network, usually to an application program interface (API).


2 Answers

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.

like image 185
hugomg Avatar answered Sep 20 '22 21:09

hugomg


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.

like image 21
Apocalisp Avatar answered Sep 22 '22 21:09

Apocalisp