Why Android For Me ?

Android have been around since 2008/09 but I just jumped into the bandwagon 1yr ago and because of my passion with Android I’ve setup an Android blog called ozAndroid. The blog is about anything and everything Android and every time I come across people and told them about the website they asked me the question why are you into Android and why you setup your own website, what is your motive of getting into Android. Every time I always give a very simple answer – I love open source and I love Android. In reality the answer is deeper than that and thought I spend a bit of time outlining the the rationale behind my love for Android.

Open Code

This is the primary driver why I want to go deep into Android. I’m a developer at heart no matter what role I played in my professional life, I love looking at code. Nothing is more powerful and more exhilirating than looking at real production code and see it works. Google open sourced Android since day 1 (except for few Google’s apps) and they have committed to that promise until now. Google is a strong proponent for open source, I can’t see it any other way for Google to have a successfull product other than open sourcing it.

Linux

Linux is the heart of Android and without it Android (or even other mobile OS) will not even exist. This is the added bonus you get with learning Android that you will also learn about how Linux works and the nitty gritty of Linux – from bootloader, kernels all the way upto device drivers. Linux as a software is fascinating at the same complex, but if you learn it piece by piece you will know that it is not that hard to learn about Linux internals. Linux have been in the market for a long time so you can imagine the sheer amount of information and expertise that is out there on the ‘net. I started learning Linux kernels by reading code and also complimenting it with reading few books such as Linux Kernel in a Nutshell and Understanding the Linux Kernel. Learning Linux kernels it not only learning Linux as a software itself, I also start digging into hardware and learning about the processor, memory, etc and how these different devices comes together in Linux.

Learning hardware is very foreign for me as I don’t have electronic engineering background but that’s what drives me more and more into learning deeper on how the different hardware works together, you can say I’ve found something that I need to itch.  I admit though, that learning kernels from the internet is hard because there are so many resources out there and you get overhelm and also you don’t know where to start and what to read first. This is where I turn to the books I mentioned before as those books (even though bit outdated in terms of publication years) can give you pointers how and where to start learning about the kernels. There is no silver bullet in learning kernels you need to find out what you are comfortable with. I’m more comfortable with reading code but referring to books as a starting point and as I understand more about a topic I dig deep into the ‘net to find what I need.  The other best place I found was going through website such as github, I have made few friends by communicating with developers whose project are hosted in github. Most developers are more thatn willing to help out as long as your questions are clear and tell them exactly what answer you are looking for and also what you have done so far to understand about something. We as developers are blessed with the ability to network with so many different talented engineers around the world, and now is the time to tap into their knowledge to gain more knowledge for yourself.

C/C++/ASM

The other reason why I was attracted to Android was because of the language it was written in – C/C++. I’m a strong believer that no matter what language you use – may that be Ruby, PHP, Scala, etc, it still goes back to the root. I like to call C/C++/ASM language as ‘Bare Metal’ language, and it’s been eons since last I’ve used them. I’ve wrote a book before (it was written not in English language) when I was 17yrs old back in the days of Turbo C++ 1.0 and I guess it’s true when they say ‘First love never dies’, I’ve always had a thing for C/C++. For me learning C/C++ was a natural fit and all I have to do was refresh myself on how to use it again and also learning more about GCC at the same learn how the whole things work with Linux.

Going into C/C++ and also ASM kills 2 birds at the same time for me, on one side I will be using it for Android (may that be user or low level coding) and also Linux. The ASM part is needed to learn more into the hardware side as most of hardware initialization and to understand the hardware side will need me to learn ASM again. The ASM that I have to learn is more for ARM as most of Android devices runs on ARM hardware, however that could change in the future. Nonetheless, by learning C/C++ this will give me an advantage that if down the track there is a new technology after Android it won’t be hard for me to jump as I have all the necessary knowledge on coding in the language, and you can’t go any lower than C/C++ and ASM combo.

Embedded

I’ve been doing coding on PC for as far as I remembered, and this closed me from knowing that there are more world than the PC world. I came to understand and learn about embedded when I came across Android, the more I dig information about Android the more I can see how closely it is related to the embedded world, not to mention the history of Android. Embedded market is bigger than the PC market and it is a very different world than what I was used to. Embedded system is different than the PC world, in embedded you do need to understand hardware as electronics and need to learn the basics of electronics. I never thought in my lifetime that I will be touching hardware but because of Android I’m really into electronics and now I’m coding into the bare metals in ARM processor. Learning electronics enable me to see coding in a different way, I always thought that everything in PC runs on 1′s and 0′s but after learning embedded I now understand that everything is drivem by voltages (0v 0r 5v). Because of the exposure I have to electronics I’m able to understand better how Android can be run on different system (besides mobiles and tablets) and what is needed to run Android properly on an embedded system.

