News for hackers. Stuff that matters.
Re:Rust vs. C++ Formatting by lmm on Tuesday January 17, 2023 @05:07PM (#34420094)
IMO the least-bad vaguely mainstream approach is what people do in Haskell with e.g. formatting or fmt. Your formatter should be a first-class strongly typed value, and the way you form/construct that value should be the normal way you form values in your language.

I do think there's space for a "write a complex value literal by writing a string in a DSL and embedding that into the source" feature. But that shouldn't be specific to format strings, and it shouldn't be by running arbitrary code at compile time; rather it should be a language feature. I haven't seen a version of that that I'm really happy with yet, but Haskell's OverloadedStrings or Scala's StringContexts are some baby steps in the right direction.

Re:Rust vs. C++ Formatting by dilap on Wednesday January 18, 2023 @08:19AM (#34426286)
Thanks.

My haskell knowledge is minimal, but looking at formatting and fmt library examples, what stands out is you're operating in the syntax of the language, so it's clumsier to use (imo) than a string with interpolations. (It seems not-dissimilar to C++ streams, to me.)

I guess your second paragraph gets at that. I think you're arguing for, "build it into the language, but flexibly." Fair enough!