Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is LINQ not purely functional? [closed]

So, why exactly is LINQ not considered purely functional?

Is it because side effects can occur? Or is it maybe because it exists in an imperative environment?

like image 782
Dave New Avatar asked Nov 15 '12 11:11

Dave New


People also ask

Is LINQ a functional programming?

LINQ technology is a form of declarative, functional programming.

Is LINQ inefficient?

LINQ syntax is typically less efficient than a foreach loop. It's good to be aware of any performance tradeoff that might occur when you use LINQ to improve the readability of your code. And if you'd like to measure the performance difference, you can use a tool like BenchmarkDotNet to do so.

What distinguishes a purely `` functional programming language from an `` imperative one?

The difference between functional programming and imperative programming is that functional programming considers the computations as mathematical functions and avoids changing state and mutable data while imperative programming uses the statements that change the programs state.

Does C# support the functional programming paradigm?

C# developers are also used to other functional techniques, especially LINQ with its heavy usage of lambda expressions, and extension methods. C# supports various functional aspects so that it may be worth to take a glance at the previously introduced core fundamentals of functional programming from its perspective.


1 Answers

LINQ is not a purely functional programming model as it permits side effects, is thus not referentially-transparent, which is a common definition of "purely functional".

like image 170
Don Stewart Avatar answered Sep 29 '22 00:09

Don Stewart