Oh CAMEL ! Objective CAML ( Categorical Abstract Machine Language)
Before we dive into the sea of codes, let’s have some basic idea of the stuff that we will be dealing with. So why OCaml?
Supports functional, imperative and object-oriented styles
- Functional programming is a sort of programming style that sees programs as mathematical functions. What we mean by that is we define functions and apply them to arguments so that we can obtain results. Programs are essentially mathematical objects, it is easier to use the power of mathematics to reason about this program. Functional languages have simpler syntax than other programming languages and are yet powerful.
- Imperative Programming style describes programs as a sequence of statements in which they are executed line by line to get a result.
- Object Oriented Programming (Common, You all know this!). Well if not, in object oriented style we have this idea of classes and instances, and breaking down problems into smaller problems representing them with classes and objects and dealing with them.
- OCAML supports all these three styles. As we move ahead, we will see (though seems contradictory now) how neatly this is handled.
OCaml is a statically typed, type-safe programming language.
- A type-safe language ensures that you don’t apply the wrong operations to the wrong data (e.g., dividing two strings).
- C and C++ are statically typed but not type-safe. There’s no guarantee that a type-error won’t occur.
- Java and OCaml are type-safe and statically typed. This means that most errors are caught before running the program.
- A good statically-typed language rules out lots of bad code, while admitting lots of good code.
It Supports a number of advanced features
- Garbage Collection : Like Java, OCaml lifts the burden of worrying about memory management.
- Type inference : Data types are automatically inferred. Unlike java and C++ you don’t need to initialize the data type of a variable (like int, float …). The compiler automatically guesses it.
- Parametric Polymorphism : OCaml lets you write functions and data structures that can be used with any type. This is somewhat like Generics in java.
Free and open source
So now let’s move on to install OCAML