David was educated at Aberdeen Grammar School under Dr. James Melvin and at Marischal College, University of Aberdeen. Intending to enter the Church, he proceeded to Edinburgh University, where he studied theology under Dr. Thomas Chalmers, with whom he remained friendly until the latter's death in 1847. However, abandoning his aspirations to the ministry, be returned to Aberdeen to undertake the editorship of the "Banner", a weekly paper devoted to the advocacy of Free Kirk principles. After two years he resigned this post and went back to Edinburgh to pursue a purely literary career. There he wrote a great deal, contributing to "Fraser's Magazine", "Dublin University Magazine" (in which appeared his essays on Thomas Chatterton) and other periodicals. In 1847 he went to London, where he found a wider scope for his energy and knowledge.