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
Programming languages..
Goto page Previous  1, 2
 
Post new topic   Reply to topic Printable version
 View previous topic  Halloween Post :: Post SSN Closed?  View next topic  
Author Message
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed Oct 27, 2004 5:39 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Well duh! It doesn't work in C, so it must be bad!
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
CypherJF
I gargle nitroglycerin


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

PostPosted: Wed Oct 27, 2004 5:42 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

so cry me a river...

tongue.gif
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu Oct 28, 2004 2:24 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

iostream is about 27 levels of function calls away from the operating system. And do you know what it uses? printf!
_________________
4,691 irradiated haggis!
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 Oct 28, 2004 7:09 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

And the OS is probably another 50 function calls away from the assembly.

Iostream makes it easier for programmers to develop programs. That's why it's there. Not so that it can print to the console with blindingly fast speed, because, after all, no one really cares how long it takes.
_________________
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
lp_street_soldier
Thing 1


Age:33
Gender:Gender:Male
Joined: Apr 24 2004
Posts: 352
Location: Britain
Offline

PostPosted: Thu Oct 28, 2004 7:53 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Bleh <_<
Back to top
View users profile Send private message Add User to Ignore List Send email MSN Messenger
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu Oct 28, 2004 8:07 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Dr Brain wrote:
And the OS is probably another 50 function calls away from the assembly.

Iostream makes it easier for programmers to develop programs. That's why it's there. Not so that it can print to the console with blindingly fast speed, because, after all, no one really cares how long it takes.


You must work for Microsoft! new_scatter.gif
Back to top
View users profile Send private message Add User to Ignore List
SuSE
Me measures good


Joined: Dec 02 2002
Posts: 2307
Offline

PostPosted: Thu Oct 28, 2004 8:47 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Anybody read "The C Programming Language" or "The C++ Programming Language"? Comments?
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
k0zy
Server Help Squatter


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

PostPosted: Thu Oct 28, 2004 10:17 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Mr Ekted wrote:
I never use scanf() in any program. And if you are going to use iostream, you might as well prgram in VB.


What do you use?
You do the same as MGB?

Mine GO BOOM wrote:
I still do gets() -> atoi()


EDIT: Here's a program I had to code for my programming class.
I began studying Computer Scince a few month ago. (I knew how to code C before)
The program solves the equation a1*x + a0 = 0
Code: Show/Hide
/*
Author: Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Martikelnummer: xxxxxx
Aufgabe 10
----
Programm liest aj der Gleichung a1*x + a0 = 0 ein, und berechnet x
*/

#include <stdio.h>

int main(void) {

   double a0=0;   // erster Faktor der Gleichung
   double a1=0;   // zweiter Faktor der Gleichung
   double x=0;      // x das berechnet werden soll

   puts("a1*x + a0 = 0");
   puts("a1 und a0 eingeben:");
   scanf("%lf %lf",&a1,&a0);      // Zahlen vom Typ double einlesen
 
   /*
    Lösung der Gleichung:
      a1 * x + a0 = 0
      a1 * x = -a0
      x = -a0/a1
   */

   // Keine Lösung für a1=0, weil man nicht du 0 teilen darf, also Fehler abfangen.
   if (a1 != 0) {
      x = -a0/a1;
      printf("x= %.2lf\n",x);
   } else {
      puts("Keine Lösung der Gleichung für a1 = 0");
   }

   return 0;
}


Any comments on the coding style and the way I solved the problem, Ekted?
I'd like to know if an axperienced coder like you tells me the same things as my lecturer, because I doubt what he says sometimes.

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
-Smong-
Guest


Offline

PostPosted: Thu Oct 28, 2004 2:52 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I prefer to put opening curly brackets on their own line as you can then find code blocks easier. Although when I first started I only had 160x160 screen and 4k file size limit so I was trying to cram as much as posible onto each line.

Also when passing parameters and such I put a space after the comma so it reads well.
Back to top
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu Oct 28, 2004 5:50 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Reformatted to my tastes. Also, scanf may fail if the input isn't very specific. You should use gets(), parse, and display appropriate errors.

Code: Show/Hide

#include <stdio.h>

int main (void)
{
double a0 = 0;   // erster Faktor der Gleichung
double a1 = 0;   // zweiter Faktor der Gleichung
double x = 0;    // x das berechnet werden soll

puts("a1*x + a0 = 0");
puts("a1 und a0 eingeben:");
scanf("%lf %lf", &a1, &a0);      // Zahlen vom Typ double einlesen

/*
Lösung der Gleichung:
   a1 * x + a0 = 0
   a1 * x = -a0
   x = -a0/a1
*/

// Keine Lösung für a1=0, weil man nicht du 0 teilen darf, also Fehler abfangen.

if (a1 != 0)
   {
   x = -a0 / a1;
   printf("x= %.2lf\n", x);
   }
else
   puts("Keine Lösung der Gleichung für a1 = 0");

return (0);
}
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu Oct 28, 2004 5:53 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Here's a picture I made showing most of my style issues...

Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


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

PostPosted: Thu Oct 28, 2004 6:38 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

style natzi icon_wink.gif jk... I think it's good advice to have a consistent clean programming style.
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Fri Oct 29, 2004 1:07 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

I like the function's to be indented. Other than that, its pretty much the same. I have the {}'s indented or not depending on whatever editor I use at the time sets up as the default.

I prefer /* */ for large comment blocks over //'s. And when I do, I always have each new line started with a *, and all the *'s line up vertically.
Back to top
View users profile Send private message Add User to Ignore List Send email
Onlyone
Newbie


Joined: Jul 26 2004
Posts: 13
Offline

PostPosted: Fri Oct 29, 2004 3:14 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Dang Ekted... i thought i was a neat freak icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Fri Oct 29, 2004 5:35 am   Post maybe stupid    Post subject: Astyle Reply to topic Reply with quote

I dislike a few things in Ekted's style, although most of it is the same as mine. icon_smile.gif

Sourceforge has some project called "astyle", I hate how it was written but it works, anyway, it can restyle source code into a bunch of styles.
Could be interesting for "style nazis". sa_tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Oct 29, 2004 6:25 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

I basically have the same style as MGB: Ekted's style but with indented functions. Actually, why do you not indent your functions, Ekted?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Fri Oct 29, 2004 2:13 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I don't indent functions because it's just extra work, wasted space, at the lowest level. Since function are always delimited by green comments, it's easy to see where they begin and end. It's not important to me that everyone use my style. They just need to be consistent within their own style, and be relatively clean. When people code using their own style, it's easier for them to code with fewer mistakes. I also believe in 1-file 1-coder methodology. I do not share code on projects. If someone takes over file(s) of yours, they own it and can format it how they wish.
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: Fri Oct 29, 2004 3:04 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

That's bacicly how I feel about peoeple's styles, with a few exceptions. When I code for ASSS, I try to follow the ASSS coding style. As it's not all that different from the way I code, this wasn't a big strech. Though I've recently given up this habit, I do feel that people should make a small effort to keep files in a public project similar to each other.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Fri Oct 29, 2004 4:16 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

I found the ASSS source files that I saw to be unreadable. grel and I are on opposite ends of the spectrum for code design, coding style, and open source issues, so it's best that we don't work together anyways.
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 Previous  1, 2
Page 2 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: 137 page(s) served in previous 5 minutes.

phpBB Created this page in 0.634394 seconds : 43 queries executed (81.7%): GZIP compression disabled