SMS: The mathematical theory of coding