Assume that the metric space $(X, d)$ is not compact then there exist a $f: X \to \Bbb R$ which is continuous but not bounded.
Compactness of $(M, d)$ in terms of continuous functions $f:M\to \mathbb R$