Honestly, I don't like code fences. New users to the site seem to have problems using them correctly, and they create unnecessary work to fix.
90% of the time that I'm on SO, I'm sitting in the new question queue looking for interesting questions and questions that need fixing up. I've noticed that since code fences started being recommended in the side panel when asking a question, new users have been trying, and failing to use them correctly.
Within a span of a few minutes, these questions were posted: 1 and 2 (+10k. Was deleted as I was posting this). I see many more than this. I could dig through my edit history if more examples are needed.
Why don't I like them? They're far too easy to mess up:
People use the wrong quotes, which prevents codes fences from being recognized.
People forget to close the fence, so any text after the code gets burried inside the code. I've seen multiple times where it seemed like the OP never asked a question, when in reality their question text was hidden at the bottom of code in a scroll box.
The language tagging feature seems unnecessary, and is just another thing that we're expecting new users to get right. The tags on the question already (fairly accurately) pick the formatting to use. In an edge case where it picks the wrong language, a
<-- lang
element can be added, or a code fence could be used in those rare cases.If a new user messes up using a fence, it's more work to fix than if they did no formatting at all. If they mess up a fence in one of the ways above, I need to remove their erroneous formatting, then apply a fix.
What I'd like changed:
Add mentions of the
{}
formatting button and how to use it (highlight code, click{}
or ctrl+k; easy). Make indent formatting the primary suggestion at the top of the help panel.Make suggestions of code fences less prominent. Don't make them the main suggestion.
Mention that fact that adding tags effects highlighting (although this is minor. I do think it falls under "formatting" though). The current panel says "add language identifier to highlight code", which makes it seem like that's how you add highlighting, even though there are other ways.
While I was writing this, I was thinking entirely about "non-guided" asking mode. I just checked the wizard however, and it gives the same advice when entering code. I think both areas should be changed.
{}
is more straightforward on mobile than needing to navigate to the backticks (2 extra clicks). It isn't major in either case, but minor things multiplied start to add up. – Carcigenicate Aug 6 '19 at 18:30'''
would be a more expedient solution? – Jon Ericson Aug 6 '19 at 18:35