Mobile phones have different kind of sensors such as GPS, Accelerometer, Radio, etc. Undestanding how these different sensors work and how it is being used in Linux and in turns the Android apps communicate with them is what interesting as this touches the different Android layer from the apps layer all the way to the hardware layer. This kind of sensors are now gaining traction is because the ability to manufactured them in such a small package that it can be integrated into the mobile phones, and this is what drives me to understand how do you use them inside and outside the phones. This ties in nicely with learning Linux, Hardware and also the C/C++ programming. Some of the books that I read for embedded topics - Embedded Linux Primer: A Practical Real-World Approach and Building Embedded Linux Systems

User Interface

Most of my career I’ve been doing lots of back end coding in Java space, sure I do write code for front end but at heart I’m not a UI person. I know how to write the code to come with a UI but I can’t come up with a pretty UI for users to look at. Learning Android have given me a different perspective on looking at UI, what I found was the UI makes a big impact regardless how bad or good your backend is. Designing UI for embedded devices which have space constraint do require certain skills than designing for web UI. In PC world we take drawing a window for granted because it is available but in embedded world this is a big issue because you need to find a proper UI library that you can use for your product. With Android all this are provided but it do takes time to really understand how the whole UI framework works and how to use them properly.

As you can see the reason for learning Android is much bigger than just Android itself it’s a whole new world out there that I haven’t touch and I’m sure many of us developers must not have heard or used what I’ve discusses here. We are living in exciting times where things are getting smaller and faster and we are blessed to work in industry that always comes out with something new and exciting before you can finish learning what you are doing at the moment. Passion and patience is the important ingredient in learning things and as long as we have the drive it’s not easy to do things at the same time. I’m really excited about the potential Android and it’s ecosystem can bring to us and future generations.

I’ve setup the website not only to share information with whoever wants to get informed about Android but also at the same time I want to make it as a repository for learning about Android – may that be application development, kernel, troubleshooting, hardware, etc.
* C/C++/ASM
The other reason why I was attracted to Android was because of the language it was written in – C/C++. I’m a strong believer that no matter what language you use – may that be Ruby, PHP, Scala, etc, it still goes back to the root. I like to call C/C++/ASM language as ‘Bare Metal’ language, and it’s been eons since last I’ve used them. I’ve wrote a book before when I was 17yrs old back in the days of Turbo C++ 1.0 and I guess it’s true when they say ‘First love never dies’, I’ve always had a thing for C/C++. For me learning C/C++ was a natural fit and all I have to do was refresh myself on how to use it again and also learning more about GCC at the same learn how the whole things work with Linux.
Going into C/C++ and also ASM kills 2 birds at the same time for me, on one side I will be using it for Android (may that be user or low level coding) and also Linux. The ASM part is needed to learn more into the hardware side as most of hardware initialization and to understand the hardware side will need me to learn ASM again. The ASM that I have to learn is more for ARM as most of Android devices runs on ARM hardware, however that could change in the future. Nonetheless, by learning C/C++ this will give me an advantage that if down the track there is a new technology after Android it won’t be hard for me to jump as I have all the necessary knowledge on coding in the language, and you can’t go any lower than C/C++ and ASM combo.
* Embedded
I’ve been doing coding on PC for as far as I remembered, and this closed me from knowing that there are more world than the PC world. I came to understand and learn about embedded when I came across Android, the more I dig information about Android the more I can see how closely it is related to the embedded world, not to mention the history of Android. Embedded market is bigger than the PC market and it is a very different world than what I was used to. Embedded system is different than the PC world, in embedded you do need to understand hardware as electronics and need to learn the basics of electronics. I never thought in my lifetime that I will be touching hardware but because of Android I’m really into electronics and now I’m coding into the bare metals in ARM processor. Learning electronics enable me to see coding in a different way, I always thought that everything in PC runs on 1′s and 0′s but after learning embedded I now understand that everything is drivem by voltages (0v 0r 5v). Because of the exposure I have to electronics I’m able to understand better how Android can be run on different system (besides mobiles and tablets) and what is needed to run Android properly on an embedded system.
Mobile phones have different kind of sensors such as GPS, Accelerometer, Radio, etc. Undestanding how these different sensors work and how it is being used in Linux and in turns the Android apps communicate with them is what interesting as this touches the different Android layer from the apps layer all the way to the hardware layer. This kind of sensors are now gaining traction is because the ability to manufactured them in such a small package that it can be integrated into the mobile phones, and this is what drives me to understand how do you use them inside and outside the phones. This ties in nicely with learning Linux, Hardware and also the C/C++ programming.
* UI
Most of my career I’ve been doing lots of back end coding in Java space, sure I do write code for front end but at heart I’m not a UI person. I know how to write the code to come with a UI but I can’t come up with a pretty UI for users to look at. Learning Android have given me a different perspective on looking at UI, what I found was the UI makes a big impact regardless how bad or good your backend is. Designing UI for embedded devices which have space constraint do require certain skills than designing for web UI. In PC world we take drawing a window for granted because it is available but in embedded world this is a big issue because you need to find a proper UI library that you can use for your product. With Android all this are provided but it do takes time to really understand how the whole UI framework works and how to use them properly.
As you can see the reason for learning Android is much bigger than just Android itself it’s a whole new world out there that I haven’t touch and I’m sure many of us developers must not have heard or used what I’ve discusses here. We are living in exciting times where things are getting smaller and faster and we are blessed to work in industry that always comes out with something new and exciting before you can finish learning what you are doing at the moment. Passion and patience is the important ingredient in learning things and as long as we have the drive it’s not easy to do things at the same time. I’m really excited about the potential Android and it’s ecosystem can bring to us and future generations.
I’ve setup the website not only to share information with whoever wants to get informed about Android but also at the same time I want to make it as a repository for learning about Android – may that be application development, kernel, troubleshooting, hardware, etc.

