Would you please explain to me how printf is confusing? When a person is
just starting out with programming, one of the first things they learn is
how to use functions. How make functions, call functions... the works.
printf *is a function*. People who are new to programming are implicitly
more comfortable with functions than with the awkward cout method that C++
uses. Printf actually makes quite a bit of sense, but more importantly, or
actually *most importantly*, when you're learning a language for the first
time the means of printing to a console is among the first objectives
taught. There is a classic program known as "Hello World" which hinges upon
this concept. Regardless of the implementation, *it will be taught* to
newcomers. That's not a concern, at all.

I'm also confused as to how printf is hard to find or rarely used, but more
importantly why it matters whether they've seen C or Rust before or not.
Look at the wikipedia page:
http://en.wikipedia.org/wiki/Printf_format_string#Programming_languages_with_printf

It is used in *everything*. If we don't teach it to them, then they'll just
have to learn about it later.

To recap,

   - printf is *the standard* and obvious way of the majority of
   programming languages
   - printf is well documented on the internet
   - the aforementioned documentation is easy to find
   - printf is not difficult, and hinges on comprehension of very basic
   programming concepts, such as variables
   - printf performs well, so with all of these advantages and the good
   performance, why mess with a good thing?


Why do you hate printf so passionately? It is a tried and true solution
that works brilliantly.


On Mon, Jul 15, 2013 at 6:05 AM, Bennie Kloosteman <[email protected]>wrote:

> 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
>
>


-- 
Sincerely,
    Josh
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to