Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

27 December 2017

Want to GIT?

The entire programming world is moving towards using GIT as it is becoming a de-facto. If you have few hours during the holidays and want to learn how to work with GIT (or how GIT works), do not miss this course from Udacity. The course instructor has done a good job of putting together a nice course with a lot of materials and exercises (you can complete the course in two days budgeting some breaks for reflection)

Udacity Course Link - Version Control with Git

Points to be noted:
Note 1: You will learn only git (not GIT Hub or something that uses git to host your code). Nevertheless, this should be the first step before embarking further. GIT Hub (or something similar) should be logical next step
Note 2: Highly recommend for students who are still in college (writing code is good thing, writing tests for the code is better thing, managing your code is the best thing)
Note 3: Very highly recommend for professionals who have not explored GIT yet (learn now or will be made to learn it in 2018).
Note 4: Many text editors (like Atom) and IDEs (like PyCharm) support GIT/GIT Hub (super easy)
Note 5 (good that you have read thus far): Refer https://git-scm.com and learn why you should be learning GIT if you are a developer

21 September 2013

OpenGyan - Becoming a Better Programmer

[Alert: Longer post, targeted for students community. Comments are welcome from seasoned software engineers]

Recently we had a couple of OpenGyan's workshops and i happen to scribble my ideas to the students. I hope i will be able to dedicate more time in writing posts like this. Hope this helps the students' community. Though software engineering is a very complex area (is it really that complex?), we are going to focus on the things that are very important for software development of any sort - may it be a lab exercise or a project. The readers are suggested to reflect upon the exercises given at the end of each article for better understanding.

I was reading and reflecting on the short article written by Badhri on Programming languages. Though it was short, it gave a general overview about the programming language. Any programming language is a tool to achieve your imagination. For example, if you are writing a simple program (similar to the ones that is given to you in lab), you do not need to think much. But in reality it isn't the case. To be a programmer, knowing a programming language is secondary because knowing the syntax of the programming language won't make you a good programmer. If knowing programming language is sufficient, then compiler would do the job. Software development is much more than knowing a programming language or few.

Any software is a solution to a given problem. And programming language is just a tool to solve the problem. The solution to the problem is more important than the tool (the programming language). In order to develop a better software one needs to follow certain basic principles in a specific order. The rest of the article discusses the basic principles of software development in a much simplified way.

First, one needs to understand what needs to be done. Because you cannot go on writing program simply for everything. You need to understand that you are writing a program for someone to use it. Remember that you will not always write program to improve your knowledge. So understanding the requirements - what needs to be done plays a crucial part. Understanding the requirements is the first step and if you do not understand the requirements, remember you do not have the second step.

As a second step to writing a program, you need to know how to solve the given problem without employing much of your knowledge on programming languages. For example, if you are writing a game, you need to understand and know how the game is played, how many players are involved, what are their roles etc. In this phase, you will least bother about whether you will use linked list or array. But you will solve the problem at an abstract level. This is called high level design. After high level design, you will decompose the high level design into modules and design each modules. For example, if you are writing a program to validate Palindrome, you need to have input module, processing module and output module. This ability to decompose the problems in sub-problems and solving them with sufficient data structures and algorithms is called low level design. While you are solving the problem, you should also keep in mind about the future problems that may crop up. Your design has to be flexible enough to accommodate future problems (which is quite challenging).

The third skill that is required is to convert the design into product and this is where the programming language comes in. Without the above two steps, the third skill is not worth and in fact not needed. Once you have understood the problem and solved it at a conceptual level, then implementation becomes pretty easier. You do not need to beat around the bush. During the implementation phase, you will implement the entire software module by module and finally integrate the modules to make it bigger whole. Apart from implementing the design, the coding is also about producing maintainable code. When you develop software, you are writing the software which is expected to live more than your lifetime. The program (aka code) can be written with a lot of grace and the code that is well written will live beyond ages (example Unix). The developer needs to understand about other developers who are working with him/her and the people who will be working in future. So programming is not merely following syntax but much more than that. As this point of time, we have discussed about three important qualities of a developer.

The final thing that you need to do as developer is to test your software. The primary focus of testing is to uncover hidden defects. As a developer, you are the best person to know about your code and it makes sense for others to bank on your certificate. So, it is the developers' responsibility to test the software and fix the defects. This is called as unit testing as the developer who develops it ensures that all the code that is written works as expected.

You need to evaluate how much percentage does a programming language play here. May be 40%. But please do not get me wrong. For writing a software, you need a language however for solving problems you need skills like understanding requirements, designing and most importantly testing it. Without these skills, you will not be able to excel as developer. Now would you understand why you have "Algorithm", "Flow Chart", "Hand Calculation" and "Output" section in your lab observation.

When you follow the above software development practices right from the beginning, you become a natural programmer/developer to solve any complex problems. You may want to evaluate your current way of writing programs. First solve the problem and then start writing the program. Though the exercise is short/simple, i am sure there is a lot to learn in terms of processes.

Exercise:
Take any simple program (Palindrome, Fibonacci series) and apply all the concepts you understood from this article (Duration: 3 Hours, Complexity: Medium)
  1. Clearly understand the requirement/problem. For example, what is palindrome or Fibonacci series
  2. Solve the problem by decomposing into modules
  3. Write the software
  4. Finally test

Happy Weekend

16 November 2011

Puzzle - Mega Substring

Scenario #1
Given two strings - string1 and string2,  write a program to find whether string2 is a part of string1 (substring of string1). The above puzzle may seem to be very simple as it is. If this sound silly, read on.

Scenario #2
Assume that you have to write above substring program to compare the contents of two files whose sizes put together is more than the size of your RAM + SWAP partition (let us say 10GB of contents). If you feel like you can solve this with bit of try, move on to the next scenario.

Scenario #3:
What if I want to exploit the number of cores? Will it be better if I have few threads to do the job. If i choose to go with multi-threaded way, what are the special conditions that i should take care of?

Watch out this place for answer (probably this weekend - 20/Nov/2011)

05 November 2011

Time Server - Network Programming

Happen to flip first few pages of Unix Network Programming by Richard Stevens. Wrote a simple time server and client.

The server listens to specified port for incoming connections and sends the current time in seconds since Epoch (midnight of 1-1-1970 UTC).

The client is written to connect to the server, gets the time and displays it.

Here is the screenshot of the output (server is started as background process, netstat shows the server is listening in port 12000. The client connects to server and gets the current time).

The source files (with comments, so that one can follow) are uploaded to my Dropbox account. Sharing it here, just in case if you want to look/run the piece of code.

Server Source
Client Source

Compile the above programs (gcc client.c -o client & gcc server.c -o server) and run it as shown in the pic.

02 November 2011

Palindrome in Haskell

This is probably a week after i started to read Haskell (a functional programming language). Having tried few examples from the book and writing few on my own, i feel like it is a different world. If i m successful enough to keep my interest with Haskell and continue to practice, i think it is going to improve my thinking at a very least. I m not so sure of using this language at work (but who knows). More on Haskell later.

Here is the code that says a given String (list) is palindrome. (see, how expressive Haskell (FP) is). The first two line is to reverse the list and the last line is the one that decides whether or not the original and reversed string same (you need to write probably 10 lines in imperative language)

rev [] = [] 
rev (x:xs) = reverse xs ++ [x] 
palindrome x = (x == rev x)
 Here is the sample output (from WinGHCi)


*Main> palindrome "test"
False
*Main> palindrome "madam"
True
*Main> palindrome "123321"
True
*Main> palindrome [1..100]
False
*Main> palindrome "a great good haskell"
False
*Main> 

You can find my Haskell notebook (and my daily progress) here. (thanks to Dropbox)

29 October 2011

Scala - The Scalable Language

I stumbled upon the programming language Scala few months back and haven't got a chance yet to work with Scala (just download Scala last night and installed Eclipse plugin in my laptop this morning). I happen to watch a video on Scala by Martin Odersky. It is a great presentation - both the language and the presenter.

If you are looking for some alternatives for Java, check out Scala. Companies like Twitter and LinkedIn are using Scala in their products and seems like the list is growing day by day.

Scala is both object oriented and functional language and the code compiles into bytecodes which runs on a Java Virtual Machine. The main advantage of writing Scala program is that you will end up writing lesser amount of code as Scala is more expressive than Java. The adoption of Scala is in early stage and i hope (should say, rather want) it replaces Java.

You can find more stuff on Scala from here.

Overview on Scala, might help you to embrace Scala - http://www.youtube.com/watch?v=zqFryHC018k
Geeky Stuff - http://www.scala-lang.org/node/198
Scala Home - http://www.scala-lang.org/

Needless to say, i m so confused on whether i should blog about Java or Scala :-)

28 October 2011

Measuring Time to Minutest Precision With Guava

Other than profiling, have you ever encountered scenarios where you wanted to measure elapsed time from a predetermined past. A simple way of doing is to log the time (milliseconds or nanoseconds) into a long and then find the difference between two points. Here is a simple code.

public static void timer() throws Exception { 
long startMillis = System.currentTimeMillis(); 
for(int i = 0; i < 10; ++i) { 
Thread.sleep(1000);//equivalent to some work/logic 
long endMillis = System.currentTimeMillis(); 
System.out.println("Elapsed Time = " + (endMillis - startMillis));
// if i need to reset the start time, i need to do the following 
// startMillis = System.currentTimeMillis();
}  
}

If you are looking for only time difference between two points, you don't need to actually log the current time. It is enough if you start a clock (your own clock may be) at time t1 and stop it at time t2. If you want to measure time, you end up writing boiler plates. Guava has a little cute API for this.

Stopwatch is a simple API that mimics the functionality of a stopwatch. Here is the reincarnation of above code example.


public static void niceLittleAPI() throws Exception { 
Stopwatch stopWatch = new Stopwatch();  
stopWatch.start();  
for(int i = 0; i < 10; ++i) { 
Thread.sleep(1000);//equivalent to some work/logic  
System.out.println("Elapsed Time = " + stopWatch.elapsedMillis()); 
// if i need to reset the timer/clock, i need to do the following 
//stopWatch.reset(); 
// and my timer resets to zero
                                 // and if you want to stop the Stopwatch, just call
                                // stopWatch.stop();
}
What are the other advantages of using Stopwatch. I think it is an advantage of Stopwatch that it hides completely the mechanism it uses to keep time and in fact the user of the API is free to give his/her own Ticker.

Another nice addon is that you can get the elapsed time in days, hours, minutes, seconds, milliseconds, microseconds and nanoseconds which becomes very handy at times. A word of caution, Stopwatch is not thread safe and you have to figure it out how to make it thread-safe :-).

In order to understand the full power of Stopwatch, you may want to read Javadocs of Stopwatch, Timer and TimeUnit.

In my next post, we will see yet another Guava class and its use.

You may also want to check my previous post on Guava's Postconditions.

27 October 2011

Preconditions - (Java) Guava Collections Library

Fail early. It is applicable in life and programming.

The methods (or functions) are inevitable part of your code. The methods operate on the objects (or state of the system) and has a logic to do. Sometimes, the logic cannot (or rather must not be applied) due to non-availability of data (objects) or data being in an inconsistent state.

Let us take simple IPv4 address validator. Here is the code.

public static boolean isValidIPV4Address(String ipAddress)
{  
boolean isIp = false;
StringTokenizer tokens = new StringTokenizer(ipAddress, "."); if(tokens.countTokens() == 4)
{
// logic to validate ip address
// set isIp to true or false;
}
return isIp;
}

The above code is potentially dangerous if null is passed into the method. It crashes and brings everything to grinding halt. We can fix this by just adding a null check (and we have been often told to do that but we hardly follow it). The code will look something like this.


public static boolean isValidIPV4Address(String ipAddress)
{
                if(ipAddress == null)
                    throw new NullPointerException();
boolean isIp = false;
StringTokenizer tokens = new StringTokenizer(ipAddress, "."); if(tokens.countTokens() == 4)
{
// logic to validate ip address
// set isIp to true or false;
}
return isIp;
}

