In reply to..
Spolsky: How do they know, how do they even know what language you're writing in?
It doesn't. The highlighter is very dumb, but manages to gets away with it because most programming languages are so similar. Nearly everything uses syntax close-enough to..
AFunction("a string")
1 + 4 # <- numbers
# /\ a comment
// also a comment..
..that most stuff highlights properly. The above isn't an actuall programming language, but it highlights perfectly.
There are exceptions, for example, it can sometimes treat a /
as the start of a regex (as in Perl/Ruby). when it is not:
this [^\s>/] # is highlighted as a regex, not a comment
..but these are fairly rare, and it does a good job of working out most stuff, like..
/*
this is a multi-line comment
"with a string" =~ /and a regex/
*/
but =~ /this is a regex with a [/*] multiline comment
markers in it! */