How to properly insert code in posts?

If I want to insert a code sample into a post, I would assume I would use the “Preformatted text” option. What’s strange about that is that this inserts two backticks along with the replaceable text. When I first saw that, I assumed that the posting software would use the wrapping backticks to detect that it should do something special with that. In practice, however, it doesn’t seem like it does anything with it. When I view the posting, it just has the code I inserted, surrounded by the backticks.

If you use single backticks it will create inline formatting like this.

If you create a separate paragraph

indented with four spaces
you will get preformatted code blocks like this

Those are the only two I’ve been using.

Use triple ticks for blocks.