Scripting Style
#1

When I script, I indent normally, but write commands on "less lines" than normal. I don't give brackets their own line, I put them after the if, function, for, etc. in front of them.
Anyways, I tend to cram my code a bit tighter than most, will this result in reduced performance, or will it simply look bad(in most's opinion). Thank you.
Reply
#2

But it won't run slower?
Reply
#3

I would like to know this too, will it run slower or faster ? :/
Reply
#4

I don't think there is a difference, since coding both(the messy one and good one) will be the same thing
Reply
#5

well afaik when it compiles no matter how you had your brackets positioned you'll have the same result. I like to keep mine neat like
if (x == y)
{
stuff
more stuff
return 1;
}
but if it's just 1 line of things then I won't even open brackets like
if (x == y) return SendClientMessage(asdfwef,wafeaw,gder);
Reply
#6

No, it won't reduce performance if you cram it all together.
Reply
#7

like in every (as far as I know) scripting / coding language, spaces and tabs are no more then visual support to read the code. When the script is put to use, whitespace is not interpreted
Reply
#8

As others have correctly pointed out, there is no difference. The style in which you choose to script is a personal preference.

I script like this:

pawn Код:
if(x) {
   print("moo");
   print("another moo");
} else {
   print("no moo");
}

if(y) print("cheese");

print("%s", (z) ? ("milk") : ("meat"));
Reply
#9

Id do it like Ded
Reply
#10

For some reason i don't follow a certain style (not best idea) but i think its best to keep it spaced out so you can find/fix bugs or update faster.

I do beleive most (if not all compilers) ignore any spaces at compile time so it shouldn't make a difference to the performance of the compiled script no matter your scrpting style.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)