Posted in Docker, Misc, Tech

Docker – Introduction


Let’s start by looking back on how applications were hosted and how it has evolved. Initially, we had one application running on a single server with its own dedicated memory, CPU and disk space. This model proved to be highly costly in order to host high load applications.

hypervisor.pngVirtual Machine

Next, we moved to Virtual Machines (VM), also called as Hypervisor Virtualization. We could now run multiple applications on each virtual machine, each one being a chunk of the actual physical server and having its own memory, CPU and disk space. However, the drawback was that each Virtual Machine needed its own Operating System and this incurred additional overhead of licensing costs, security patching, driver support, admin time etc.

Docker arrived with a solution to this problem. There is just one OS installed on the server. Containers are created on the OS. Each Container is capable of running separate applications or services. Here’s a comparative illustration of Containers vs Virtual Machines:

docker vs vm

  • Docker is said to be derived from the words: docker + worker -> Docker.
  • It is written using Golang
  • Is Open source with Apache license 2.0.

Let’s look at what the following mean:

Docker Container: It is a software that contains the code and all its dependencies to facilitate an application to run quickly and reliably irrespective of the computing environment

Docker Container Image is a lightweight, standalone, executable package that contains everything to run an application: the code, runtime, system tools, libraries and settings. Container Images become Containers at runtime.

Docker Hub is a public docker repository to store and retrieve docker Images. This is provided by Docker, however there are other third-party registries as well.

Open Container Initiative or OCI  is responsible for standardizing container format and container runtime.

Why is Docker so popular? 

  • A Docker image can run the same way irrespective of the server or the machine. It is hence very portable and consistent. It eliminates the overhead of setting up and debugging environment.
  • Another reason is Rapid Deployment, the deployment time is reduced to a few seconds.
  • They start and stop much faster than Virtual Machines
  • Applications are easy to scale as containers can be easily added from an environment.
  • Helps in converting a monolithic application into Microservices. [To read more, refer Microservices]
  • last but not the least, it is Open Source.
Posted in Scala

Scala – Introduction


Scala was created by Martin Odersky in 2004. The name ‘Scala’ is derived from the word ‘Scalable’ which signifies that it can grow with the demand of the user. Scala was designed to be both an Object oriented as well as a Functional programming language. i.e. every value is an object and every function is a value. It is designed to exhibit common programming patterns in a concise, type-safe and elegant way. Many say that it was introduced to fulfill the shortcomings of Java.


Why Scala?

  • Modular, highly efficient and scalable.
  • Is a type-safe JVM language that incorporates both object-oriented and functional programming.
  • Good for exploiting parallelism for multicore and parallel computing.
  • The source code compiles to Java bytecode that runs on the JVM.
  • It is very flexible in defining abstractions
  • Immutability: Scala makes it easy to write code using immutable data
  • Scala can use all Java libraries and Scala code can be imported into Java code interchangeably.
  •  Applications:
    • Writing web applications
    • Distributed applications
    • Streaming Data
    • Parallel processing
    • Analyzing data with Spark

Who’s using Scala?


Directory structure

SBT or the Source Build Tool is an open-source build tool for Scala/Java Projects. Here’s the directory structure normally followed in Scala projects. The src/ is the Base or the project’s root directory.

         <files to include in main jar here>
         <main Scala sources>
         <main Java sources>
         <files to include in test jar here>
         <test Scala sources>
         <test Java sources>

Class, Object, Package and Trait

Class: The concept of classes in Scala is similar to that in Java. They are nothing but templates containing fields and methods. A class can be instantiated using the ‘new’ construct. Classes in Scala cannot have static members.

Object: Object is a named instance with fields and methods.

Package: Packages allows you to modularize programs. Contents of the package can be scattered across many files. Classes defined in a package can be specifically imported.

Trait: Traits are like Interfaces. However, they can even contain field definition or method implementations.

Writing your first Scala Program:

object FirstScalaProg extends App {
    println("I am done! Execute me!")

The entry point of the program is defined inside an object. The object is made executable by extending the type ‘App‘ or by adding a “main” method, as follows:

object FirstScalaProg {
    def main(args: Array[String]){
        println("I can be written this way too!")

Scala source code is stored in text files with the extension .scala. The Scala compiler compiles .scala files into .class files. Classfiles are binary files containing machine code for the JVM to execute.


  • Structure and Interpretation of Computer ProgramsHarold Abelson and Gerald J. Sussman. 2nd edition. MIT Press 1996.– [Full text available online].
  • Programming in ScalaMartin Odersky, Lex Spoon and Bill Venners. 2nd edition. Artima 2010. – [Full text of 1st edition available online]
  • Scala for the ImpatientCay Horstmann. Addison-Wesley 2012. – [First part available for download.]
  • Scala in DepthJoshua D. Suereth. Manning 2012.
  • Programming ScalaDean Wampler and Alex Payne. O’Reilly 2009.

Other Learning Sources: