View Poll Results: Add default colouring to posted code?

Voters
24. You may not vote on this poll
  • Yes!

    18 75.00%
  • No!

    6 25.00%

Thread: Proposal: Code colouring

  1. #1
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Proposal: Code colouring

    Hey y'all, I'd like to make a proposal for the cboard.

    Let me prefix this by saying that PHP code colouring looks terrible for C/C++, and C/C++ code should not be posted in PHP tags.


    I think we should add a board feature, a paramater for code tags which uses something like this to colour code. Syntax highlighting is standard in editors and we're all used to seeing it. Having looked at recent posts by dwks, it's clear to me that this would make it easier to read posted code, and consequently help others.

    I propose something like:
    [code highlight="off"] [/code]

    That way people who really don't want to use it don't have to. It should default to "on" so that omitting the highlight parameter defaults to highlighted code.


    As a second suggestion, all ad revenue generated from pages with highlighted code should have royalties to dwks, and a modest 87% of that to me as a finders fee

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Great idea, but I'll take 95%, thanks.

    If you wanted to add code colouring to this board, I would strongly recommend GeSHi. It's written in PHP, like the board, and it supports dozens of languages. It's a lot slower than codeform, but hey.

    I don't think code should be coloured by default. Why? Because then you can't colour code specially to highlight it, like this:
    Code:
    int main() {
        gets(s);
        puts(s);
    }
    I think code should only be coloured for some code segments, like examples such as this: http://cboard.cprogramming.com/showp...96&postcount=9

    But I really like code colouring. So I think it should be enabled, but maybe not by default. Or at least have a way to turn it off.

    So I'm voting Yes, but what I really mean is, enable it but not by default.

    [edit] I think this would be a good syntax:
    Code:
    [code=c] [/code]
    [code=c++] [/code]
    That way, it's not enabled by default. [/edit]

    [edit=2] Never mind, Geshi takes rather a long time to execute. Highlighting codeform with itself on a 400MHz computer takes less than 700 milliseconds, but takes nearly 11 seconds with Geshi (and I'm sure that server is a lot faster than 400 MHz!):
    0.161/10.601/0.004 seconds (language loading/parsing/cleanup)
    You could always take matters into your own hands and use codeform! [/edit]

    [edit=3] Do you think all Canadians like coloured code? :P [/edit]
    Last edited by dwks; 04-13-2007 at 01:41 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    yeah, I agree there are a few situations when you would want it disabled. I just figured that if it was disabled by default most people/noobs won't use it (because they don't realize it's there).

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Well, here's what I think. Make the "code tag" buttons use
    Code:
    [code=c++][/code]
    by default. Anyone who actually types "[code]" probably knows to use code tags.

    Or the default could be c++ and you have to use [code=] or =none to turn it off, like you suggested.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Code coloring is useless -- on a forum. Being able to highlight pieces of code as dwks described is useful.
    There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Rashakil Fol:

    Obviously you have never seen the complex problems that are posted from time to time on this board. Also people like Bubba like to share their code as examples(lessons) and it would be a lot nicer to see it in colored form.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    ...or as lessons in what NOT to do.

    I like the idea.

  8. #8
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by Rashakil Fol View Post
    Code coloring is useless -- on a forum. Being able to highlight pieces of code as dwks described is useful.
    when people post significant sized portions of code, even like this, for example, it's not useless in my opinion.

  9. #9
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I say yes, definitely not useless, it makes code a lot easier to read, especially when a noobie post unformatted code.
    Last edited by Queatrix; 04-13-2007 at 10:03 PM.

  10. #10
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    You will be very surpised, I think, how noobs who don't format their code will abuse this feature. Ugly code will still look like ........ except now it's colored ......... Monochrome 4 lyfe.

  11. #11
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    I've had a different take on this lately. But it has received more comment here now *chirp* *chirp* than anywhere else yet.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  12. #12
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    That's a bit different though isn't it - if code tags were smart enough to beautify code, then I wouldn't have any objections. But the posts there only managed to convince me that seems difficult unless we get to work. dwk seems the closest to achieving the goal! He will lead us!

  13. #13
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I'm all for this as long as we don't go psycho on the colours (like Python's IDLE thing - you don't have to assign a colour to everything).
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    "I hate your colour scheme" along with "your indentation sucks" will be an additional refrain.

    If I want your code in pretty colours, then I'm perfectly capable of copy/pasting your monochrome code into my IDE with MY preferred colour scheme.

    Besides, there seem to be several "colouring in" tools out there which do a fine job of actually corrupting the code.

    Used sparingly, colour is very useful for highlighting specific points in the code, but blanket colouring in like some cheap IDE - no thanks.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  15. #15
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    I think it's a good idea, and voted to echo that, but perhaps defaulting it to colouring is not the greatest idea. Just like quoting doesn't default to pointing to a user unless you explicated tell it to.

    >> "I hate your colour scheme" along with "your indentation sucks" will be an additional refrain.
    You talking about a beautifier that indents your code too? The thing is that people could give out about your colour scheme and your indentation anyway if you were using any "colouring in" tools which don't corrupt the code.

    >> If I want your code in pretty colours, then I'm perfectly capable of copy/pasting your monochrome code into my IDE with MY preferred colour scheme.
    Or you could just look at it here with the your preferred colour scheme Perhaps user-programmable colours may be a neat idea so you don't have to go to all that trouble, Salem A user could fill out what they want the colours to look like, in their control panel, and then if code has been posted with a special identifier, such as [I][code type=c#][/I] ... [/code], when you upload a page it will load your defaults so you see it as you wish.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  4. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM