liveBook · Manning

Code example

As explained in Writing for Developers: Blogs that get read

A fragment or sample of source code presented to illustrate a programming technique or system behavior.

A code example earns its place by showing how something works, why an improvement matters, or why an optimization is necessary. Treat it as evidence, not decoration. section 5.4.6

Before publishing, run each example through this checklist:

  • Share only code you have permission to publish, especially when the project is closed source. section 5.4.6
  • Check production code carefully and ask another person to review it for mistakes. section 5.4.6
  • Make invented code realistic, secure, syntactically correct, and compilable; link to a playground when useful. section 5.4.6
  • Cut irrelevant details from non-runnable excerpts, using ellipses to mark omissions. section 5.4.6
  • Add enough surrounding technical detail—exact technologies, steps, benchmarks, or repository links—for readers to test your claims. section 8.5.2

Contrast makes a rewrite concrete

A rewrite article can show an awkward Rust snippet beside its clearer Zig counterpart. The contrast lets readers judge readability directly, while practical migration details help them decide whether to attempt their own rewrite. section 9.3.1 section 9.4.2

For presentation slides, keep excerpts readable: split or redact nonessential code rather than shrinking the type until nobody can follow it. section 16.4.3

How Writing for Developers: Blogs that get read covers it

How deep it goes
Specifies selection, permission, review, realism, compilation, concision, and presentation constraints rather than teaching programming language internals.
Examples
Uses Rust and Zig comparisons, old-and-new rewrite samples, language playground snippets, and readable conference-slide excerpts.
What it assumes
Assumes enough technical context to interpret code, while emphasizing that examples should carry explanatory detail for readers who need to catch up.
What you can do after
Apply it by selecting, checking, trimming, and presenting code that supports a technical claim without misleading readers.
How it connects
Connects code examples with technical blog posts, bug hunting, software rewrites, documentation, benchmarks, and conference talks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Writing for Developers: Blogs that get read. The section links point to the parts of the book it draws on.