The Last Item Is Not Special: A Plea for the Line Number and the Trailing Comma
Every tool in the chain already agrees on one address: file and line. Compilers print it, stack traces carry it, grep returns it, diff hunks are cut by it, and git blame and review comments hang from it. That only works if one line carries one meaning. Two habits break it more than any missing tree diff does: formats that treat the last item as special, and tools that squeeze many lines into one. This is a plea to keep the line meaningful, and to treat the tree as a view you derive, not the unit everything is built on.
One Line, One Meaning
A file:line pair is a flat, content-agnostic address, the same kind of thing as a page number in a paged bytestream: a tool needs no idea what is on the line to point at it. Where books have pages, source code has lines. The difference is who cuts them. A printer cuts a page break, so it can land mid-sentence without harm, because nobody addresses a book by its second clause. An author cuts a line break, and tools treat it exactly like a page break: they blame it, diff it and point errors at it. A line only works as a page if the author cuts it somewhere meaningful. If You Can’t Diff It, It’s a Dead End Street made the case for git as the non-semantic index. This is the same argument for the formats that sit on top of it.
A tree path such as /Window/Grid/Button[2] is the chapter hierarchy leaking into the address. It shifts when a sibling is inserted, and every tool that wants it has to carry the format’s grammar. The difference shows at the worst moment. A half-typed file has lines and no tree, and a merge conflict leaves markers in the middle of a JSON or XML file where the parser stops. A line diff keeps working on both, because it never needed the file to be valid. A tree diff needs input it can parse, so it fails in the middle of the work.
The line address itself breaks in three ways. Minified JavaScript is one line, which is why source maps exist, to map positions back. Generated code with no mapping to its source has lines nobody wrote. And one long expression spread over ten lines gives an error that covers all ten.
The Last Item Is Not Special
A separator makes the last item special. In a comma-separated list every element but the final one carries a comma, so adding an item at the end changes two lines: the new one, and the previous line that gains a comma. git blame then credits that previous line to whoever added the comma instead of whoever wrote the item. A terminator avoids all of it. Every item ends the same way, so adding, removing or reordering one touches exactly one line.
JSON has separators and allows no trailing comma. JSON5 was made for hand editing: it drops the demand to quote every key, allows comments, and lets the last item carry a comma too. SQL has separators too, and Oracle rejects a trailing comma in a select list, which is why people write leading commas. That moves the special case to the first line, the one that rarely changes:
SELECT e.EmpNo
, e.EName
, d.DName
FROM Emp e
, Dept d
WHERE e.DeptNo = d.DeptNo
ORDER BY d.DName
, e.EName
DuckDB removed the special case instead. Its docs list trailing commas as friendly SQL, accepted in column and table lists and in list literals, and BigQuery accepts them too. Pascal-style separators have no fix beyond discipline.
Plenty of languages already pass. C, Java and Slint end statements with ;. Rust, Python and modern JavaScript allow the trailing comma, and Go requires it whenever the closing bracket sits on its own line. KDL and HCL use the line ending itself as the terminator.
The test is short: can you tell from one line, without knowing its neighbors, where something starts and ends? Terminators, trailing commas and stable line numbers pass it. Separators fail it, and so does JavaScript’s automatic semicolon insertion, where whether a newline ends a statement depends on the next line, and so does minified code. It is the O(1) boundary principle tested on the comma, and the same property UTF-8’s self-synchronization gives bytes, one level up and with no scan needed.
Markup That Keeps the Line
XAML adds a different break. Its binding expressions are strings in a second language, read by another part of the toolchain than your code, so there are two kinds of error in two places. Microsoft’s experimental Reactor drops that layer. It writes WinUI interfaces as typed factory methods and fluent modifiers in C#, and its README sells the result as “no XAML string-typing, no binding errors at runtime.” The UI becomes a C# file, addressed by the compiler’s own file and line. Its docs add that Reactor elements can’t be written in a XAML page, because there is no XAML loader for them, so the two don’t mix. Underneath, a reconciler still turns element records into a WinUI control tree, which is fine, since that sits below the waterline.
JSX looks like tags and is ordinary JavaScript underneath: the build turns the tags into plain calls and errors point back to the line you typed. The brace family, Slint, QML and Dioxus’s rsx!, tends to put one property on one line. XMLUI is XML and still respects the file, because its docs say there is no build step and the engine loads the .xmlui file you wrote.
Trees as a View
A structural diff is a good way to look at a change. It is a smart reader on top of a dumb wire, computed from the lines when someone asks, at the point of use. It is a poor thing to store, a poor thing to address by, and a poor thing for a tool to depend on exclusively. The tree can be derived from the lines at any time. Going the other way loses the comments, the order you chose and the layout you typed.
This post is part of the Gutenberg/Semantic series. Related: If You Can’t Diff It, It’s a Dead End Street on git as the non-semantic index, YAML, JSON, and the Config File That Fights Back on the O(1) boundary, and One DNS Lookup Per Book on units that carry their own boundary.
Sources: Friendly SQL, DuckDB documentation; Microsoft.UI.Reactor, README and docs; XMLUI documentation.