Ari Lerner — Writing
Ari Lerner writes code and mathematics, builds hardware and systems, and teaches across secure AI infrastructure, systems software, and new computing models.
- Website
- ari.io · all feeds from this site
- Feed URL
https://ari.io/rss.xml
Read it in your FeedListing reader
Or add to: Feedly Inoreader Raw feed
Latest posts
-
Verify It by Running It Backwards
The verifier is 122 lines long and five of them are re-exports. Everything else lives in the trace you hand to somebody else.
-
I Deleted the Code That Worked
A refactor spec of ours said the raw-packet network path had been deleted. It was still in the tree, so we deleted it for real and took 41,000 lines with it.
-
Widen Before You Multiply
My square-root search returned 1073741823 for x = i32::MAX. The right answer is 46340.
-
Never Build the Number
I folded ten nines into an i32 and the release build handed back 1410065407 without complaining.
-
The Stack That Refused to Pop
An empty stack, a pop that returns None, and one comparison that catches both an empty stack and a mismatched bracket.
-
Allocating Once
The merge knew its output length before it started. Without one line, it reallocated nine times on the way to a thousand elements.
-
In Place, and the Borrow Checker Agreed
I wrote the version with the indices backwards on purpose, and the borrow checker had nothing to say about it.
-
ASCII Is Not a Vowel Set
My vowel counter returns 1 for café, because to_ascii_lowercase folds only ASCII letters and the method name is the only place that assumption shows up.
-
The Overflow Guard Is Not Defensive
The overflow guard in my reverse-integer solution never fired once across 3,000,169 inputs, so in-range inputs that overflow panic in debug and return wrong answers in release.
-
The Swap That Panicked
My crate’s arithmetic swap overflows on i32::MAX and returns the right answer anyway, and at -O the optimizer collapses all three swap implementations into the same three instructions.
-
The Rounding That Did Not Round
My celsius-to-fahrenheit solution multiplies by 100 and divides by 100, which does not round anything, and the test passes only because 98.60 and the computed value share the same bits.
-
The One Where Rust Does Not Matter
The leap-year solution is one boolean expression with no allocation and no panic. After running it on negative years, I could not find a Rust-specific decision anywhere in it.
-
Two Is Prime Because of One Line
I deleted one guard clause from my prime checker and is_prime(2) started returning false. The test suite stayed green the whole time.
-
Rust’s Percent Keeps the Sign
-3 % 2 is -1 in Rust, and that one sign rule is the only thing separating the three parity checks in my crate.
-
I Reimplemented min()
I counted 61 characters for my hand-written closure body and 34 for the one that calls min. The standard library version is the better line.
-
The Seed Is the Algorithm
My first find_max did not compile — expected &i32, found Option . The seed was the whole problem, and one test line is the only thing holding it in place.
-
I Wrote the Fold by Hand
My hand-written fold and the standard library’s sum() panic in the same place with the same message, and in a release build they produce the same wrong number.
-
The Version I Commented Out Was Right
The shipped count_digits returns -2147483647 for zero, and the version I commented out above it was the correct one.
-
A Table to Hold One Number
The dynamic programming factorial allocates 52 bytes per call and throws them away, and the recursion it replaced allocates nothing at all.
-
Three Implementations, One Shipped
The naive recursion in the fibonacci file makes 2,692,537 calls to produce one number. The version that actually runs allocates nothing, and still overflows at n = 47.