Let's Discuss: What Are Exactly Functional Languages
People are arguing exactly what a functional programming language is, but they are attracting developers like crazy. The men behind Clojure, Scala, F# explain what these functional programming actually is and how the languages are evolving today.
Martin Odersky, Founder of Scala says:
Functional programming has a core appeal for some developers. The programmers in that segment like functional programming because it make code clearer, better structured, and it prevents many classes of errors.
Others tend to argue that functional programming leads to less-efficient software and applications.
Functional programming also tends to require not to think about programming in a new way. Abstract coding can always be an issue. When you make your code more abstract, you feel like your moving farther away from manipulating data and just going through loops. This can cause issues and take way more time ot understand what is going on in these abstractions.
What exactly is a functional language?
In the most basic terms, functional programming is about treating computer computation as mathematical functions. In addition to some languages, some are billed as functional from the start. An example of this is Java or C# have both became functional by adding support for lambda expressions.
Trying to find a precise definition of what a functional programming language is can be really hard to pin down. There is quite a few different definitions that just seem to be wrong, in my opinion. Some people may see a functional programming language as enabling a functional style with higher order of functions, or even a language that is supporting lambdas. When you think about it, a good semi-correct defition is a language that strongly emphasizes on functions and immutable data.
I an say that I may not even be correct regarding this definition. From my experience, this semi-correct definition fits Clojure the best. Scala may even have a different definitions that could be close or I am totally off regarding it.
Let's go back to the basics now. A function is a piece of code that maps inputs to outputs, and has no further effects beyond that. This can be said that it is the mathematical definition of functions that is being used here. Sometimes we can call these functions as pure. We can also distinguish them from some of the functions within C. I believe a functional language focuses on programming with pure functions, as in making it easy and pretty powerful to do so this way.
Functional programming can be combined with a lot of other paradigms. As anothe example, functional goes really well with object-oriented programming. Scala is definitely a functional language. I think we can agree that a language with just lambdas does not make a language functional. Yet it is necessary, but not all that sufficient.
First-class or even higher-order functions are not what functional programming is completely about. Functional programming is really about making a programming language more like mathematics. That also states that there is more and still remains a spectrum of definitions for functional programming.
Let's go beyond the languages alone. The most popular functional programming language in the world tends to be Excel, when you think about it. A simple Excel worksheet may have a column with a bunch of values, such as A5 X 2. That tends to be a pure function on A5, and that A5 doesn't change, so you will be computing values from that existing data.
If you think about all of this, almost every programming language is adopting features from functional languages.
Immutable data is critical to functional programming. Concurrency, such as programs with multiple threads operating on data at the same time, also benefits greatly from immutable data. We can call F# a functional-first language because it comes from a heritage of other different languages. It also has support for object-oriented programming and will operate with C# and Visual Basic.
I can see strong adopting of functional languages as a response to the increasing pressure that is facing developers. These developers will have to take on the bigger problems of these days. To do their job, they must reduce the incidental complexity of their programs and software. It is now recognized that side effects are a source of complexity and bugs within these applications. While, in all honestly, it is possible to reduce the amount of state in a program that is written in a non-functional language, it would be dramatically easier plus faster to do so in a language that makes functional programming idiomatic and the default.
What's next for the functional languages?
Let's talk about the legendary Scala. The language is now 13 years old, and has become the primary language for data science. It is highly supported in JMVs, and has an estimated 400,000 to 600,000 users. Plans for the short term call for it to be optimized for Java 8. Also in which bytecode instructions from the latest standard Java upgrade will enable Scala to generate more efficient code.
Now let's talk about Clojure. The language is now 9 years old, and also based on the JVM. It has been used in finance, retail, software, and entertainment. It has also been applied to diverse applications, such as transaction processing, big data, networking operations, search, analytics, security, and consumer offerings.
Finally, we have F#. The language was founded by Don Syme and often overseen by the F# Foundation. It is used in a wide range of applications and runs on Linux, OS X, Android, iOS, Windows, and even the web browsers. They are currently working on making it work with the .NET Core. It is an open source, cross-platform modular version of the .NET Framework, as rumors are saying. There is even string interplation, which is going to make it easier to write strings, is also on the drawing board for the language.