7

A few months back, a SuperUser account person had a comment conversation on an answer with me regarding the format bar options. In particular about the code sample/block option from the format bar using what was referred to as "antiquidated".

I asked the question because this account has modified other posts of mine in the past reformatting it using some of these methods entirely changing my answer layout, and I'm all for learning and keeping things simple.

It was also mentioned that the more modern three backticks method is more efficient for various reasons, and stated the four leading white spaces has storage overhead for answer content.

  • I reference quoted the entire chat conversation in the 'supporting resource' section below for further context.

Questions:

  1. Can this technical concern/reason expressed by this person regarding this matter be debunked by some backend storage technology which handles this concern?
  2. If this is 100% totally true, is it already on the radar to change that method to be the easy-to-find and use code block/sample option from the format bar?

Format bar code sample option enter image description here

White Space Code

Get-OldSchool whitespace

Three Backtick Code

Get-Modern 3backticks

enter image description here

Supporting Resource

  • How to delete all the emails in Outlook in all folders before a certain date?

    Please use correct markdown for monospaced code and code boxes – JW0914 May 31 at 11:21

    @JW0914 What to read about the format you used in particular? The markdown that uses the 4 backticks for example, is this part of the built in format per the SU posts that go over this because the tool SU provides to write a post does not give those sort of options unless I'm overlooking something. What should I read as a starting point to make that as easy as writing the answer? Do you know this per front end web coding HTML, etc. or did you read about these formatting options in a howto post? I like simple when it come to writing a post though so the simpler the better for me personally. – Vomit IT - Chunky Mess Style Jun 7 at 20:57

    @JW0914 And yes, if I'm overlooking something simple that is built in, I wouldn't be surprised either. Different web UI features and navigation gives me trouble sometimes not spotting something obvious. Happy to learn either way though. Thank you! – Vomit IT - Chunky Mess Style Jun 7 at 21:00

    Formatting options can be found in the formatting bar on questions/answers, directly above the content box, with the formatting bar's question icon expanding a help section. There is no markdown that uses four backticks - single backticks are used for monospaced code, whereas three backticks are for code boxes. Monospaced code markdown is important for a few reasons, as web translators don't translate it (a necessity) and its easier to notice and read, keeping commands on the same line & not line breaking them, which is imperative for clear understanding of where the command begins and ends – JW0914 Jun 7 at 22:30

    @JW0914 When I write an answer or a post, I typically use the options that are here: https://i.sstatic.net/ekMVX.png and I have not clicked the (?) there and then look over advanced help. While that detail is useful, I do not think the actual options from the bar provide all those level of formatting. For example the 3 backticks is not what you get when you click it to put the code block. You have to explicitly type the 3 backticks before and after you code block for that format and know that's what you are supposed to do. I'll play with it more when I get some time though. – Vomit IT - Chunky Mess Style Jun 8 at 13:27

    Screenshot linked to is the formatting bar. While the formatting bar's code link indents at four whitespaces on a new line, the help section shows three backticks under Code)_, I'm unsure why the formatting bar's code button is still using the antiquated four whitespaces (results in significantly more storage overhead for content when scaled to an answer site like StackExchange); either/or can be used, however backticks allow specifying the specific syntax directlyafter them (e.g. three backticks then bash, ini, xml, etc.), versus the inefficient way it must be done with four whitespaces – JW0914 Jun 8 at 17:31

4
  • Is this is more suited towards Meta Stack Exchange than Super User Meta, please migrate over. I figured I'd post here to start. Commented Sep 14, 2022 at 21:40
  • Related feature request on MSE: Make the post editor { } button use code fences instead of indent syntax
    – Andrew T.
    Commented Sep 16, 2022 at 2:47
  • @VomitIT-ChunkyMessStyle It's SE policy not to talk about suspensions while users are suspended; they can't respond, for one. Would you mind editing it out of the question?
    – wizzwizz4
    Commented Sep 22, 2022 at 13:09
  • @wizzwizz4 Actually I will remove that from the question. I thought about it more. There you go, it's done. I reread my question, and I now do not think it adds much other than part of the reason I opened the question. I deleted the other two comments explaining why I did not want to do that originally. Thank you! Commented Sep 22, 2022 at 14:47

3 Answers 3

6

If anyone wants to cut down on SE storage, just edit a few of my posts to remove the wordiness ;-) ...

the code sample/block option from the format bar using what was referred to as "antiquidated".

I wouldn't call it antiquated, but I do personally consider it "non-optimal", just because it's far easier to edit when using the backticks, IMHO. This is just my personal preference, and I do often wish that the SE editor would use backticks rather than indentation for code-blocks.

