Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

printf() considered garbage

Name: Anonymous 2013-06-26 6:47

Why not just use puts()? Is formatting your own strings properly really so hard? Maybe if you went to a school with a name that ended in `.com'. If that's the case, enjoy your security holes when you fuck up and put an %n somewhere or do something stupid like printf(str) and loosing buffer overflows all over the place. Not only that, but it's inefficient and bloated. I am sick and tired of seeing new programmers wasting CPU time and memory to run this huge, buggy function.

In general, it's never a bad idea to use something simpler if available.

Name: Anonymous 2013-06-26 6:49

Funny thing that "secure" and type-safe c++ iostream are slower than printf.

Name: Anonymous 2013-06-26 7:08

>>2
What in Sepples isn't slower than C?

Name: Anonymous 2013-06-26 7:39

>>2
Not to mention format strings are better for localisation. (They still suck though. The Right Thing would be the ability to patch entire functions at run-time, seamlessly (i.e. without “dynamic” library nonsense). It would also help with different calendars, etc. as well as allow the extension of programs at run-time.)

Name: 4 2013-06-26 7:47

(continued, explaining why “format strings are better for localisation”)

Format strings are functions written in domain-specific languages. In effect, systems such as GNU gettext are run-time function loaders.

Name: Anonymous 2013-06-26 10:59

>>4,5
G?NU gettext

Confirmed for wildebeest-riding unwashed neckbearded hippie.

Name: Anonymous 2013-06-26 13:00

★☆☆☆☆

Name: Anonymous 2013-06-26 20:53

banpu pantsu

Name: Anonymous 2013-06-26 21:42

>>7
★★☆☆☆

Name: Anonymous 2013-06-27 4:02

>>9
☆★☆★☆

Name: Anonymous 2013-06-27 4:09

LISP

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-06-27 8:22

Why not just use [ocde]puts()[/code]?
You mean fputs()? Most of the time you don't want a newline after every string.

I am sick and tired of seeing new programmers wasting CPU time and memory to run this huge, buggy function.
You're wasting even more by calling individual "output an integer" "output a character" "output a string" etc. functions. If your printf() implementation is buggy then you should either fix it yourself or find someone who can (or complain incessantly until it is.) Yes, printf() by itself is huge if you're outputting very little but the savings add up across all the programs that need to use it, just like everything else in the standard library. Fortunately the C stdlib is one of the few things that has paid off its reuse many many times over (unlike some platforms named after coffee or a TLD...)

In the DOS days, there was no dynamic linking so every program did have its own copy of all the stdlib functions it used, and in that case you could make a better argument for custom output functions, but now that almost all OSs --- even some 8-bit embedded ones --- have dynlink, it's become a moot point.

Don't change these.
Name: Email:
Entire Thread Thread List