Dmitry Khalanskiy [JB]
05/28/2026, 6:04 PMformat invocation, like
val dateTime = LocalDate(2026, 5, 28).atTime(19, 58)
dateTime.format { monthNumber(); char(' '); day(); char(' '); time(LocalTime.Formats.ISO) }
Currently, you have to allocate a format in a separate object and then use it:
val dateTime = LocalDate(2026, 5, 28).atTime(19, 58)
val myFormat = LocalDateTime.Format { monthNumber(); char(' '); day(); char(' '); time(LocalTime.Formats.ISO) }
dateTime.format(myFormat)
This has the benefit of guiding programmers to store the format in some field once and use it multiple times (which amortizes the construction costs).
However, when called only once, the first form could actually be more performant, and it's also more succinct.CLOVIS
05/28/2026, 6:49 PMhfhbd
05/28/2026, 7:49 PMval germanDateFormat = …Thomas Hormes
05/29/2026, 3:07 PMEl Anthony
05/30/2026, 11:16 AMDmitry Khalanskiy [JB]
06/03/2026, 9:52 AMformat calls could realistically become twice as fast as they are now. We're focusing on stabilizing the library at the moment, getting the APIs right, and once we do, we'll dive into optimization, using what we have now as a reference implementation whose behavior we should match.
Currently, a naive implementation of dateTime.format { something() } is actually faster than using a pre-allocated structure, because it gets to sidestep the entire naively written parsing/formatting machinery!
From staring at the profiler and meditating on which complexity is inherent and which is avoidable, my current guess for the result we'll eventually see is:
• Allocating a new format for use in formatting (without ever calling parse) is 3 units of time,
• Formatting with a preallocated format is 1 unit of time,
• Formatting with an inline format is 1.3 units of time.
In any case, I'm certain the difference wouldn't be an order of magnitude or even close to that.
The question is mostly about whether the API would look nice, in your opinion. Right now, the impression is that there isn't all that much interest and the API is a "nice-to-have" at best.Anonymike
06/13/2026, 7:59 PM