Flymake is a minor editing mode for Emacs that performs on-the-fly syntax checks on the contents of your current buffer as you edit it, highlighting errors and warnings against the lines they occur on.
Flymake currently has in-built support for C/C++, Java, XML, Perl, PHP and Tex, there are also plugins available for Python and Ruby.
Some useful places to get started:
Flymake mode has been bundled with Emacs since v23, prior to that you needed to manually install it.