And thats how you fail early. You validate the inputs (irrespective of the number of arguments) and flag/fail early without changing the state if the arguments (inputs) sound weird. If you still operate on the data that is passed and change the state of the system, you add more pain by pushing the system to an inconsistent state. [Read Effective Java by Joshua Bloch if you haven't read it yet and if you want to be told by a Java expert]

If you think above is a good way, hold on. You have better way.

Guava (Google collection library) has a better way to handle this by using Preconditions. Replace the null check with one line statement and bingo Guava helps you to throw the exception.


public static boolean isValidIPV4Address(String ipAddress)
{  
Preconditions.checkNotNull(ipAddress); 
boolean isIp = false;
StringTokenizer tokens = new StringTokenizer(ipAddress, "."); if(tokens.countTokens() == 4)
{
// logic to validate ip address
// set isIp to true or false;
}
return isIp;
}

If "null" is passed, Preconditions.checkNotNull throws NullPointerException. You can also check for the validity of expression using Preconditions.checkArgument (check out Javadoc). Apart from improving the readability of code (to reduce boiler plates from code), it helps you to fail faster without causing any trouble to the state of the system.

Check out Preconditions. Here is the Javadoc of Preconditions. Don't you think that Preconditions is worth adding in our source code :-)

In the next post, we will see how to measure time with Guava's Stopwatch.


04 April 2011

Design Patterns - How to Learn

Most often we encounter people whom they call themselves as expert in design patterns. They start off with the discussion saying that they know Singleton pattern - knowing little bit of what is singleton and completely ignorant of why Singleton is needed. While design pattern helped experts to improve their productivity and the quality of software they write, it hasn't done anything to novice designers like us. Right away, let me say that it is not the problem with the design patterns. It shows that the way we learn design patterns isn't right.

Learning design patterns starts with getting hands dirt with abstraction, hierarchy, encapsulation and loose coupling. All these attributes do not come easy and they evolve over a period of time with imagination. We have to visualize how a solution is better than the other and if we can solve by writing code, it really helps us to understand deeper.

Keeping that mind, i started to put together series of puzzles on software design to improve my design knowledge - particularly on object oriented software design for quite sometime. I would say that this method is changing the way i think. If you also want to get your hands dirt, you can find puzzles tagged as "Design for Fun".


Let me tell you, more puzzles are on the way.

27 March 2011

Software Design Puzzle #8 - Manufacturing Soaps

Assume that you are an expert in manufacturing many varieties of soaps - bath soaps, detergent soaps and all soaps in the earth. You have a magic recipes of soap making right from procuring raw materials till manufacturing soaps and shipping to stores. There are many processes involved in soap making and there are various flavors for each process. And some of the processes are optional and specific types of soaps. For example, you know that you to have add a lot of scents for bath/toilet soap and lot of whitening material for detergent soaps. 

The puzzle is to design the soap manufacturing with lot of processes/steps and all these processes/steps are sequential meaning that one process cannot start until the previous processes are complete. For instance, the process of shipping cannot happen until you make soap and you cannot make soaps until you form soap base and you cannot start soap base without raw materials.

Can you design soap manufacturing process where one step depends on so many previous steps. To induce your thinking, let us assume that you have the following processes/steps

  • Buy raw materials (can be different based on the soaps)
  • Mix raw materials
  • Form soap base
  • Make soaps
  • Package soaps
  • Ship It
You are free to add more steps but the key is to come up with a process that can be changed dynamically based on soap types that are going to be invented in future :-)

19 March 2011

Interesting Tools on Bytecode Manipulation

The last week, i got a chance to experiment on couple of bytecode manipulation APIs/tools and thought i can share my learning here.

Javassist is one of bytecode manipulation APIs that helps you to manipulate bytecode and it is simpler to use. I wrote a simple method profiler that takes class files as input and instruments the bytecodes in each method. Added, method start time, complete time and measured the time spent in the method. One good thing about Javassist is that you can directly add code written in Java that compiles on the fly while instrumentation. Seems like bytecode instrumentation is bit easier in Javassist. With Javassist, you can also do on the fly instrumentation during classloading phase.

Retroweaver is another bytecode manipulation tool that back ports the code compiled by Java 5 to Java 1.4. If you have written classes (or a third party classes/libraries) in Java 5 and if your production system still runs with Java 1.4/1.3/1.2, you may want to check out this tool. It is really cool to use latest APIs/libraries in old JVM. Retrotranslator is a similar tool.

Bytecode engineering seems to be very interesting.

16 February 2011

Software Design Puzzle #7.2 - Thread Pools & Tasks

Please refer to previous two posts on the same problem - Implementing Thread Pools and Tasks. Here is the link for your convenience.
Yesterday, i added a requirement that i want to have a priority for tasks (a problem on data structures and algorithms). Today, i thought about another feature that gives a lot of flexibility (real OO design). In the above examples, we didn't talk much about the threads in thread pools. Can we try to make threads in thread pool dynamic entity - based on the need, the number of threads in thread pool should grow or shrink. Here are my next set of questions.

  1. What are the design decisions that i should take so as to make thread pool dynamic.
  2. How can i make threads, tasks, thread pool at the topmost level of abstraction and yet get many different concrete implementations.
  3. How can i ensure that the code I am going to develop after two years (due to new requirements) doesn't affect my code now (seal the code from modification for new requirements)
  4. How can i bring in hierarchy, levels of abstraction and modularity for better design?
  5. Do i have any design patterns?

15 February 2011

Software Design Puzzle #7.1 - Thread Pools & Tasks

Refer to the previous post, Software Design Puzzle #7 - Thread Pools & Tasks. This post is an addendum to the previous post.

I m going to add one more enhancement to the thread pool design. The enhancement is to come up with a priority queue for tasks. Each task will have certain priority, an integer that increases as priority increases. At any given time, the task with highest priority has to be selected and run by threads in thread pool.

Can you refactor your design?

13 February 2011

Software Design Puzzle #7 - Thread Pools & Tasks

We know what is thread. The thread is an independent execution path or entity in a process. When you want to exploit multi-core (increased processing) or do some blocking operations, the thread is the default destination (increased interactivity, heavy input/output operations). In any programming language that supports multi-threading, you run the code that can be run as independent execution path as thread with each having its own context. The infrastructure that is needed to run threads in parallel like stack, program counter, registers are tightly coupled with the code that runs. Due to this tight coupling, each time you need an independent path (let us call it as task), you create a thread (the infrastructure) which has its own overheads. Is it possible to change code of the thread?

Obviously the next step is to separate out the infrastructure and the task which is achieved using thread pools. Here is the next problem.

Write a simple thread pool in Java with following requirements

  1. Have a fixed but configurable number of threads in thread pool. At any point of time, you can run up to N threads.
  2. Have a task queue (or a suitable data structure). This can be much bigger than number of threads. The tasks wait in the queue for their turn.
  3. The thread should consume tasks from the task queue and execute it. It can be any task (but you have to ensure some fairness). The role of the thread is to run task without bothering too much on what it does and how it does.

06 February 2011

Puzzle - Help the Painter

Your friend is a painter and he paints houses for quite sometime. He is highly professional and highly sought after as he known for his quality work and fair painting charges. Throughout his life he has painted lot of houses that are regular sizes - rectangles, squares and circles. He charges his customer based on the area he paints. (you see calculating area for regular shapes is cake for him)

Last week, a new potential customer called him up for a huge order that will keep him and his team busy for next five to seven months. The catch here is that the customer is not willing to pay a penny more and even your friend being a professional painter wants to quote a fair pricing strategy to his new potential customer to win this order. BTW, did i tell you that the area to be painted are irregular shapes.

The painting area is

  • Irregularly shaped like amoeba
  • Each surface is uniquely shaped (bare minimum he needs to paint 1000 such surface different in 1000 ways)


What is the pricing strategy that your friend can offer to his customer so that both your friend and his customer is happy.

30 January 2011

Java Threads - Why you can't start a thread twice?

Assume the following code
class Mythread extends Thread {
          }


          Mythead thread = new Mythread(); 
          thread.start(); thread.start();

Why you cannot start the thread (i.e calling thread.start()) twice? Why JVM panics when you do that?

26 January 2011

Why Loose Coupling is Strong Coupling?

Often, senior programmers insist us to have a loose coupling. In order to appreciate those words - "go for loose coupling", we need to understand what does it mean by loose coupling.

There is another good practice encouraged by senior developers which is modularity. Often, they want us to write function or methods which is just a screen's length (by the way for 14 inch monitor :-)). How can loose coupling be possible when you have modularity? When your application is highly modularized, you heavily depends on many modules to accomplish things.

The concept of modularity in fact leads to loose coupling. By modularity, we make a part of the code to do one critical thing. We don't want any part (or technically a unit) of the code to do two things. We want to restrict to a critical thing and by modularity we also want to hide the gory details underneath. When modularity is practiced in a structural programming, we tend to get loose coupling in a structural language/programming and when we follow right abstraction in object oriented paradigm, we get right loose coupling in object orientation. The modularity mean do one thing that is appropriate to the level of abstraction.

The loose coupling is not restricted to a specific programming types but rather has to be seen as a concept. The application of concept can be different in different programming language types like modularity, abstraction (having hierarchies of abstraction, each level of abstraction marries to a same level of abstraction to realize the functionality).

So, loose coupling helps us to realize strong coupling between objects but avoids tight coupling (which is a code smell).

What do you think?

16 January 2011

Emergent Behavior & its Role in Big Picture

A football team wins FIFA world cup, a society that is progressive, a complex software system that fails in field utterly, a strategic group fail to deliver a good strategy, a promising youth later turns out be a pathetic failure at later stage of his life due to his tiny compromises, a kid by continuous practice turns out to be a distinguished performer in arts by being passionate everyday. 

Let us see a software perspective.