I would never edit an answer just to change it from four-space-indent to three-backticks, nor would I ask someone else to change their method. If I was making other edits to the post which were made easier by a backtick codeblock, then I would probably convert it. In other words, I'd only change it if it "got in my way."

this account has modified other posts of mine in the past reformatting it using some of these methods entirely chaging my answer layout

I guess I'm confused on that point. The end-result of either codeblock method should be identical. If other formatting changes were done, then the person hopefully thought that they were improvements in other aspects.

It was also mentioned that the more modern three backticks method is more effecient for various reasons, and stated the four leading white spaces has storage overhead for answer content. ... Can this technical concern/reason expressed by this person regarding this matter be debunked by some backend storage technology which handles this concern?

Well, maybe. I'm sure a SE staff could answer in detail, but SE is served gzip'd through (I believe) Nginx and Varnish, and both support retrieving the content from the backend in compressed form. I'm not an expert in this area, but I think it's very likely that the markdown is stored on the backend pre-gzip'd.

Let's consider either option:

  • If the posts are stored in compressed form on the backend, then four-spaces-indent codeblocks can actually be more efficient than backticks by a hair, at best.

    I ran two separate tests. In one, non-real-world example, 20 lines of four-space indented content compressed to 4-bytes smaller than the equivalent backticks.

    But, as I said, this was a very contrived example (twenty lines of echo one).

    To see what a real example would look like, I used your answer's "PowerShell Exchange On-Premise" code-block.

    In gzip form, both the backticks version and the indented version were exactly the same size -- 514 bytes.

  • If the posts are stored uncompressed, then obviously the backticks form will be more efficient, but by how much? Your answer's code-block was 848 bytes with backticks and 888 bytes with indents, a difference of around 5%. And that's just for the code-block. If you take the rest of the post, the difference is probably less than 1%.

    Is a 1% savings in storage costs worthwhile? Maybe, if you are storing data on the scale of SE. But in that case, they'll probably be going with server-side compression anyway, and getting bigger gains.

If this is 100% totally true, is it already on the radar to change that method to be the easy-to-find and use code block/sample option from the format bar?

Well, while I don't use it (since I'm a keyboard junky and I find the mouse movement to the formatting bar inefficient), I'd still love to see it changed just out of personal preference for the ease of editing backticks-code.

And for the same reason, I'd love to see images be inline, rather than with the [] reference at the bottom of the post.

But again, this is purely personal preference.

I think we've probably debunked the "100% totally true" part enough for it not to matter from that perspective.

Side-note formatting nitpick

In your question above, you use **bold** to format the "Format bar code sample option", "White Space Code", etc.

These are more semantically appropriate as headings (####, etc.). And yes, there's a good, technical reason -- screen reader software/accessibility. Not that Stack doesn't have semantic issues in their use of headings, but it's still better than using Bold, IMHO.

2
  • Actually, I did have time to read it again with thorough detail. I've accepted this as the answer as I think you went well above and beyond what I expected in an answer and this certainly does help clarify a lot of this for me. And also the bonus with the heading rather than bold format coding. I appreciate your answer @NotTheDr01ds.... Thank you very much for all this detail. Commented Sep 15, 2022 at 22:14
  • 6
    Even if backticks have the advantage of using less storage space, making edits just to change them is pointless - because then there are two versions of the post to be stored, rather than once slightly unoptimal version.
    – gronostaj
    Commented Sep 16, 2022 at 7:39
7

Neither of these styles is incorrect, old, deprecated etc. Stack Exchange is using Commonmark which allows both styles: indented, fenced.

Actually, if anything, it's the fenced style that is controversial. I can't find it now, but some opponents of Commonmark have expressed their dislike for that style because it's not as elegant and obvious in plaintext form.

Personally I agree that indented code blocks look better in plaintext, but they are impractical. To indent a larger code block I must use the formatting toolbar or a text editor. Or I can just do ``` Ctrl+V ```.

2

The triple-backtick style has one notable advantage: it allows enabling syntax highlighting quickly and easily, per code block.

#!/bin/sh

if [ 1 -eq 1 ]; then
  echo Hello World
fi

Like this:

```bash
#!/bin/sh

if [ 1 -eq 1 ]; then
  echo Hello World
fi
```

In my opinion, this can greatly enhance the readability of code examples, especially with convoluted languages like HTML.

However, not all languages are available. An incorrect language should not be used, because the result could be confusing (like, say, using C highlighting for Java code). Check this meta thread for details on how code highlighting works.

You must log in to answer this question.

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