The success of a foundation design for structures is to precisely estimate the bearing capacity of underlying soils or rocks. To avoid the elaborate in-situ experimental methods, several approaches presented by various researchers for the estimation of the bearing capacity factor. Despite this fact, there still exists a serious need to develop more robust predictive models. The aim of this paper is to propose a novel formulation for the ultimate bearing capacity of shallow foundations resting on/in rock masses, using a powerful evolutionary computational technique, namely linear genetic programming. Thus, a comprehensive set of data is collected to develop the model. In order to evaluate the validity of the obtained model, several analyses are conducted and compared with those provided by other researchers. Consequently, the results clearly demonstrate the proposed model accurately characterize the bearing capacity factor and reach a notably better prediction performance than the traditional models.