Few years back, having a personal computer with 2GB of RAM is very rare and today it is common thing and so is parallel processing (particularly after multi-cores becoming a common thing). The sheer performance of the hardware has increased at least few folds. However, Microsoft Windows froze few years back and it continues to freeze even now. BTW, the freezing is little to do with MS Windows (but it plays a role). Most of the damage is done by the application developers.

Few years back, the developers used to think that we have 512 MB RAM and the part of it is ours (may be half of it). Today, we tend to think that 2 GB RAM is available in the system (as we give minimum requirements in our user guide or release note) and half of it ours. Our thinking doesn't change over a period of time. When we develop applications, we think that there will be few applications that will coexists with ours.

Let us assume that for a 2 GB RAM and 2 GB of swap, we think that at least four applications can run with each  consuming 1 GB of RAM. The math works perfectly well on paper and for the first few days until the processes grows up to 2GB (put together). Beyond 2 GB, the operating system has to swap some portion of RAM to disk. Once few pages are swapped, a method call or access to heap may lead to page miss and the operating system has to fetch the page from swap - an interesting complexity gets added. Due to this complexity, the time to execute an intended operation takes little longer which again may increase the time and memory footprint (as delayed execution delays reclaim of memory which will become eligible for reclaim if the program runs as per plan). This complexity grows exponentially until few process crashes or the system crawls and you decide to give a rebirth by rebooting the system.

But mathematically, we think that there is no problem with the parts (each process) but the entire issue is with the whole (the operating system and the processes put together). This is called emergent behavior. The whole exhibits a behavior that cannot be explicitly attributed to the parts and each part thinks that none of its behavior is responsible for the whole behavior. There is inherent complexity due to movement of parts, the environment and the processing of events that are external to the parts (and no way related to any of the parts).

This emergent behavior affects the operating systems, make climate change a failure or reason for human stupidity. Emergent Behavior proves that the software can be made with the same process that is used to make this universe and the same process can be used to attain spiritual enlightenment.

Think about how an image is formed. The image are formed using pixels. Does removing a pixel lead to disfigured image? No. The disfigure is almost negligible. So, the whole has a power than its parts due to the emergent behavior. People who talk about "the bigger picture" should focus more on studying "emergent behavior". Generalizing things from individual events can be done well by understanding this emergent behavior (and it actually helps not to generalize the exceptions).

15 January 2011

Importance of Expressiveness in Programming Languages

It is a while i had a post here and in fact this is my first post in 2011. I happy to have my first post of the year on the topic that is of huge interest to me these days.

Why aren't we still programming in assembly languages? The threads, inter-process communication mechanisms can be done in assembly language but not easily though. With assembly language, there is only level of abstraction - ability to see the requirements as sequence of bits that are comprehensible by the machine. When you want make your program to run in another target platform, you may need to change both the abstraction and implementation. The assembly language is not as expressive as procedural language. In order to increment a number, you have locate the address, move it to accumulator, add it by one and store back to the same memory location. There is no clear division of responsibility. You have more number of steps to do in assembly but that is very primitive in procedural language.

Why aren't we writing program with procedural language alone? Procedural language is less expressive than object oriented program. The amount of code that a developer should write to accomplish a logic is more in the case of procedural language. While the level of abstraction is moved a level up from the bare machine, still the abstraction is not efficient to solve a problem in application domain. As far as the application is concerned (and in imperative languages), a task is accomplished with side effects. You call a method and it changes the state of few objects. The data and operation have to cohesive. So, in application development it is highly essential that we glue the data together with operations because these operations are specialized over the data.

There are other types of programming languages like functional programming inspired by lambda calculus and one can write their own language for a particular domain. There is one basic commonality in all types of programming languages - they try to be more expressive to make the life of developers easier. For example, today many developers are thinking about writing concurrent programs not only due to multi-cores being prevalent but also due to modern languages that made multi-threading highly expressive. It is easier to write multi-threaded in Java than in C or assembly.

As we move on, we will see many more expressive language, expressive than Java world and it is part of evolution of programming languages.

The article was written after reading Grady Booch's "OOAD with Application" and first chapter of "Programming Paradigms". Hoping to bring few posts on the subject this year. Watch out this space.

30 December 2010

A Question on Java Exception?

In Java, there are two types of exceptions - checked and unchecked.
Java compiler ensures that "checked" exceptions are handled and flags compilation error when checked exceptions are not handled. But it does not flag errors when "unchecked" exceptions are not handled. The subclasses of "RuntimeException" and the subclasses "Error" are "unchecked".

Why does Java have this as a thumb rule?