Top 5 features added to Java SE 9

Background

Java has been evolving at a good pace ever since it was introduced in early 90’s. With every passing year and each release it has tried to keep pace with emerging market demands.Java has been evolving at a good pace ever since it was introduced in early 90’s. With every passing year and each release it has tried to keep pace with emerging market demands.

Let’s take a look at the top 5 features added to Java 9

1. Modules
The result of Project Jigsaw, modules are the most important addition to Java 9.

  • Java is now modular which means the library packages are now organized as modules.
  • It changes the way we design and build Java Applications.
  • It is different from OSGi.
  • It helps Programmers to be more productive.
  • Managing and evolving modules is easier.

2. JShell : Read-Eval-Print loop for Java
A tool that allows you to develop and test Java code interactively.

Earlier:

class Sample{
	public static void main(String[] a){
		System.out.println("Hello World");
	}
}

And now using JShell you can print Hello without writing other stuff.
You can type JShell at command line to get started.
And write

System.out.println(“Hello !!”);

3. Private Methods in Interfaces

You can now add private methods to your Interfaces. This can help you to create  reusable code.

Example:

public interface Sample {

private void printMyStuff(String abc){

System.out.println(abc);

}

}

4. Collections
Earlier you would write

List<Employee> empList = new ArrayList<>();

empList.add(new Employee(1, “Ankur”));

empList.add(new Employee(2, “Rohan”));

Now you can write

List<Employee> empList = List.of(new Employee(1, “Ankur”), new Employee(2, “Rohan”));

Reason – Thanks to changes in Java 8. Interfaces can now have default methods.

5. Concurrency Updates

Java 8 introduced Streams. Java 9 has gone a step ahead and added

  • Reactive Streams publish-subscribe framework
  • Enhancements to CompletableFuture class which was introduced in Java 8.

Other Notable Changes

HTTP Client API to support HTTP/2 and WebSocketThe new incubator HTTP Client is capable of working with both HTTP/1.1 and HTTP/2

 

3 Key Updates in Java SE 8

What is new in Java 8?

Java has been evolving at a good pace since it was introduced in early 90’s. With every passing year it has tried to keep pace with emerging market demands.

Let’s take a look at 3 key updates introduced in Java 8:
1. Lambda Expression  

Lambda Expression adds functional programming features to Java. It changes the way programming solutions are conceptualized and the way code is written in Java. It reduces the amount of code needed to create certain constructs like Anonymous Classes.

2. Stream API

The Stream API supports pipeline operations on data. Stream API is designed with Lambda Expression in mind.Powerful way to handle data in an efficient way.You can perform very sophisticated operations that search, filter or manipulate data. Plus it can be done in Parallel.

3. Interface Methods

Another Lambda inspired feature is the ability to define a default implementation for a method in the Interface. This feature helps you to update the codebase without impacting the classes that implement an interface.

Other new features

1. New Date and Time API

2. Ability to use parallel processing when sorting an Array.

Key Considerations in Java Design

What Java intends to provide?

  • Simple
    Java should be simple to learn and use by the Professional Programmers.
  • Object Oriented Features
    The Object Model in Java is simple and easy to extend.
  • Robust
    Programs written in Java should be able to run reliably in any Environment.
  • Multithreading
    To support Concurrency and Parallelism
  • Architecture Neutral
    Thanks to Java Virtual Machine  
  • Interpreted and High Performance
  • Distributed
    Java supports Remote Method Invocation.

Apart from these Java is a strictly typed language so it checks your program at both compile and run time.

It also frees you from Memory Management activities which can cause major errors at run time, if not managed properly.

An Engineering Approach to Build Websites

Sunny’s E-Commerce Website

Sunny owns a bookshop, which is doing reasonably well, and he wants to offer his services online via an e-commerce website. He starts to do some research on how to build a website.

After few days of searching and reading blogs he puts down his options.

1. Hire a freelance developer who can create a website for him.
2. Use a website builder and try to create a website on his own with some help from a freelancer, which may cost him less.
3. Learn programming and start building a website from scratch.

In your view which approach makes sense?

Continue reading “An Engineering Approach to Build Websites”

Why study Relational Algebra?

I am familiar with SQL so when I had to study Relational Algebra(RA) I found it difficult to understand why should I study RA or how is it related to SQL? Ideally it should have been other way round, not quite in my case.

I couldn’t find good analogies so I came up with a couple of them. Hope this helps you get an idea.

I present two simple analogies here

  1. Say you need an Algorithm to sort a set of numbers. And you write an algorithm, say a version of quick sort. Next you need to implement it. You can code it in any programming language – Java/C etc. using language specific constructs. As long as the idea is retained the code should get you the desired result. Similarly you can think of RA as the theoretical model to query a relational databases. It defines operations like Select, Project etc. This idea has been implemented by a query language like SQL.
  2. Consider specification document written for a Server. Any vendor who plans to build a server should comply with this specification document. As long as the server follows the rules / guidelines specified in the document it’s all good. On similar lines you can think of RA and SQL