Google’s Android Strategy

Early last year we heard a lot about Blacberry and Apple but just bit of whispers when it comes to Android but this year everything is about Android. It’s no more prediction but it’s the reality that Android now is the market leader and thanks to Google and its partners the consumers now have more choices of smartphones and tablets that they can ever dream of. On personal level I do love Apple but the thing that stops me from owning or having a go at Apple is the price point and the proprietary nature of their products. I believe in open technology as it’s been proven over and over again that you grow your business not within but from the product ecosystem, allowing the proliferation of new products and technologies to grow and prosper. Android have both this and this what have me hooked since the first day I stumble into it.

Since I will be investing my time into Android I’ve been thinking hard on what the future will be and what it would looks. To do this I try to put myself in Google’s shoes and try to see it from their viewpoint, what I come out with is this 3 viewpoints

1. Flood the market

Mobile phones are part of our life, it’s like the air we breathe in without it we humans are lost. Without a doubt people will keep on buying mobile phones, the questions that comes to mind if you build a mobile phones, how do you make sure that your product can penetrate different kind of consumers ? the simple answer is ‘flood the market’. Consumers love to have choices and love to buy something within their budget but have the same kind of ‘feeling’ as other expensive product. Android fits the bills, because it is open any kind of mobile manufacturer can design product for different kind of consumers with different functionalities attached to it. This is the same kind of strategy adopted by all the major manufacture pre-Android era. This will allows Android to get the market and mindshare of the consumers, as this will allows different users to have access to Android mobile devices. Android have been very successful doing this for the last 1.5-2 years as can be seen by the different reports that comes out from the research companies. This will keep on continuing with the new powerful devices that are coming out to the market as there are still segments of users that have not switch to smartphones.

2. Happy Developer happy consumer

Once Android have established itself in the market it needs to maintain it’s position and love in the consumers mind and heart, how can it do that ? the simple answer is applications. Android apps are the lifeblood for the survival of Android and it’s ecosystem and this is the biggest investment that Google and it’s partners need to do now and into the future. First and foremost Google is a software company not a hardware company so it comes as natural for them to do software while other vendor they rely on software and hardware. Google invest heavily in their software and this is how they know best, and besides that they have good relationship with developers all over the world. Constant churning of application for consumers is the only way to make sure that Android will stay alive and move forward. Google has the infrastructure in place that allows them to scale so it comes naturally for them to support apps that will run on millions of devices without investing heavily into it. In Google I/O 2011 there was a lot of emphasis placed on Android Market and the developer community which really shows the commitment that they have to make sure Android will keep on growing and increasing in market share.

3. Branching out

Mobile device is not the only device that Google is targetting at. Android will evolve in differnt kind of devices which will allow it to live on beyond mobile. Google has proven in the market that they can collaborate seamlessly with hardwarde vendors to bring successful product and make lots of money, this will opens the way for them to enter into different kind of devices that are available in the market to run Android. The vision that they are trying to bring into life is by making Android runs on devices which will allow those devices to communicate with one another, so not only human communication Android can deliver but also on device communication level. At the end of the day consumers will have the ability to control their devices with one single controller which will be their phone/tablets. At the same time they will have choices which devices they need and wants to buy.

First foray with Google v8 Engine

I feel butterfly in my stomach everytime I try new technology or language, it’s like love at first sight and I had this kind of feeling last night when I decided to learn more about node.js. I’ve always been fascinated with cross languages and their boundaries and how different programming language works together running on different level, this is the same reason why I venture into the world of Java 9 years ago. I’ve been meaning to learn more about Google v8 Javascript engine as I’m interested how this will be useful in times to come for me and for the greater good.

While reading through v8 information on it’s website I start thinking of looking around for samples that will show the power of v8 on all different aspects and I managed to find a very interesting framework caled node.js. At first I thought that this might be just another Javascript framework but boy I was wrong!. Apparently it’s a whole lot more of a framework, it really dig deep into v8. node.js really shows you how to really integrate with v8 inside and outside and this was perfect for me as I could learn more that I was hoping for, it was a dream come true, let’s move on.

Following are the steps that I did to venture into this new journey.

1. First I checked out v8 source code from their source code repository and start building it. I followed the instruction as per what is written in the following link http://code.google.com/apis/v8/build.html. My home dev machine is Ubuntu 10.04 so it was straight steps to follow from that website

2. After building v8 I started looking node.js website http://nodejs.org/ and check out their source code as well. The node.js source code includes the v8 source so my setup look as below

3. Now I need to build node.js. Now, node.js is not only a bunch of .js files that you can use straight away into your Javascript code it is a combination of .js, .cc and .h files, what this means is it is basically an application that ‘hooks’ into the v8 engine to run it’s internal Javascript code and you can ‘hook’ into, if you are confused don’t worry you can read up on node.js website and you will understand what I mean. So what I need to do now is build node.js which is a straight forward process and it’s outlined in their wiki page https://github.com/joyent/node/wiki/Installation. For me basically I just need to run the following command

cd /home/nanik/v8
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
export PATH=$HOME/local/node/bin:$PATH

After running the above command I can run the application from anywhere as it’s include in my local environment

4. Now that I have node.js installed I need to run a sample application to use it so that I can walk through the code into node.js and into v8 to understand how the whole thing glue together, for this I pick up a simple application that you can find in node.js website, the code is as follows

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

so now I run node.js using the above sample as shown on the screenshot below

ignore the other messages that are shown on the console as those are the log messages I put inside the node.js code to understand the flow, what you should be getting is the message that is surrounded by the blue line. This particular sample code is running as a server that uses port 1337 and ready to accept incoming request. The response that will be send back will be a string ‘Hello, World’ as you can see below

5. After successfully run the code I was very curious to understand how the whole thing works, so following is breakdown of my finding. The explanation below is a walkthrough the executing path of running the server sample code

a. The node.js life starts from the source file node_main.cc which will bootstrap node.js itself and also v8 engine. The calling of v8 engine code resides inside node.cc file :

		    int Start(int argc, char *argv[]) {

		      v8::V8::Initialize();
		      v8::HandleScope handle_scope;

		      argv = Init(argc, argv);

                      ....
                      ....
                      ....

		    }

b. After v8 is successfully initialize the engine will start executing the server sample code and this is where things get interesting (I’m not going to go through the Javascript syntax or flow).

c. The code http.createServer ( .. ) is calling the js function inside the http.js which is located inside the /lib directory of node.js source code. The http.js source is using net.js code extensively which takes care of the socket housekeeping. The crux of the socket housekeeping code is inside the .cc code (C++ code) which is called by the node.js Javascript code which is possible because v8 allows us to do this.

d. For our sample the main function that we are interested in is the Server function which is shown below

		function Server(/* [ options, ] listener */) {
		  if (!(this instanceof Server)) return new Server(arguments[0], arguments[1]);
		  events.EventEmitter.call(this);
		  var self = this;

                      ....
                      ....

		  self.allowHalfOpen = options.allowHalfOpen || false;

		  self.watcher = new IOWatcher();                                      (*)
		  console.log('setting wathcer....');
		  self.watcher.host = self;
		  self.watcher.callback = function( val,val2,val3,val4) {	       (**) this code is the code that I modify from the original source code to show how parameter is pass back from v8

The Server( ) function is the main function that will create a socket process that will receive connection for the port that we specify which in our example is 1337. This function utilize callback mechanism where this callback will be called from v8 from node.js, the question that come to our mind now is how does the Javascript knows which C++ function to call and how it is called, this is the magic of v8

e. In order to understand this part you need to read and understand the internal working of v8 integration that you can read in here http://code.google.com/apis/v8/embed.html (especially the Templates and Accessors section). The way node.js works it’s magic is by registering the function that it can called from Javascript and mapped it to the C++ function which is shown in the code below

		  void InitNet(Handle<Object> target) {
		    HandleScope scope;

		    NODE_SET_METHOD(target, "write", Write);
		    NODE_SET_METHOD(target, "read", Read);
		    NODE_SET_METHOD(target, "sendto", SendTo);
		    NODE_SET_METHOD(target, "recvfrom", RecvFrom);

                      ....
                      ....

		    NODE_SET_METHOD(target, "connect", Connect);
		    NODE_SET_METHOD(target, "bind", Bind);
		  }

The above code snippet was extracted from node_net.cc, what this means is that when you want to use the function connect automatically v8 will know that it need to call the C++ function called Connect inside this call. The way node.js register this call to v8 is using the following macro

		  NODE_MODULE(node_net, node::InitNet);

which resides in the last line of the node_net.cc

f. To use the function inside node.js Javascript code it define the following variable

		var socket = binding.socket;
		var bind = binding.bind;
		var connect = binding.connect;
		var listen = binding.listen;
		var accept = binding.accept;
		var close = binding.close;
		var shutdown = binding.shutdown;
		var read = binding.read;

which is found inside the net.js, what the code is saying is basically I can use the variable accept to accept the socket connection which is used as follows

		var peerInfo = accept(self.fd);

g. node.js is an evented I/O framework so it uses the libenv framework http://software.schmorp.de/pkg/libev.html. Inside the Javascript Server(..) function you will see the following code

		self.watcher = new IOWatcher();

		self.watcher.callback = function( val,val2,val3,val4) {

The IOWatcher is an internal C++ node.js code that it uses as a timer to interact with the libev framework. In order for the socket connection to start listening the watcher variable will need to be initialize using the set( ) method as shown in the below code

		Server.prototype._startWatcher = function() {
		  this.watcher.set(this.fd, true, false);
		  this.watcher.start();
                      ....

		};

the this.watcher.set( ) function is calling the following C++ function inside the node_io_watcher.cc

		Handle<Value> IOWatcher::Set(const Arguments&amp; args) {
		  HandleScope scope;

		  IOWatcher *io = ObjectWrap::Unwrap<IOWatcher>(args.Holder());

		  if (!args[0]->IsInt32()) {
		    return ThrowException(Exception::TypeError(
			  String::New("First arg should be a file descriptor.")));
		  }

		  ....
		  ....
		}

The function of the IOWatcher::Set(..) code is to obtain the parameter that is being passed along and use it to call the libev function to listen to the connection

h. Remember the callback function inside node.js Javascript code ?

	       self.watcher.callback = function( val,val2,val3) {
		    .....
		    .....
	       }

This callback function will be called from node_io_watcher.cc code when it a client connect to the socket and the code responsible to call the Javascript callback function is as follows

	      void IOWatcher::Callback(EV_P_ ev_io *w, int revents) {
		IOWatcher *io = static_cast<IOWatcher*>(w->data);
		assert(w == &amp;io->watcher_);
		HandleScope scope;

		Local<Value> callback_v = io->handle_->Get(callback_symbol);
		if (!callback_v->IsFunction()) {
		  io->Stop();
		  return;
		}

		Local<Function> callback = Local<Function>::Cast(callback_v);

		TryCatch try_catch;

		Local<Value> argv[3];
		argv[0] = Local<Value>::New(revents &amp; EV_READ ? True() : False());
		argv[1] = Local<Value>::New(revents &amp; EV_WRITE ? True() : False());
		argv[2] = Local<Integer>::New(Integer::New(33));

		callback->Call(io->handle_, 3, argv);

		if (try_catch.HasCaught()) {
		  FatalException(try_catch);
		}
	      }

I’ve modified the code slightly as the callback is expecting 3 parameter pass to it (val1, val2, val3) which is represented by argv[0],argv[1] and argv[3]. In this example if I connect to the server I will see a print out of 33 for val3 as that is what being passed from the C++ code as can be shown below

6. The integration work is bit tedious and error prone I must say if you are not careful but once you understand how to do it you can appreciate the power in terms of what you can develop using v8. Happy v8-ing !

Correlation between cost of living and your mortgage rate

Over the last 4-5 years lots of people have bought into the Australian dream (which is the same as American dream) of owning their own home. It’s human nature to own a home and everybody in their life will want to have a roof that they called their own (me included). Owning a home have been every living human being’s dream living in this world no matter which part of the world you are living in. Buying a house now and before (25-30 yrs ago) is totally different concept in terms of what you are paying and where prices are going. Back then financial systems were not as advanced as they are now and micro/macro economics are much simpler than what they are today. Cost of living were not that high as there were not that many people and most countries are self fulfilling in terms of supporting their own local economies. Nowadays all those factors are totally different and it plays different kind of roles (this will be a separate topic on it’s own).

Currently in Australia the market mortgage loan fluctuates between 6.85% – 7.05% depending which lenders you are on. Historically for Australia the current rate is low but compare to other developed countries it’s the highest. Most parents will tell their kids that what they are paying now are cheaper than what they were paying before, which is very true but, in terms of monetary value it’s much higher than before. The reason for this is because

1. The mortgage loan taken out is much higher that what it was 25-30 yrs ago.
2. Cost of living (in terms of inflation increases) have moved higher than inflation rate.
3. Even income tax rate have come down compared to before but we are paying tax on other things that we need in life.
4. Average wages have not kept up with cost of living increases.

Cost of living have increases substantially over the course of 3-4 yrs, the following things pops up in my mind when it comes to price increases:

1. Fruits and Veggies
2. Petrol price
3. Health insurance
4. Car insurance
5. Medicines
6. Electricity
7. Water
8. Council rate
9. Phone (land line and mobile)

As we can see from the above all the necessary day to day living cost have increased consistently.

When people takes out home loan they don’t count their capacity to service the loan by taking into account all these increases in cost of living and other relevant costs. Almost all people that I know never takes into account cost such as : council rate, cost to maintain the house (may that be renovation, plumbing, pavement, etc), water, etc. On paper most of these expenses may look trivial but once you aggregate them you are in for a surprise.

People buy property as a mechanism to save for their retirement age, which I personally think is a good thing and they want to have a roof on top of their head when they retire at the same time to have something that they can fall back on in case of financial hardship. However, it is not as simple as it may sounds (for some people they tend to put their head in the sand than hearing all the problems) as increases in cost of living translate indirectly to increases in interest rate which indirectly feeds on housing prices which will make house prices more vulnerable to drop or best stagnate in prices. For most people this annotation does not make sense, which is understandable as most people are not financially literate or they simply don’t understand investments and money economics. Most of us are not aware of what’s going on or how does the whole system works

The example below shows a mortgage calculation of $350,000 with 30 yrs lifetime for 7%, and as we can see that the monthly repayment for this loan is $2328.

Now let’s take the same loan with the same 30yrs lifetime but with interest rate of 7.25% which translate to $2387 monthly repayment.

As you can see that an increase of 0.25% in interest rate translate to an increase of extra $59 per month repayment. By standard this amount is bearable for most home owners as they are willing to fork extra for their home.

We have calculate the cost of interest that we have to pay for the loan now let’s do calculation to show how increases in cost of living indirectly translate to increase in interest rate.

Let’s assume we have the following monthly expenses

Water 116.67
Electricity 133.33
Gas 100.00
Council rate OR Strata 133.33
Water 116.67
Health Insurance 200.00
Cost of food 800.00
——–
1558.33

The calculation shows that every month we are paying $1558 in terms of our cost of living. Of course, on monthly basis this amount fluctuates but the trend is up and never down.

We know that prices at the moment all have gone up and it varies substantially, for example electricity prices has gone up more than 10% while other utilities has gone up between 5-6% (depending where you are living). Let’s take a conservative calculation and average the price increases to 7% per year. In recalculating our living cost we came up with the following

Let’s break down a bit on the calculation. 7% yearly increase on our cost of living translate to extra $1309 out of our pocket which is a permanent increase meaning once prices goes up it can never goes down (when was the last time you see the price of electricity, water and fruits gone down ?).

Let’s put the calculation of our mortgage to our cost of living together. We know now that we are paying (with interest rate of 7%) monthly repayment of $2328. Now assuming that the interest rate will stabilize for the next 1 year while cost of living keep on going up (which has been happening for the last 6months). We know that increase of 0.25% in mortgage rate will translate to extra $59 per month. We know from our previous calculation that our cost of living increased by $1309 per year which comes to $109/month which is much higher than the 0.25% increase in mortgage rate.

As you can see that even you are paying 7% in mortgage rate with the increase in cost of living you are indirectly been paying more than 7.25% in terms of interest rate out of your pocket. The feedback loop of price increases in cost of living brings rise to inflation which will bring rise to interest rate will kick in again and the next calculation you going to make for your loan will be based not on 7% but more likely will be above 7.5%

How to work effectively with open source code

I’m very fortunate to work in a team where we believe in using open source products and we have been using quite a number of them throughout the years. The beauty about using open source product is that it enables us to troubleshoot problem quickly as we can have a glance through it’s source code and of course the maintenance cost are much more cheaper compared to packaged products.

There are few things that I do personally to enable me to navigate through so many source code for the projects that we are using. This helps me to save time to understand better what a particular code is used for or how it is being used.

1. JUnit Test Cases

Most of open source projects have quite a lot of JUnit test cases written (of course there are few exceptions!). Test cases is the first place you want to look at to understand how a specific function works internally.

2. UML Diagram

When I’m dealing with a complex source code (something like Jetty, JBoss, etc) first thing I do to keep me sane is to dram UML diagrams of the classes, interfaces, etc that I’m working with. Not only this helps me to not forget any classes I’m working with but also will allow me to know the relationship between them. At the same time visual diagram is easy to recollect than reading lines and lines of code. Most of the time I draw with hand the UML diagram and when I get the chance I convert it into a digital diagram.

3. Code walkthrough in debugging mode

Code walkthrough by debugging or stepping through the code is very effective in understanding what a particular really do as this will give you an insight on the stacktrace as well as the variables that it is using. It will also gives you an insight on the different class implementation being used by a particular code as most of the code you are working with will be pretty much working with interfaces. Remote debugging is very useful if you need to debug a running application inside a container (debugging Spring, Hibernate, etc)

4. Search

Make sure you are viewing the source code using one of your favourite IDE as this will make your life much more easier. Using your IDE do a search for the particular class that you are interested in will be easy as it will allow you to find references to that class, classes being defined inside a property files or XML files, etc. By doing search you will be able to see the different places a particular class is used.

5. Create test case

Nothing beats getting your hand dirty. Create you own test case by creating new one or reusing an existing one. This will allow you understand more on how to use a specific function or API call. Along with other declaration that you have to do – i.e – exception handling, return value, etc.

6. Run fully functional demo

Most of the open source projects they have a fully functional demo that you can deploy and run. Running the demo will allow us to get a feeling on how it works and also you can do remote debugging at the same time to get an understanding on the internal working on the project. If the project does not include a fully functional demo than you can create a simple demo or find another open source projects that is using it and run it.

Buying a home not a child’s game

During the early years arriving to Australia I never had thoughts of buying a house or even looking for house but as time passes by and being part of the Australian community you tend to get carried away with the vibe that is happening in the society. One of this vibes is the obsession of Australians to own a house. Owning a house is everbody’s dream and goals in life, why is this ? well, sadly that’s how society measures our individual success. If you don’t have a house indirectly they labelled you as not a successful person on the other hand if you have a house regardless what your profession is they think you are successful. This is the irony of life being smart sometimes does not mean you are rich or you can afford something especially something major such as owning a house.

I compared the situation I’m in and my father’s. He bought his first house in the 80′s and he bought is cash and it was a brand new home and life keeps on going on after that. Never ever he bought something may that be a house, car, etc by taking out finance, he bought everything cash. His principle was if you can afford go for it but if you can’t afford stay put as there must be a reason
why you can’t afford it. Nowadays everywhere you see people have everything from games consoles, latest gadgets, cars, house, etc, even people who earns annually $30,$40 or $50k, all this thanks to the innovation in finance and it’s called DEBT. Without taking debt there is no way in hell people can buy anything, why ? because what people earns and what they spend are totally imbalance. The simple rules of spending is you spend what you earn but societies since the 90′s have been in spending spree, they spend more than they earn.

It is surprising to see how people whose earning is not considered as high earner are willing to buy a house carrying huge debt. Taking into consideration their style of living they won’t be able to survive if something goes wrong with their jobs or if all basic needs prices shoots up. Since the year 2000 house prices have shoot up because of the availability of credits provided by banks, mortgage brokers and other institutions and people have jumped the bandwagon regardless whether they can afford or not. This situation have been seen more obviously the last 3 years where a whoel bunch of new first time buyers with the help of government grants jumped into the housing market carrying with them huge amount of debt. If you asked anybody a simple questions such as “How many
percent of your monthly repayment goes to interest and principal ?” and you will for sure get a blank stare. I’ve seen this before and asked several people the same questions and they haven’t got a clue. Try another question – “How much do you spend every month for cost of living ?” you will get the same blank stare as well or if you do get an answer they will tell you “I don’t save as I put
everything into mortgage and living”, so in other words they have no clue at all!.

Coming back to the principle what you earn is what you spend, if initially you are already spending more than what you are earning how will you be able to repay your mortgage if some of the factors that life depends on changes substantially case in point – unemployment. Take for example interest rates – it have been going up ever since last year and it will keep on going up until the end of the year and most probably next year. Another case in point is cost of living – electricity, water, gas, food, medicine, insurance all these are the bare essentials of life and they have gone up substantially (we are talking in the vicinity of 15-18% annual rise). If your earning is not going up by that much how are you going to survive if you have major debt. Money management discipline is very important before taking any steps in taking debt, if you are able to manevour your lifestyle than you will be ok but if you are a person who hates changes than you are all alone.

Another thing that you have to remember when taking out mortgage is what is the split between interest and principal does your monthly repayments covers, let’s take a simple example:

Loan – $300,000
Mortgage Rates – 7.5% (fixed rate)
Monthly Repayment – $2000
Breakup Percentage – 90% interest and 10% principal ($200 for principal and $1800 for interest)
Year 1 Payment – 12 x $200 = $2400 paid for principal and 12 x $1800 = $21,600

As you can see from the simple calculation your after paying $24,000 for your debt basically you have only paid $2400 off from your principal so by the end of year 1 your debt will be down to $297,600 !. As you can see it’s a looong way before you can even pay down $100,000 off from your initial debt. The question that sometimes people don’t asked is what happen to the $21,600 we are paying every year, well that supposedly will be something you can “hope” to gain from the value of your house. So this means that if your house price is $350,000 you are “hoping” that every year your house price will go up by around 6% so that the interest you pay to the bank you will get it back in terms of your house price appreciation if one day you decided to sell.

If we assume that you have been paying for the last 10years this means that you are hoping house prices will go up by 6% x 10yrs = 60%, so you are “hoping” that your home will be valued at $560,000 or you will be able to sell around that much. If you are able to sell your house by that amount than you will get all your money back but if you don’t than you will lose money. This is taking into consideration that for the last 10 years you are spending any amount of money on renovations or fixing your house.

As you can see taking a debt is not a kid’s game if you are not smart enough in maintaining your household balance sheet than you will experience a stressful and bumpy rides in your life. Make sure if you take debt it’s something you are comfortable carrying with you, don’t take something that you can’t afford no matter how beautiful the house might be.

My interest rate analysis

There have been debates going on as when RBA (Reserve Bank of Australia) going to raise interest rates. There are some school of thoughts that are saying that interest rate could be cut before end of 2010, while there are some people that are saying it’s going to increase before end of 2010. Here are some of my thoughts

  1. Debt Market – Over the course of few weeks international debt market have been hit by several news about the European debt crisis. To summarize the problem it is hard for banks as well as private enterprises to obtain credit/debt in the market and if they do get they have to pay higher interest rates as investors are very cautioned about the economic condition in Europe. The credit problem in Europe is not impact only European companies but slowly but surely it will have a major impact on enterprises in other countries as that’s how the market works. If you can get higher interest in one place and you know other enterprises have the same kind of problems you as an investor will demand for higher interest rates as you view the risks are high no matter where you are. Most enterprises are still floating because of credit there are only a small number of enterprise who are alive with their own cash in the banks.
  2. Funding – From the news that I’ve read around 50-60% funding are funded by local funds (superannuation, retail deposits, etc) while the rest are from overseas investors. At the moments banks are fighting for retail deposits because superannuation funds are not doing well or need to put aside cash for redemption as the stock market have fallen quite substantially. The retail deposits market are not that big while the need for funding for loans are very big so to entice banks customer to deposit their money like it or not banks have to compete fiercely by upping their term deposits. My analysis is telling me that term deposits can rise between 7-7.5% before end of 2010. If the stock market is going to drop more than what they are currently are it could push the term deposits to around 7.75-8%.
  3. Stock Price – As we can see the stock market is doing well at all as a matter of fact it could go down more further than what they currently are, this will not be good for the bank’s stock price as this will make it harder for the banks to raise funds either through new issues or debt market. This will create pressure for the banks to make sure they earn good money on their margin by upping their lending rates (business, personal, home, etc loan), the different between that the banks paid for deposits and loan rate must be between  0.35-0.50% before they can comfortably earn money, but I’m sure stock owners wants more so they are looking for 0.75-1% earning from loans so I’m looking for the lending rates to go up quite a lot before 2010.

All in all this year and the coming years will be good years for savers, people like me who knows how to save and spend just enough for living, it’s about time that the banks rewards savers.

Is the market mad ?

This blog post has been written before on August 27, 2009 at 6:50 am but it was published not as a blog post but as part of the main page.

I’ve been observing the market for the last few weeks and one thing that I notice is that the market is “crazy”. Why crazy ? well for one thing stock prices (and index) have been moving up continously when most of the data that are coming still bad, nothing is positive. Most of the news that comes out are mostly better than previous months but it’s still bad compared to 2007-2008. I’m no economists but my logical thinking is telling me if things have not recovered how is that considered good ?. My gut feelings is telling me that something is cooking behind the scene, for some reason it’s being push either speculatively or some “invisible hand” is doing it’s job.

Today the GDP came out still -1.0%, still better as they said compared to the forecast. Bloody hell, it’s still minus ONE !!, how can that be good, and the jobless claim drops by 10,000 to 570,000. The figure still shows a lot of people are still unemployed, which is bad.

Technically most indicators like RSI and Momentum are showing a bearish divergence formation, which can mean only one thing and that is the prices have been extended too long it’s time for correction. My expection there will be 8-10% correction in the index.

We will see how it turns out !

Creating DVD Video in Ubuntu

I’ve been dabbling with Ubuntu at home for the last 3 months and I have never looked back to Windows again (except in my work). I’ve been given the task by the missus to create a DVD video for our youngest son as he is now 1 yr old and it’s time for him to hear nursery songs. With the help of Mr. Google I was able to create a home made DVD video with nursery ryhmes. Following are the steps to create the DVD in Ubuntu (Ubuntu 10.04 LTS – the Lucid Lynx)

1. Download YouTube.com video using youtube-dl (you can download from http://www.arrakis.es/~rggi3/youtube-dl/) and run it as follows

./youtube-dl “http:/youtube.com”

2. Copy the flv2avi script from this website (http://www.linux.com/archive/feed/56642) and run the script flv2avi.sh . The generated file will be the same as the .flv file except the extension will be .avi

3. Run DVD Styler and select all the .avi files, and create an .iso file.

4. Run the GnomeBaker application (or any other DVD burning tools). With GNomeBaker select Tools –> Burn DVD Image and burn the .iso image to the DVD.

Happy Life

Each one of us are born into this world with an exception gift and talent. We all are unique and each of us complement one another but the one thing that we are lacking no matter who we are is the capacity to make ourself happy. If somebody asked you this question – “Are you happy ?” you will instantly replied “Yes! I’m happy”, which is normal response we give to people when they are asked us about us. But, sometimes if you sit down and think about it are you really happy ? And your honest answer will be “Maybe”.


There is an old saying “If you want to make other people happy, you must make yourself happy”. Happiness and sadness is virulent it can affect people instantly without you being aware of it.

Social Experiment – Wake up one morning and tell yourself you want to have a positive thinking and you want to be happy. Give an objective to yourself by targeting to give good comments to your friends or colleague – comments such as “Good Job”, “Well Done”, “You look beautiful in that dress”, any positive comment you can give. Without you realising you already infected other people with all your positivity

If we compare our life with our parent’s or grandparents life you will see big difference, I’m not talking financial wise. Back during the olden days people don’t have too many things to worry about, they live a simple life and basically they just ‘lived’ their life. You don’t see or hear them trying to seek knowledge on how to become rich, how to make themselves happy or try to please other people. Now that we are in a more advanced society with all the innovation that’s happening why can’t we go back to basics and try to just ‘lived’ our life.

As time progresses and society becomes complex we should not make ourself complex, we should make ourself less complex and simple. No matter whether you a doctor, engineer, prime minister or whoever you maybe the key to making yourself happy is just be simple, it’s that easy.Lots of people will say that it’s easier said than done to live a simple life. Well of course nothing is easy if you make it hard but if you want to give 110% of your heart into it you can overcome the obstacles without you even realising it. You cannot undo what has been done but you can improve on what is coming in times to come. Changing your life and the way you live it is not simple and nobody will say it is simple, but if you take one step at a time you will reach the ultimate goal. Nobody can decide what you can or cannot do with your life it’s in your hand you are the driver. There is no certainty in life, nobody can predict what is going to happen in the future let alone predicting your future.

We should start by having this motto ‘Don’t worry, be happy!

Next Page »