It seems like the GeSHi Filter is the most popular Drupal 7.x module for syntax highlighting. To get it up and running, first install the dependent Libraries API (2.x-dev) and download the required GeSHi PHP Library (1.0.x), then install the GeSHi Filter module. As per the GeSHi Filter README, extract the GeSHi Library to /sites/all/modules/geshifilter and then enable the module via the Drupal admin interface. If the library isn't detected, try clearing the cache.
Once the GeSHi module is running, you have to enable the filter on your preferred text format (e.g. Filtered HTML). You do this on the Admin >> Configuration >> Text Formats page. I also had to put GeSHi at the bottom of the processing order to get it to work. If you’re using a WYSIWYG editor (like CKEditor) for creating content, make sure it’s not escaping special characters like ‘>’.
Once you get the module fully functional, you should be able to highlight a wide variety of languages, as illustrated in the following examples.
Java class example.
PHP example from MediaWiki’s LocalSettings.php config file.
Python list comprehension example.
MySQL create table example.
In theory, inline code snippets like
should also work.
EDIT: Since I migrated to Jekyll, the above code is actually highlighted using Pygments.