http://www.perlmonks.org?node_id=334657


in reply to Re: Feature Request: Adding Colors to Source Code
in thread Feature Request: Adding Colors to Source Code

find that many editors prove the old adage that "Only perl can parse Perl" (ie, highlighting is occasionally goofed up by odd syntaxes).

I've rarely seen Emacs mess up on the syntax highlighting. Certainly, it's happened, but it's not really that common. Besides, if we changed the colors of the strings, and changed the colors of the keywords, how hard is it really? Not that hard at all.

Combine that with the fact that code tags are used for a lot more than just Perl code, and you end up with a difficult to implement problem.

I've pointed out in another post that Perl is very unique and structured. For instance, HTML doesn't have semicolons at the end of most of the lines, and #! /usr/bin/perl or use strict; use warnings; at the top of most (if not all) scripts are dead giveaways as to perl. Add to that a couple checks for variables that you're only going to see in Perl -- i.e. $_, @_, @ARGV, things that look like variables -- or variables with my before them, and it's really not that hard to identify Perl.

As far as readability, I don't really find syntax highlighting all that big of a deal anyway. If you write clean code, with proper indenting, sufficient whitespace, and clear idioms, you end up with something that is going to be legible with or without highlighting. If you want to write illegible code, we have a section for that too, and I have a feeling syntax highlighting won't help there either.

Unfortunately, this is a place where there are quite a people who don't write clean code. Granted, well structured code can be easy to read whether or not it's highlighted. However, what percentage of posts have that structure? Again, if I see a mess on the screen, my first instinct is to want to help out, but I really don't have the time to sort through code. Adding colored strings / keywords / variables / whatever would go a long way in helping to untangle the mess some people post.


Want to support the EFF and FSF by buying cool stuff? Click here.