The aim of this chapter is to investigate the line from the 19th century, through Frege's works, to the appearance of the principle of compositionality in modern sciences. It is shown that contextuality and compositionality were discussed at the beginnings of the 19th century, but that contextuality was favoured. Also for Frege contextuality was the basic principle and he always obeyed it. Although he argued that within a given sentence, one may distinguish a compositional structure, he would never accept compositionality as we know it. Carnap was the first to give a formulation of the compositionality principle. In logic, natural language semantics, and computer science, 'compositionality' arose independently, and is a generally accepted method, but when a phenomenon is studied that has a strong influence from context, non-compositional methods are used without hesitation. The wide support for compositionality turns out to be for practical reasons, not for principled ones.