In one of our latest projects at work, we need to calculate two world coordinates. Instead of going into details about how the calculations is made, I will just refer to this page. This explains all details of math involved in getting distances and/or bearings from lat/long pairs.
I have implemented this calculation in several languages in the last couple of months - both for work, but also for learning details about a language through implementing a known algorithm in it.
Here is a simple nodejs module extracted from the javascript code on that page. The module has one public method called getDistance.
My changes are released licensed under the WTFPL
