This survey article discusses the pragmatist tradition in twentieth century philosophy of science. Pragmatism, originating with Charles Peirce's writings on the pragmatic maxim in the 1870s, is a background both for scientific realism and, via the views of William James and John Dewey, for the relativist and/or constructivist forms of neopragmatism that have often been seen as challenging the very ideas of scientific rationality and objectivity. The paper shows how the issue of realism arises in pragmatist philosophy of science and how some pragmatists, classical and modern, have attempted to deal with it. Various dimensions of the realism dispute are thus discussed, especially realism as contrasted to instrumentalism and realism as contrasted to relativism/constructivism. It is argued that the pragmatist tradition cannot avoid these tensions but is largely constituted by them.