Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
why do people say a real programmer uses printf?
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  problem with c# Post :: Post Free Games Engine  View next topic  
Author Message
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Sun Apr 13, 2008 7:42 pm   Post maybe stupid    Post subject: why do people say a real programmer uses printf? Reply to topic Reply with quote

why do poeple say that a real programmer uses printf() over cout? To me they look pretty much the same except for printf() you do more writing and its smaller icon_confused.gif

like isnt it just easier to do

Code: Show/Hide

int age;
cout<<"enter your age: ";
cin>>age;
cout<<"you entered "<<age;


then
Code: Show/Hide

int age;
printf("Enter your age: ");
scanf("%d",age);
printf("you entered %d",age);

Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Apr 13, 2008 7:53 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

it's pretty much the same, typing-wise.

There was a big discussion among the Great Geeks of this forum about this... one of the 2 is "more efficient", apparently, but since you don't print something 1000 times a second, it doesn't change anything.

It's like the people who say Firefox is the only worthy browser, vs IE users... there are fanboys on each side, but they have no idea how much their fight is worthless...
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Apr 13, 2008 7:59 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mostly because "real programmers" use C, rather than C++.

I use the term loosely, of course, since the lower level you are, the more "real" you are. Making the people who cast the silicon the real programmers, I guess...
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Apr 14, 2008 3:56 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

/me waits for MrEkted to comment on the issue

I still remeber the endless discussions about that... ^^
And why MrEkted uses goto. That was fun to read, too.
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Mon Apr 14, 2008 5:18 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I always thought the formatting was pretty flexible with printf... never used cin/cout, though.
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Apr 14, 2008 6:14 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Anything you can do with one, you can do with the other. There are arguments for efficiency and abstraction on the C++ streams side, but they're fairly trivial things either way.

If you use C++, then you use iostreams. If you use C, then you use fprintf.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Mon Apr 14, 2008 10:04 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

fprintf is file print, right? I think you mean iostream/printf, or fstream/fprintf
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Doc Flabby
Server Help Squatter


Joined: Feb 26 2006
Posts: 636
Offline

PostPosted: Tue Apr 15, 2008 6:20 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

i find the printf syntax easier to read and understand, but thats just personal preference.
_________________
Rediscover online gaming. Get Subspace | STF The future...prehaps
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Tue Apr 15, 2008 8:06 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

IOStreams encompass the console and file io, and fprintf(stdout, "x") and printf("x") do the same task.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Tue Apr 15, 2008 8:32 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I just read a topic somewhere else and turns out in the C# you dont use cout or printf but you use their new function Console.WriteLine("Hello World!");

and its closer to printf but i dont get why do they have to keep changing shit?

this is how the input age works in c#

string input;
int age;
Console.WriteLine("Please enter your age");
input = Console.ReadLine();
age = Int32.Parse(myInput);
Console.WriteLine("You entered {0}", age);



now just tell me how gay is first impression of c# is?


also did Ekted have an acount on MGB? I read some stuff on wiki how ekted said that every one is a noob on SS and thats why he quit, or something like that
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Tue Apr 15, 2008 9:35 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

c# owns.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue Apr 15, 2008 9:58 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

the console is only used for debugging purposes most of the time anyway... getting input from it, and especially validating is a pain in the butt, and ugly tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
Blocks
Novice


Joined: Jul 13 2006
Posts: 95
Location: California
Offline

PostPosted: Wed Apr 16, 2008 1:52 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mr Ekted uses goto? I never knew him, but I thought better of him.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Doc Flabby
Server Help Squatter


Joined: Feb 26 2006
Posts: 636
Offline

PostPosted: Wed Apr 16, 2008 4:57 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

hellzlaker wrote:
I just read a topic somewhere else and turns out in the C# you dont use cout or printf but you use their new function Console.WriteLine("Hello World!");

and its closer to printf but i dont get why do they have to keep changing shit?

this is how the input age works in c#

Code: Show/Hide

string input;
int age;
Console.WriteLine("Please enter your age");
input = Console.ReadLine();
age = Int32.Parse(myInput);
Console.WriteLine("You entered {0}", age);


You could also write it like this.
If you think c# is diffferent take a look at Pascal tongue.gif
Code: Show/Hide

Console.WriteLine("Please enter your age");
int age = Int32.Parse(Console.ReadLine());
Console.WriteLine("You entered " + age);


Nothing wrong with using goto, the problem is when it gets overused by newbies, it has a valid place in programming imo.
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Wed Apr 16, 2008 11:41 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

hellzlaker wrote:
I just read a topic somewhere else and turns out in the C# you dont use cout or printf but you use their new function Console.WriteLine("Hello World!");

and its closer to printf but i dont get why do they have to keep changing shit?

this is how the input age works in c#

string input;
int age;
Console.WriteLine("Please enter your age");
input = Console.ReadLine();
age = Int32.Parse(myInput);
Console.WriteLine("You entered {0}", age);



now just tell me how gay is first impression of c# is?


You can actually do it the Java way too, I think, with concatenating strings. At the very least, you could do:

string output = "You entered" + age;
Console.WriteLine(output);, but you can probably do that inside of the parentheses. It's just whichever way you choose.

There's certainly a place for both. Most people prefer the first method, with the {0}, but... I had a project recently in my C# class where we were given a project, but we were told that we would later have to re-do the project using Windows programming instead of console input/output. So the idea was to code in a way that could be easily converted. Each class was supposed to have a Show() function that would just print all of the information that class was storing to the screen. So instead of having the function use Console.WriteLine(), I just had the function return "Var1: " + var1 + "\nVar2: " + var2; so that, in the main function, you could just Console.WriteLine(class.Show()); That way, when I had to re-do the project, I wouldn't have to change the classes at all.

Well, that was the idea. Instead I'm changing the project so it can work with a database, so I'll probably have to change the classes anyway, but whatever.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Wed Apr 16, 2008 12:43 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I'm pretty sure you need to use the .toString() method:
Code: Show/Hide
Console.WriteLine("You entered " + age.toString() );
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Wed Apr 16, 2008 2:21 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

the + operator is overloaded so you don't need to

Alternatively, you could even do
Code: Show/Hide
Console.Write("You entered ");
Console.WriteLine(age);


If you're doing a lot of string processing you should use String.Format (which is what you showed earlier with the {0}) or a StringBuilder for performance reasons.

@Ani: if you put the Show() method body into ToString() you would be able to Console.WriteLine(class);
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Wed Apr 16, 2008 2:57 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Blocks wrote:
Mr Ekted uses goto? I never knew him, but I thought better of him.


MrEkted is a great programmer.
In his opinion functions should only have one return.
He uses goto to break out of the funtions and jump to the return in case an error occurs.
That's an okay use for goto.

And I think it was him who said that cout actually uses printf internally.
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Wed Apr 16, 2008 4:04 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

well i guess i got used to C++ so much that all other languages look weird, but PHP, JAVA they kinda feel like C++, and C of course
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Apr 16, 2008 7:49 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote:
And I think it was him who said that cout actually uses printf internally.


He did. He was wrong.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Thu Apr 17, 2008 2:14 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Did you guys know that Java features a goto like construct? It can be used to break out of nested loops for example.

I just found that out a few weeks ago.
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Apr 17, 2008 7:44 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Yes, and the entire Java library is written without using it. In the Java specification, they say that it's bad practice to use it. I think they only put it in as a concession.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Thu Apr 17, 2008 8:22 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

I actually saw that the other week when I was decompiling a few java class files; it used a couple of goto statements.
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sat Apr 19, 2008 8:39 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

D1st0rt wrote:
@Ani: if you put the Show() method body into ToString() you would be able to Console.WriteLine(class);


elaborate

You mean, within my class definition, define a string ToString() method?
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Doc Flabby
Server Help Squatter


Joined: Feb 26 2006
Posts: 636
Offline

PostPosted: Sun Apr 20, 2008 9:03 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Animate Dreams wrote:
[..]
elaborate

You mean, within my class definition, define a string ToString() method?

Basically override the ToString method.

Example
Code: Show/Hide

public class MyClass
{
   public override string ToString()
   {
      return "String Representation of Class";
   }
}
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Trash Talk All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 185 page(s) served in previous 5 minutes.

phpBB Created this page in 0.782793 seconds : 50 queries executed (71.1%): GZIP compression disabled