Programming for the Cloud means programming in a distributed environment. In this environment the flow of a program is parallel, asynchronous and has to react to external events. Developers need to make the sitch from the old sequential programming mind se to a distributed and asynchronous one, cloud computing is forcing this transformation.
Writing, debugging and maintaining parallel and asynchronous code is very difficult.
Like in the past, now with the new era, cloud computing, big data, mobility and distributed architectures have created new challenges for developers and it seems like the community is responding once again with an abundance of new languages. The common themes among the new emerging programming languages are:
- parallel computing
- multi-platform programming
- multi paradigm programming(Object Oriented + Functional Programming)
The ideal language for the Cloud age should be object oriented and embrace functional programming.
FP is a practical implementation of the study behind a formal system called lambda calculus, designed in the academic world to resolve problems related to calculation. The system was based on functions that look other functions as parameters and returned functions as results. The benefits of functional programming languages can be summarized in one phrase:
they allow writing code without "side effects", ideal for concurrent, high availability, critical and distributed systems. In functional languages, the basic unit of work is a function.
Unlike imperative languages, variables are immutable in pure FP and their values cannot be changes after initialization. The FP function cannot ever cause side effects: a function cannot modify a value outside of its scope for another function to use. This means that the only effect of eveluating a function is its return value and the only thing that affects the return value of a function is its arguments.
Benefits of FP:
- Multi-threading: a functional program is ready for concurrency. There is no need to worry abour deadlocks and race conditions because data cannot be modified twice by the current thread or other threads.
- Debugging: it is easier in FP because a bug doesn't depend on separate code. If a return value of a function is wrong, it is always wrong, what code was executed before running the function?!
- Parallelism: two or more time-consuming functions can be run in parallel on a multi-CPU system because their return value is indipendent of modifications to the global state from other functions. Each function may modify the state of its scope.
- Hot deployment: is easier if the application is written with FP. You can replace a component at runtime without worrying about losing state data associated with that component.
- Lazy evaluation: the value are only computed when, and if, they are actually needed, instead of when they are passed to some function.
All these characteristics are very powerful in the age of cloud computing.
However, "pure" FP languages have not been very successful. In reality, many other languages are incorporating functional elements without strictly adhering to functional dogma. This approach of combining elements of Object Oriented and FP is called multi-pradigm programming.
Examples of new programming languages are:
- Dart (by Google)
- GO (by Google)
- OPA (similare to Node.JS)
- Scala (general purpose programming language)
Libraries and Frameworks:
- Hadoop: can coordinate a number of machines working on a problem and compile their work into a single answer. This project imitates some of the Map/Reduce framework developed by Google. The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage.