He was born at Kinnaird, Perthshire and brought up by his grandfather from the age of three after his parents and younger brother emigrated to the United States. Illiterate until 13, he showed no early signs of linguistic ability, but despite this late start, at age 17 he was appointed schoolmaster of the village of Stralock.
Shortly after this he attended Kirkmichael school followed by Perth Grammar School and the University of St. Andrews, gaining a Masters degree from the latter.
In 1823 he took a post at Calcutta Academy, but because of poor health he was forced to return to Europe in 1826. In 1837 he became Professor of Oriental Languages at King's College London and stayed at this post until his retirement in 1861. During his time at King's College London he also worked at the British Museum, cataloguing the collection of Persian manuscripts.
During his life he wrote a number of books, and it is for these which he is most remembered. He had a hand in translating or editing a number of books in Urdu, Persian and Arabic, including a translation of Mir Amman's Urdu Bagh o Bahar, or Tales of the Four Darweshes, (which is itself a translation from the Persian of Amir Khusro), and of the Persian Adventures of Hatim Tai.