I've been using Mathematica for a long time, so I have a habit of using some of the older functions even when newer, better ones have been added to replace them.
StringForm
is one such function. I have the habit of using it with Print
as the Mathematica analog of C's printf
when I need debugging output. Today, when I found myself typing Print[StringForm[ ...
once again, the thought "why am I not using Row
?" occurred to me. Indeed, why not?
Row
has been in Mathematica since ver. 6. It looks to me it can do anything that StringForm
can do and a lot more. However, WRI has not deprecated StringForm
, so I wonder: should Row
always be used in place of StringForm
? Or is there still some use cases where StringForm
is better?
Row
as a more generic function that allows you to form a row of arbitrary items for visual appearances (e.g. strings and images) andStringForm
as a more low level function that's useful in injecting values into a boilerplate message. In writing debugging messages, I findStringForm
easier to use because I can read the text in one go, rather than being broken as inRow
$\endgroup$StringForm
to format the output ofDate[]
. But nowDate
is deprecated and we haveDateString
... So it's definitely true thatStringForm
is not nearly as central to formatting asRow
is. $\endgroup$Row
would seem to be preferred if you want to style words or phrases in Italic, Bold, etc., or with varying color or size or font family, for then you can useStyle
. $\endgroup$Message
usesStringForm
, so I think it can't be deprecated. $\endgroup$StringForm["x = ``", Style[1/3, Red]]
yields aString
, which looks the same asRow[{"x = ", Style[1/3, Red]}]
but different thanRow[{"x = ", Style[1/3, Red]}] // ToString
. Sometimes you might want aString
(to put into string functions, I suppose); sometimes it might suit your style, such as the use rm -rf mentioned. $\endgroup$