Functional & Logic Programming
Functional Programming Language
Functional programming is a new fad, and it has several benefits compared with object orientated programming. The principal advantage is the lack of state, which makes it much better for multi-threaded code as many of the problems in multi-threading are caused by mutating an object in one thread and using it in another. So most functions are pure, which means the result depends on the inputs to the function only, and not on any global state. Since functions are pure, you can perform certain optimizations automatically, such as caching the results. It is mainly used in academia, but it is spreading, especially where strict guarantees on code quality are required.
The racket is based on Scheme, which is, in turn, based on Lisp
, but offers extensions to make writing GUIs or to provide a logic-based programming language like Prolog
Prolog – Logic Based
is a logic-based programming language; you can define axioms and then query them. So for an example imagine a family tree program, you would specify rules such as sibling(x, y) if father(x) == father(y) and mother(x) == mother(y), brother(x, y) if sibling(x, y) and male(y), and so on. You could ask mother(john?), and it would tell you even if the fact was not present as long as it could be worked out (so john’s sister is mary, and you told it the mother of mary).
Scala – Mix of Functional and Object-Oriented
is designed to run on the JVM (Java Virtual Machine), and is a mix of functional and object-orientated and can intermix with Java code.
Haskell – Pure Functional Language
is a purely functional programming language, and one interesting aspect is that of lazy evaluation. This can lead to some surprising results; code that would take a long time to execute may not even be executed at all if the result is not needed.
Lisp for List Processing
is the grandfather of the other programming languages here as it came out in 1958, it stands for List Processing, and the source code of your program is a list, so it makes it easy to modify the code as it runs.
Ocaml - Multi-Paradigm
is another multi-paradigm programming language that mixes object orientated programming with functional programming. You can write a program in Ocaml and link to it from C to enable you to interface with existing systems even if you are not familiar with the language.
Erlang – Very Useful for Large Scale Systems
is designed for large scale systems and allows you to change the program whilst it is running and running on multiple machines at the same time. It was developed by Ericsson to help run their phone network, and it was used to write WhatsApp. It is designed to run multiple processes and to make it easy to pass messages between them.