Go and D are basically C with a few add ons so it makes sense thet want to
keep things the same that does not mean they are good ... and none of those
are major languages ..

String builder can  use streams but streams are slower then direct output
 ... . You can use string.Format both of which i mentioned  ... HOWEVER ..
the fastest  way is only really relevant to a small amount of code   though
it is important for libs  . The default and obvious methods should be the
easiest to use for someone who has nver seen C or Rust  and the most easy
to maintain , ...  So to me its not really relevant that the printf is
there thouigh it is important that its hard to find and rarely used :-)
 Defaulting to printf style is building  premature optomization front and
centre into the language just because some  authors are the most familiar
with it ..

Note C# does have format strings it uses {0} , {1} for the params since the
compile knows the type anyway ...seems a lotr smarter to me... when you
want to do more extensive format these days you have to take linguistic
formats it to account anyway ( yen with 2 decimal points looks  stupid...so
then you need something much more complicated anyway.




On Mon, Jul 15, 2013 at 1:09 AM, Daniel Micay <[email protected]> wrote:

> 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

Reply via email to