fb

BLOGS

Ideal for algorithms: Functional Programming

Ideal for algorithms: Functional Programming

Fri, 09 Apr 2021

Common programming languages generally allow multiple programming paradigms, making a rough distinction between declarative and imperative programming. When programming software such paradigms form the basic approach. A sub-form of the declarative approach is so-called functional programming which is mainly used to develop the following programs or codes:

  • Technical and mathematical applications
  • Artificial intelligence (AI)
  • Compilers and parsers
  • Algorithms

What is functional programming?

As the name suggests, Functions are the focus of the functional programming approach. All elements may be considered a function with a functional program, and the code can be executed with concatenated function calls. There are no stand-alone value assignments. The best envisaged is a function as a special variant of a sub-program. This is reusable, and it returns a result directly, unlike a procedure.

Some functions are defined and then applied in many higher-level programming languages, so this is not a special feature of functional programming. The fact that functions within this programming paradigm can take on different forms is the thing that makes the functional approach so important for computer science and at the same time suitable for a wide range of applications. This special handling of functions allows programmers to implement complex computational tasks and to process them.

Functional programming languages

The most important programming languages based on the functional approach like LISP, ML, Haskell, OCaml, F#, Erlang, Clojure, Scala. There are well-known programming languages that allow functional programming as one of several possible paradigms: Perl, Ruby, Visual, Basic .NET, Dylan, ECMAScript.

Advantages

  • Programs are stateless
  • Well-suited for parallelization
  • Easily testable code
  • Easily verifiable code, even stateless functions can be verified
  • Can be combined with imperative, object-oriented programming
  • More accurate, shorter code

Disadvantages

  • Data like variables cannot be changed
  • Retrieval of large amounts of data not possible efficiently
  • Not recommended for connections to databases and servers
  • Not suitable for many recursions of the same stack
  • Recursive programming can lead to serious errors
  • Not suitable for all tasks