Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Feature Request: Adding Colors to Source Code

by davido (Archbishop)
on Mar 07, 2004 at 04:53 UTC ( #334578=note: print w/ replies, xml ) Need Help??


in reply to Feature Request: Adding Colors to Source Code

I don't know that I'm sold on the need. Syntax highlighting is cool, but as often as not I find that many editors prove the old adage that "Only perl can parse Perl" (ie, highlighting is occasionally goofed up by odd syntaxes).

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.

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.


Dave


Comment on Re: Feature Request: Adding Colors to Source Code
Re: Re: Feature Request: Adding Colors to Source Code
by Vautrin (Hermit) on Mar 07, 2004 at 20:35 UTC
    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.
      For instance, HTML doesn't have semicolons at the end of most of the lines ...

      There is a "view source" link on most of the pages on my web site. For CGIs, it shows you the perl source. The generated HTML might look something like this:

      <html>... <tt> use&nbsp;CGI::Carp&nbsp;qw&nbsp;(fatalsToBrowser); <br>use&nbsp;strict; <br>use&nbsp;warnings; <br>use&nbsp;Data::Dumper; <br> <br>use&nbsp;IO::Capture::Stdout; <br>use&nbsp;IO::Capture::Stderr; <br> <br>print&nbsp;"Content-type:&nbsp;text/html\n\n"; ...
      The view source program is, of course, just a CGI and so you can view its source too. But don't bother, it's awful code.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://334578]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-12-20 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (99 votes), past polls