Skip to content

Some thoughts about functional programming

Kartik edited this page Feb 21, 2018 · 3 revisions

Characteristics of functional langugage

  • Functional programming does not support state, so there are no side-effect results and we can write error-free codes.
  • function is first class citizen
  • immutable variables
  • lots of pattern matching, guards
  • no looping structure
  • currying -> chaining function, function is returned
  • function does not depend on any other external state
  • closure
  • ease of parallelization thanks to lack of mutation
  • Functional programming can be advantageous when you are going to be performing lots of different operations on data that has a fixed, known amount of variation
  • In functional languages the program is structured such that it treats computation as the evaluation of mathematical functions. And this is really good for: Gaming and Artificial Intelligence
  • Functional programming allows you to express computations as combinations of partial functions without ever needing to modify existing values
  • It operates only on its arguments. There are no hidden states or complex transition rules."
  • is the ability to develop sane, straightforward, efficient and beautiful concurrent software

Functional Programming – Advantages Functional programming offers the following advantages −

  • Bugs-Free Code − Functional programming does not support state, so there are no side-effect results and we can write error-free codes.

  • Efficient Parallel Programming − Functional programming languages have NO Mutable state, so there are no state-change issues. One can program "Functions" to work parallel as "instructions". Such codes support easy reusability and testability.

  • Efficiency − Functional programs consist of independent units that can run concurrently. As a result, such programs are more efficient.

  • Supports Nested Functions − Functional programming supports Nested Functions.

  • Lazy Evaluation − Functional programming supports Lazy Functional Constructs like Lazy Lists, Lazy Maps, etc.

Some disadvantages

  • Using only immutable values and recursion can potentially lead to performance problems, including RAM use and speed
  • As a downside, functional programming requires a large memory space. As it does not have state, you need to create new objects every time to perform actions.

Functional Programming is used in situations where we have to perform lots of different operations on the same set of data.

Lisp is used for artificial intelligence applications like Machine learning, language processing, Modeling of speech and vision, etc.

Embedded Lisp interpreters add programmability to some systems like Emacs.

ok

Clone this wiki locally