Databases Reference
In-Depth Information
some properties of functional languages. Both the SQL -like HIVE language and the
PIG system that are used with Hadoop include functional concepts.
Several multiparadigm languages have also been created to help bridge the gap
between the imperative and functional systems. The programming language Scala was
created to add functional programming features to the Java language. For software
developers using Microsoft tools, Microsoft created the F# (F sharp) language to meet
the needs of functional programmers. These languages are designed to allow develop-
ers to use multiple paradigms, imperative and functional, within the same project.
They have an advantage in that they can use libraries written in both imperative and
functional languages.
The number of languages that integrate functional programming constructs in dis-
tributed systems is large and growing. Perhaps this is driven by the need to write
MapReduce jobs in languages in which people feel comfortable. MapReduce jobs are
being written in more than a dozen languages today and that list continues to grow.
Almost any language can be used to write MapReduce jobs as long as those programs
don't have side effects. This requires more discipline and training when using impera-
tive languages that allow side effects, but it's possible.
This shows that functional programming isn't a single attribute of a particular lan-
guage. Functional programming is a collection of properties that make it easier to
solve specific types of performance, scalability, and reliability problems within a pro-
gramming language. This means that you can add features to an old procedural or
object-oriented language to make it behave more like a pure functional language.
10.4
Making the transition from imperative
to functional programming
We've spent a lot of time defining functional programming and describing how it's
different from imperative programming. Now that you have a clear definition of func-
tional programming, let's look at some of the things that will change for you and your
development team.
10.4.1
Using functions as a parameter of a function
Many of us are comfortable passing parameters to functions that have different data
types. A function might have input parameters that are strings, integers, floats, Bool-
eans, or a sequence of items. Functional programming adds another type of parame-
ter: the function. In functional programming, you can pass a function as a
parameter to another function, which turns out to be incredibly useful. For exam-
ple, if you have a compressed zip file, you might want to uncompress it and pass a fil-
ter function to only extract specific data files. Instead of extracting everything and
then writing a second pass on the output, the filter intercepts files before they're
uncompressed and stored.
Search WWH ::




Custom Search