On Sun, Jul 14, 2013 at 2:29 AM, Bennie Kloosteman <[email protected]> wrote:
> The C printf way is very primative .. no new languages have used it in
> ages and even C++ tried to replace it with cout and overloading .
Scala, Go and D have compile-time checked, type-safe format strings for I/O.
> I prefer the Java /C# way which is best from a coding simplicity and
> safety point of view but can handle different cases.
>
> stream.Write ( str1 + str2 +string3) ( you can go Console.WriteLine or
> File but these use a stream underneath so i dont think it would make a huge
> difference in performance )
Allocations on output do make a huge difference in performance, Rust
is proving that true right now.
> I dont like print (str1 , str2 ,str3 ) as much because its not as
> obvious what the method does eg in C# if str1+str2 ..etc etc is too slow
> in a big loop you go to
>
> var str =string.Format ( "This is a long string with many inserts {0} at
> different points {1} , val0 , val1 ...) ;
> stream.Write (str);
>
> and if that is still too slow use stringbuilder to write direcly to the
> stream.
> and if that is still too slow build your own char array
All of this is much slower than just writing directly to a stream.
> It may be needed for the lib to give ok performance but i would call it
> somehing obscure like internal_print so its not the default option for every
> c programmer ..the default / easiest option needs to be the easiest and
> safest one to program .. which c printf style is not..
Format strings are entirely safe. They're checked at compile-time and
encourage separating the formatting from the input. You would be
hard-pressed to do internationalization without them.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev