The story develop Scala applications to access Hadoop data

The name Scala stands for Scalable language. Technically, Scala is a blend of object-oriented and functional programming concepts in a statically typed language.

Simple Scala program:

var capital = Map("US" -> "Washington", "France" -> "Paris") capital += ("Japan" -> "Tokyo") 

How the above program works This program sets up a map from countries to their capitals, modifies the map by adding a new binding (“Japan” -> “Tokyo”), and prints the capital associated with the country France.

Scala a scalable Language

The sample code to get factorial

def factorial(x: BigInt): BigInt = if (x == 0) 1 else x * factorial(x - 1) 

if you call factorial(30) you would get: 265252859812191058636308480000000

Scala is pure object oriented: Scala is an object-oriented language in pure form: every value is an object and every operation is a method call.

For example, when you say 1 + 2 in Scala, you are actually invoking a method named + defined in class Int. You can define methods with operator-like names that clients of your API can then use in operator notation.

Scala is also a functional language: In addition to being a pure object-oriented language, Scala is also a fullblown functional language. Scala doesn’t require you to leap backwards off the Java platform to step forward from the Java language.

It allows you to add value to existing code—to build on what you already have—because it was designed for seamless interoperability with Java.

Scala is high-level language.

// this is Java boolean

nameHasUpperCase = false; for (int i = 0; i < name.length(); ++i) 
{ if (Character.isUpperCase(name.charAt(i))) { nameHasUpperCase = true; break; } } 

Whereas in Scala, you could write this:

val nameHasUpperCase = name.exists(_.isUpper) 

The above example tells how simple you can write complex logic in one or two line. You can take QUIZ on Scala here.

Scala in Hadoop Eco system
Scala in Hadoop Eco system

How Scala and Hadoop both can be integrated

Scala is used in some of the Hadoop ecosystem components like Apache Spark, Apache Kafka, etc. So it would be really useful for someone to develop applications using Scala that uses Hadoop and the ecosystem projects. You can read a best example with Scala how to access Hadoop data.


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.

Start Discussion

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s