4

Whilst browsing answers to my question about randomness, which has largely gathered software algorithms and code examples, I noticed that not one of the code blocks has syntax highlighting. I couldn't find prettify in the page source for the main site, so I assume that we haven't got it. (Regardless, a is the proper method for requesting new languages for syntax highlighting as per the mSE FAQ post.)

Do we want syntax highlighting on code blocks? If so, what languages do we want to support?

6
  • 1
    I'm not seeing BASIC, COBOL, FORTRAN, or any dialect of assembly language on the list of supported languages.
    – Mark
    Oct 4 '17 at 19:24
  • @Mark If you like, add them. You'll need a Google account for that, though. :-(
    – wizzwizz4 Mod
    Oct 4 '17 at 19:28
  • Seeing as I have disabled syntax highlighting on every system that I have ever used as I find it annoyingly distracting, I'm agnostic on this one.
    – Chenmunka Mod
    Oct 5 '17 at 8:36
  • I'm not realy in favour. It distracts from the real content. I don't know anyone who would prefer a novel where punktuation marks are highlighed. I's maybe helpful for beginners - much like letter shapes on the wall for first graders learning to spell. But even then it gets useless with languages that relay on libraries (like C) or macros (like Asm) as these can only be highlighted with knowledge about the librar. And it gets total useless on many other languages not following a simple graph.
    – Raffzahn
    Oct 5 '17 at 11:39
  • @Raffzahn Do you want to post that as an answer?
    – wizzwizz4 Mod
    Oct 5 '17 at 15:29
  • @wizzwizz4 It's an opinion, not realy an answer, but either way works for me.
    – Raffzahn
    Oct 5 '17 at 15:36
3

I'm not realy in favour for any kind of highlighting.

a) It distracts from the real content. I don't know anyone who would prefer a novel where punktuation marks are highlighed. I's maybe helpful for beginners - much like letter shapes on the wall for first graders learning to spell.

b) It gets less useful with languages that relay on libraries (like C) or macros (like Asm) as these can only be highlighted with knowledge about the libraries. Just highlighting the standard parts doesn't make much sense.

c) thinking of assembler, what good would be a highlighting iff all in column 8 to 15 gets attributed?

d) Or BASIC. Correct highlighting for all the MS-dialects will be a gigantic task - not to mention more interesting BASIC variations out there.

e) It gets totaly useless other languages that so not following a simple graph.

f) lets over all of this not forget, that RC is not about pages of inserted source listings. I do not expect (or want at all) see this.

To me a) already would qualfy to cancel this.

Last but not least, lets think about the meaning of this site - answering questions - so in an answer automated highlighting of some standard features of a language won't do any good, as this is (usually) not the point an answer is about. So the answerer needs to put up his own markers anway to point out the important pats - which in turn will fade against all the other blinkenlights, making it harder to understand what the answer is about.

2
  • 1
    "I don't know anyone who would prefer a novel where punktuation marks are highlighed" -- speaking as an amateur novelist who also is developing a word processor application that includes syntax highlighting for English, I don't think this is as strange as it sounds. Syntax highlighting makes it easy to distinguish the different parts of a language at a glance. Sure, you don't need it, but it's a very useful tool for skim reading.
    – Jules
    Oct 18 '17 at 23:37
  • @Jules LOL. So, you're writing your novels in German then? It's famous for highlighting nouns with uppercase letters to speed up reading, isn't it?
    – Raffzahn
    Oct 19 '17 at 5:55
3

I am in favour of syntax highlighting.

  • For many people, syntax highlighting makes code easier to read. Syntax highlighting:
    • makes comments a different colour so that they can be more easily distinguished from the code at a glance;
    • allows readers not familiar with the programming language to more easily follow the language (something common on a site where old and therefore potentially obscure programming languages are on-topic); and
    • marks the HTML with metadata stating which programming language the code block is and providing lexical analysis which could be used e.g. by screen readers to read code in a more reasonable way (e.g. strings, comments, keywords etc. could be read out phonetically and other things could be read out character by character, depending on whether it makes sense for the programming language).
  • Syntax highlighting works well on Stack Overflow, for example with the C tag.
  • Syntax highlighting is language-specific - it's tailored for specific languages.
    • Languages that follow completely different syntax rules (e.g. C-like, BASIC-like) are treated separately. In fact, all languages are treated separately if they have even slightly different syntax (e.g. C v.s. C++).
    • Languages that do not conform to a simple graph can still be highlighted - if they can be processed by a compiler or interpreter then they can be highlighted by custom JavaScript.
  • Syntax-highlighting would be opt-in for authors as they would have to tell the syntax highlighter which language the code is in.
    • On questions with specific language tags (like ), syntax highlighting would be enabled by default - this could be changed or disabled by a HTML comment above the code block or once for every code block in the answer.
    • If syntax highlighting does not make sense, it can be disabled or not be enabled on a case-by-case basis by the author.
  • Adding syntax highlighting would not change the scope of this site.
1
  • Agreed. I think to be useful here, we'd need to make a particular effort to increase the coverage of older and obsolete languages, but I'm sure that this is an effort that everyone can benefit from. And I think Raffzahn's point (a) is actually an argument in favour -- syntax highlighting makes it less effort to read code, so makes it easier to skim and therefore less likely to distract from the real content of a question or answer. I think as long as programming questions are on topic here, syntax highlighting should be enabled.
    – Jules
    Oct 18 '17 at 23:41
0

I know I'm late to the party, but...

Syntax highlighting is mainly a thing for code.

I don't see much code on Retrocomputing SE. Maybe the occasional assembly listing or piece of sample code illustrating a technique, but code is hardly what the site is primarily about. Those code snippets also are rarely long, and the audience isn't necessarily programmers.

Also, as already pointed out, assembler in particular is difficult to syntax highlight without intimate knowledge of the architecture and possibly surrounding code. At least, every architecture uses its own mnenomics for opcodes; LDA is a valid mnenomic in 6502 assembler, for example, but not on the 8086, so should it be highlighted or not? What about 8085, 8080, 68000, ...?

Bottom line, I don't think having syntax highlighting on Retrocomputing would add any significant value.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .