Price drops between two snapshots

FxDart wins

Requirement

Two snapshots of a shop's price list (data in the code): June and July. Some items got cheaper, some more expensive, one was discontinued and one is new. Report every item that dropped in price — old price, new price, and the drop — sorted by biggest drop first, plus a callout for the single biggest drop and the total savings. Both versions must print the report under Expected output.

Expected output
Price drops, June -> July
  Hand Grinder    $49.90 -> $44.00  (-$5.90)
  Espresso Beans  $18.00 -> $14.50  (-$3.50)
  Filter Papers   $6.40 -> $5.90  (-$0.50)
Biggest drop: Hand Grinder (-$5.90)
Total savings if bought now: $9.90

Side by side

Native Dart

FxDart

Why they differ

The whole task is one flow: index June by SKU, keep July items that got cheaper, pair each with its drop, sort by drop. FxDart has a named step for each move — indexBy for the lookup table, filtermapsortBy for the pipeline, then head and sumBy reuse the same result list for the summary lines. Native Dart can express it — a map literal for the index, where/map/ sortedBy for the chain — but the vocabulary is scattered: fold with a seed instead of sumBy, sortedBy<num> with a negated key, and no name at all for "build me a lookup by key".

Benchmark

Apple M1 Max, 32 GB RAM · Dart 3.12.2 (AOT-compiled) · 2026-08-24

N = 100

Time Tie

Native Dart 56 µs
FxDart 37 µs

Peak memory Tie

Native Dart 16.5 MB
FxDart 16.5 MB

N = 10,000

Time FxDart wins

Native Dart 7.05 ms
FxDart 3.62 ms

Peak memory FxDart wins

Native Dart 37.2 MB
FxDart 34.0 MB

N = 1,000,000

Time FxDart wins

Native Dart 1160.5 ms
FxDart 640.7 ms

Peak memory Native wins

Native Dart 393.6 MB
FxDart 427.0 MB

Bars are medians of repeated timed iterations in fresh processes per side (small N is batched for timer resolution). Sides within 5% of each other — or within 0.6 ms, a difference no person can perceive — count as a tie; close relative races are re-measured up to 5 runs. In an app, anything under a few milliseconds is invisible to the user regardless of which bar is shorter. Memory is peak process RSS. The Dart VM and the dataset are identical on both sides, so the difference between the two bars is what the pipeline itself holds onto.