Dmitry Chestnykh on Syntax Highlighting

Silly post. Just had to share when I ran across this.
https://twitter.com/dchest/status/504645401119842304
LOL.
I love those meaningless images with multiple panels that compare several languages with several real life things. C++ is usually the swiss army knife.
...and C++ syntax highlighting is usually like watching an episode of Dora the Explorer.
As someone idly developing a syntax highlighter for C++, I can assert that this is accurate.

-Albatross
I don't understand the Dora comparison?

@TheRabbitologist: the Dora comparison is accurate or the twitter post is accurate?
I mostly meant the twitter post, but from what little I've been shown of Dora, I suppose that's accurate too. Colorful and pretends to be informative, but it usually ends up silly and without much substance.

-Albatross
Dora is a good show, age appropriate, but it is very repeatitive, with loud colors and... have you ever noticed that everyone on the show is shouting all the time?

/Dora: I'LL KEEP IT IN MY BACKPACK!
/Boots: YAY, BACKPACK!
/Backpack: YUM, YUM YUM YUM YUM YUM YUM YUM! DELICIOSO!

Google "syntax highlighting" and it's kind of the same thing.
@LB http://bjorn.tipling.com/if-programming-languages-were-weapons

@Duoas after a quick google image search I agree that most of the highlighting there just makes everything unreadable, but I think if you manage to set it up correctly, it can make it much easier to read. For example, I've got mine set up like this: http://postimg.org/image/48j7qu04n/ What's your opinion on a set up like that?
I just use the default color scheme of Visual Studio and Notepad++ - it's too much effort to not only pick new colors but also learn said new colors.

Also, maybe it's because I learned C++ first, but a lot of people seem to have issues with C++ that I've never had myself...
Last edited on
@shadowmouse: change green to light gray and make blue a sightly lighter shade, and it will almost be my night scheme.
@LB I tend to just pick one colour scheme where I pick basically every colour carefully and then just use that one, because then I learn those colours and get very used to them. I also learnt C++ first and then started to go into other languages which I found much harder which is why I'm often confused when people say that C++ is so much harder to learn that most languages. It's also why I disapprove of the view that secondary school students must be taught Python as C++ is too difficult as I learnt C++ when I was 10, but Duoas made it pretty clear that my opinions are invalid when it comes to teaching (being a student means I can't possibly understand teaching apparently) and I can't be bothered to argue at the moment.

@MiiNiPaa you mean like this? http://postimg.org/image/fmbt1kfzn/
Last edited on
Almost: http://puu.sh/jxoUr/6747b2b0c3.png
(Code is part of "add another problem" or "try to solve each text parsing problem on this site with regexes" self-imposed challendge)
I like that, I might use it over my matrix theme, not sure. http://postimg.org/image/4snmmh8pr/
Code is part of my A level course work which is a graph drawer that can interpret equations and convert them into a parse tree that can be run to produce a result for any given parameters. Is there any way to export these themes so people could easily share their favourite ones?
Last edited on
Alas, I cannot play right this moment, but if there's something online where you can paste a theme and see SH'd code that would be great.
From what I've found, it's possible to export your codeblocks themes with cb_share_config, but I think if you import them then you overwrite the ones you already had. Probably best to just post examples using as many of the different colours in your theme as possible.
That tweet would have been more impressive if he'd actually used a picture that was originally black and white, rather than greyscaling an image that is already iconic as a colour one.

Having recently rewatched the first two Terminator films, one of the things that impressed me was Cameron's use of lighting and colour palettes. Stills from the film look much better in the original colour than when turned into greyscale, which kinda undermines Chestnykh's point.

Um... am I overthinking this?
Yes.


:O)
Alright, here's something quick to play with, complete with a simple theme I like.
You can see it in action by simply cutting and pasting to http://editor.livegap.com/

syntax.html
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <style>

.background   { background-color: #FFF; }
.highlighted  { background-color: #DDD; }
.plain        { }
.comment      { color: #07A; }
.preprocessor { color: #07A; }
.keyword      { color: #070; font-weight: bold; }
.string       { color: #707; }
.literal      { color: #707; }
.typename     { color: #07A; font-weight: bold; }
.function     { }
.variable     { }
.namespace    { }
.cursor       { background-color: #7A0; }
.border       { background-color: #DDD; color: black; border-color: #DDD; }
pre           { font-family: Consolas, "Courier 10 Pitch", "Courier New", Consolas, Courier, monospace; }

    </style>
  </head>
  <body class="background" style="padding:0;margin:20px;font-size:larger">
  <center><div style="margin:0;padding:0;display:inline-block;text-align:left">
  <div class="border" style="position:relative;border-width:2px;border-style:solid;border-radius:10px;display:inline-block;padding:0 0 0 1.5em;margin:0">
  <div style="position:absolute;color:black;left:.25em;top:-.9em;padding:.5em 0"><pre> 1<br> 2</br> 3<br> 4<br> 5<br> 6<br> 7<br> 8<br> 9<br>10<br>11<br>12<br>13</pre></div>
  <pre class="plain background" style="padding:.5em 0; margin:0; border-radius:0 10px 10px 0"> <span class="comment">// hello.cpp</span>
 <span class="preprocessor">#include &lt;iostream&gt;</span>
 <span class="keyword">using namespace</span> <span class="namespace">std</span>;
 
 <span class="typename">int</span> <span class="function">main</span>( <span class="typename">int</span> <span class="variable">argc</span>, <span class="typename">char**</span> <span class="variable">argv</span> )
 {
   <span class="keyword">if</span> (<span class="variable">argv</span> == <span class="literal">1</span>)
     <span class="namespace">std</span>::<span class="variable">cout</span> &lt;&lt; <span class="string">"Hello world!\n"</span>;
   <span class="keyword">else</span>
     <span class="keyword">for</span> (<span class="typename">int</span> <span class="variable">n</span> = <span class="literal">1</span>; <span class="variable">n</span> &lt; <span class="variable">argc</span>; <span class="variable">n</span>++)
       <span class="namespace">std</span>::<span class="variable">cout</span> &lt;&lt; <span class="string">"Hello "</span> &lt;&lt; <span class="variable">argv</span>[<span class="variable">n</span>] &lt;&lt; <span class="string">"!\n"</span>;
<span class="highlighted">   <span class="keyword">return</span> <span class="literal">0</span>;<span class="cursor" style="display:inline-block">&nbsp;</span>                                     </span>
 }</pre></div></div></center></body>
</html>

The top part there, in the <style>, is what is important.

I like the block cursor, but if you like the vertical pipe, here's that:
.cursor       { border-left: 1px solid black; }

Well, post your styles!
@Duoas: most people use https://jsfiddle.net/ or http://codepen.io/

Here's a side-by-side screenshot of Notepad++ and Visual Studio 2015 both opened to a file I didn't write:
https://i.imgur.com/e1twKQl.png
Last edited on
Topic archived. No new replies allowed.