4 ms·
I agree we don't need to optimize for characters typed, and needing to memorize/lookup formatting directives is a time sink. What I _do_ want to see optimized
by Yen 8y ago
I agree we don't need to optimize for characters typed, and needing to memorize/lookup formatting directives is a time sink.
What I _do_ want to see optimized for is readability - and this often is related to more compact representations. This is not hard-and-fast, and there's tradeoffs in both directions. This tradeoff becomes more tricky as you need to express finer grained control over formatting.
Consider
%{year}-%{month}-%{date}
%{year-4-digit}-%{month-2-digit}-%{date-2-digit}
%YYYY-%MM-%DD
Or, outside the context of dates,
Computed %u records in %u seconds (%0.3f MB/s)
Computed %{unsigned int} records in %{unsigned int} seconds (%{float-precision-3} MB/s)
Computed %{correctlyProcessedRecordsCount} in %{totalProcessingTime as seconds} (%{processingRate as megabytes-per-second with 3 digits precision} MB/s)
I don't have a great solution here, I just want to point out that the verbose cases can also get ungainly. I think, if we try to optimize for "format strings read approximately like the text they output", that probably gets close to the best middle ground.
- DCoder 8y agoAnd you haven't even touched localization (digit grouping, decimal separators, singular/plural noun forms, currency formats, week/month names with correct capitalization, …) yet.