Imparts a self--contained development of the algebraic theory of Kac--Moody algebras, their representations and close relatives----the Virasoro and Heisenberg algebras. Focuses on developing the theory of triangular decompositions and part of the Kac--Moody theory not specific to the affine case.