Why use a functional language in another imperative project?

Why use a functional language in another imperative project?

+3
source share
6 answers

If your project is really necessary, you probably do not need a purely functional language. But you probably still want a language with functional features; a functional style refers to a low-level code structure in the same way an object-oriented style refers to a high-level structure. Both allow you to pack certain common language-supported templates.

In the primary imperative project, the functional style is useful at the level of expressions and expressions, allowing you to separate common loops and sequences:

For example, take this general template:

newlist = []
for x in oldlist:
    y = dosomething(x)
    newlist.append(y)

This is map:

 newlist = map(dosomething, oldlist)

:

total = 1
for n in numbers:
    total = total * n

fold ( reduce):

total = fold(*, 1, numbers)

, - , " , , for(int i = 0; ...)". OO , OO.

IDE , . . - , .

. . " " -. , :

+2

, . , , - .

.

+6

, Java ++, FP, , currying, ..

. Scala .

+2

, - ( , ).

+2

, , : " , 18 $10 . ". , , , , , , , . , . - , . # LINQ

0

?

:

Mathematica C. Mathematica - , , , . , , .

Joule - . Joule #, F #. , , , F #. , (~ 50kLOC) ++ (~ 1kLOC) F # , . , .

The Microsoft Halo 3 computer game and the Bing search engine have some of their dense math code written in their own functional language Microsoft F #.

0
source

Source: https://habr.com/ru/post/1740338/


All Articles