For new comers to Julia, is teaching the string() and * useful?
It seems if you’re putting 2 or 3 strings together using string() and * it shouldn’t be a problem. It may become difficult when you have a lot of variables, and need to piece together strings, punctuation and \n.
If I want to print several variables at the same time, I usually use the long form of println(a, b, c, ...). If I have to build up a really long string from a large number of values in a loop, I usually use an IOBuffer to print into, since that will create the string object itself only when it’s consumed. Because strings are immutable in julia, each application of * has to create a new string and can’t modify existing strings, so for really long string concatenation, an IOBuffer is usally faster. This is advanced though and isn’t particularly helpful in introductory material - *, string and multi-argument println should be fine there.
On the surface using $ looks straightforward, especially when you have to deal with quoting punctuation, and ".\n".
A beginner might want to know why they should learn string() and * when $ looks easier? I’ll admit, I’m not too sure myself, so I was wondering what the difference is between them. Does string() or * provide some functionality that $ doesn’t?
Different syntax is occasionally useful — sometimes one alternative is more convenient, sometimes the other. Personally I find $ interpolations quite nice for info/error messages that can be read as a template. Just use whatever you prefer.