Skip to content

Type Ceremony

What fraction of your code is boilerplate rather than logic?

Ceremony ratio = ceremony lines / total lines. Ceremony lines are imports, package declarations, main wrappers, lone closing braces, and type-only annotation lines. Lower means more of your code does actual work.

Ceremony by Language

Averaged across 7 benchmark problems.

Language Ceremony Ratio Ceremony Lines Total Lines
Clojure008
Erlang0012
Python0.1051.714.6
Elixir0.1472.617.4
Zig0.1957.139.9
Objective-C0.214314
Haskell0.221521.9
JavaScript0.2223.115.7
Ruby0.2243.114.3
TypeScript0.2293.415.9
Swift0.27622.3
Kotlin0.2845.919.7
Go0.318.126.6
Milo0.3138.326.9
Rust0.3177.122.6
C0.32611.739.7
C++0.3489.627.9
Java0.39710.326.6
C#0.438716

What drives the differences?

Python (10%) — no imports for builtins, no main wrapper, no braces. Almost every line is logic.

Java (40%) — package declarations, class wrappers, public static void main, import statements, closing braces. Nearly half the code is scaffolding.

Rust (32%) vs Zig (20%) — Rust's use imports, fn main(), and match arm braces add up. Zig's @import is terser and comptime reduces boilerplate.

Go (31%)package main, import, func main(), explicit if err != nil blocks. Error handling is ceremony by design — Go chose explicitness over conciseness.

TypeScript (23%) vs JavaScript (22%) — nearly identical. Type annotations don't count as ceremony since they carry semantic weight. The difference is mainly import style.

What counts as ceremony?

Lines classified as ceremony:

  • Imports/includesimport, require, use, #include
  • Package/module declarationspackage main, module X
  • Entry point wrapperspublic static void main, fn main()
  • Lone closing delimiters}, end, )
  • Type-only lines — lines that exist solely for type annotations with no logic

Lines NOT counted as ceremony:

  • Function signatures (they define behavior)
  • Variable declarations with initialization
  • Type annotations inline with logic
  • Comments
The formal basis

Ore et al. (ASE 2018) coined "Type Annotation Burden" and found: developers average 136 seconds per correct annotation and get it right only 51% of the time.

Annotations are expensive. Our ceremony metric captures the broader category — all structural lines that exist for the compiler rather than for expressing intent.