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

iostream vs. stdio

Name: Anonymous 2007-11-22 14:09

so, I've got EXPERT PROGRAMMERS telling me to use printf instead of cout in c++, ok but why? what is the difference (in b4 stream)

Name: Anonymous 2007-11-22 14:16

>>1
C++ is a dirty hack.

Name: Anonymous 2007-11-22 14:19

ask them not us

Name: Anonymous 2007-11-22 14:21

>>3
but they are total fags...

Name: Anonymous 2007-11-22 14:25

>>1
they are not EXPERT PROGRAMMERS.
They would tell you not to use C++ at all if they where.

Name: Anonymous 2007-11-22 14:29

>>1
BLOATED EXECUTABLES

when you use any of the c++ i/o you're including statically alot of code, so your exe is HUEG

Name: Anonymous 2007-11-22 14:46

SEPPLES ITT

Name: Anonymous 2007-11-22 14:50

I was just thinking about iostreams yesterday. What the fuck? Why did they ever think
cout << "Yo" << " I'm " << 6 " fags!" << endl;
was a good idea? Not only does it look like bit shifts, it's longer and harder to read than the alternative would have been.

Name: Anonymous 2007-11-22 15:41

>>8
They probably did it to show off how C++ could overload operators and use objects. OMG NEW FEATURE LETS USE IT!!!111

>>6
You can link dynamically too, but it's still a very roundabout way of doing it (IIRC cout eventually calls through printf or something)

Name: Anonymous 2007-11-22 17:19

>>6
Yeah, that must be the reason.

:facepalm:

Name: Anonymous 2007-11-22 18:51

>>10
die

Name: Anonymous 2007-11-22 19:03

cout is an ugly hack.

printf is a very, very capable and universal way of printing data.

Basically, you're a dumb nigger so just use printf like we said.

Name: Anonymous 2007-11-22 19:08

>>6
solid numbers or gtfo.

Name: Anonymous 2007-11-22 20:33

>>13
/* hello.c */
#include <stdio.h>
main() {
 printf("Hello world!");
}

633 bytes

// hello.cpp
#include <iostream>
using namespace std;
main() {
 cout << "Hello world!";
}

2560 bytes

Obtained with maximum optimization and dynamic linking enabled.

Another program I wrote (the details don't matter, the important thing is that it writes to standard output A LOT) -- again, maximum opts and dynlink:

All stdio: 12KB
All iostream: 40KB

Name: Anonymous 2007-11-22 20:34

>>14
but which is faster?

Name: Anonymous 2007-11-22 20:36

>>15
i'd imagine stdio to be, but not by a whole lot

Name: Anonymous 2007-11-22 20:43

>>16
I actually haven't measured it, but I imagine cout is faster, or rather, has the potential to be faster. because printf interprets the format string, the cout stuff is determined at compile time.

Ok, yes, it's not a huge overhead. I'm a moron, forget it.

Name: Anonymous 2007-11-22 20:59

>>15
gcc win32 codeblocks full opt.
a: 0.015s av. over 10 runs
b: 0.032s av. over 10 runs

Name: Anonymous 2007-11-22 21:03

>>18
which is a and which is b?

Name: Anonymous 2007-11-22 21:04

>>13
% gcc -O2 hello.c -o helloc
% g++ -O2 hello.cpp -o hellocpp
% strip helloc hellocpp
% ls -l helloc hellocpp
-rwxr-xr-x 1 expert progmr 13184 2007-11-23 02:01 helloc
-rwxr-xr-x 1 expert progmr 17780 2007-11-23 02:01 hellocpp

Name: Anonymous 2007-11-22 21:38

>>19
a: printf
b: cout

Name: Anonymous 2007-11-22 23:29

I would only use c++ i/o when stdio isnt adaquete, such as displaying int64s, cout is overloaded to work with 64 and 128 bit (i think) binaries

Name: Anonymous 2007-11-22 23:33

>>22
Or you can lrn codez and actually program properly rather than using moronic fucking languagehacks.

Name: Anonymous 2007-11-23 3:07

cout doesn't have to run a fucking interpreter with % tags and parameters scattered in different places.

Name: Anonymous 2007-11-23 4:19

>>24
You make it sound like parsing a string and interpolating values when you encounter a sigil is somehow computationally intensive.

Name: Anonymous 2007-11-23 5:52

>>24
You make it sound like writing friend functions of operator<<(ostream &, T &) is somehow the lesser evil to an extremely minor performance difference.

(I mean, it didn't matter even on a kilohetrz-clocked PDP-8!)

Name: Anonymous 2007-11-23 5:59

OH FOR FUCKS SAKE ?? 26 POSTS ON THIS THREAD GOOOD DAMN IT SHUT UP EVERYONE IM TRYING TO SLEEP

Name: Anonymous 2007-11-23 7:06

>>24
Enjoy your iomanip

Name: Anonymous 2007-11-23 8:05

>>1
Stroustrup is the biggest troll ever, who the fuck would really think about overloading bitwise operators and saying that it's better learning C++ without any knowledge of C. Listen to people like Paul Graham and The Sussman they know what they are talking about.

Name: Anonymous 2007-11-23 9:23

>>29
Truth

Name: Anonymous 2007-11-23 11:51

>>22
printf() in 64-bit and 128-bit environments would by necessity support outputting those sizes.

>>24
There's fwrite(), puts() and other output functions that don't do formatting if you don't need it. But most of the time you do need the formatting, and that's when something like "%08X-%08X-%c|%d/%d%%" in a single printf() is better than a whole bunch of setxxx() calls.

Name: Anonymous 2007-11-23 13:17

>>31
Hey, isn't that VALID PERL CODE?

Name: Anonymous 2007-11-23 13:18

>>32
YOURE AN IDIOT

Name: Anonymous 2007-11-24 12:25

iostream = fail and aids, with a cherry on top.

Name: Anonymous 2007-11-24 12:32

>>34
Ahh, nothing like a convincing argument!

Name: Anonymous 2007-11-24 12:40

>>35

You must be new here

Name: Anonymous 2007-11-24 12:50

>>36
It seems that, my friend, that
 you
  have
   just
    been

 ##TROLLED##

     !!!

Name: Anonymous 2007-11-24 12:57

>>37

No, this was anticipated. It was found that deterring ill behaved new users was of greater importance than being `trolled' by an established member of this community.

Name: Anonymous 2007-11-24 13:28

>>38
no

Name: Anonymous 2007-11-24 13:35

>>39

No.

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