Raised This Month: $32 Target: $400
 8% 

[DEBATE] Hawk552 vs SnoW


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-13-2009 , 15:58   [DEBATE] Hawk552 vs SnoW
Reply With Quote #1

You should never assign a variable for zero when creating it:
PHP Code:
for( new 0sizeofszBuyCommands ); i++ ) 
But leave it as:
PHP Code:
for( new isizeofszBuyCommands ); i++ ) 
Don't blame me, it was Hawk who started the Bad practice- day.
SnoW is offline
Send a message via MSN to SnoW
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-13-2009 , 16:01   Re: Blocking Buy Commands (Basic)
Reply With Quote #2

Quote:
Originally Posted by SnoW View Post
You should never assign a variable for zero when creating it:
PHP Code:
for( new 0sizeofszBuyCommands ); i++ ) 
But leave it as:
PHP Code:
for( new isizeofszBuyCommands ); i++ ) 
Don't blame me, it was Hawk who started the Bad practice- day.

Edit:

Nothing.
I don't recall starting this or ever specifically saying anywhere that you have to do that, but it's completely fine. You could even consider it good practice because it clearly states what i will evaluate to instead of implying it.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-13-2009 , 16:11   Re: Blocking Buy Commands (Basic)
Reply With Quote #3

Quote:
Originally Posted by Hawk552 View Post
I don't recall starting this or ever specifically saying anywhere that you have to do that, but it's completely fine. You could even consider it good practice because it clearly states what i will evaluate to instead of implying it.
The way of assigning the variable comes from other langs such as Java where it has to be done. There's no point doing such thing in loops ( because you have some kind of habit for that ) and then not doing it in other cases. Imagine someone doing something smiliar as this:
PHP Code:
new origin] = { 00};
new 
boolbvar false
The starting values have to be known and reminding them for readability is just silly. This is really bad practice for my opinion.

Last edited by SnoW; 10-13-2009 at 16:26.
SnoW is offline
Send a message via MSN to SnoW
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-13-2009 , 16:21   Re: Blocking Buy Commands (Basic)
Reply With Quote #4

When do you ever use a vector when you first create it?
There is always some assignment that is done before it is used.

Also, the boolean variable can be declared as false for the same reason as an integer can be declared as 0.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-13-2009 , 16:34   Re: Blocking Buy Commands (Basic)
Reply With Quote #5

There isn't always an assigment, even the origin was a bad example. It could be in a hud game my worm's origin which I'd generate in a smiliar loop in what you used the size. What ever it doesn't matter.
Obviously there's no difference between false and zero, just that assigning a var to false seems in a code even worse practice.
SnoW is offline
Send a message via MSN to SnoW
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-13-2009 , 16:40   Re: Blocking Buy Commands (Basic)
Reply With Quote #6

Quote:
Originally Posted by SnoW View Post
The way of assigning the variable comes from other langs such as Java where it has to be done.
... I know, I use C++ way more than I use Pawn nowadays. The reality is that no language that I know of actually demands that you assign a value; it will just be garbage until you do. For this reason, I disagree with your analogy. In C, C++, Java, etc. we avoid assigning a value whenever possible because it's significantly faster. In this case, both options cost the same amount of resources but assigning a zero value is explicit as opposed to implicit.

Quote:
Originally Posted by SnoW View Post
There's no point doing such thing in loops ( because you have some kind of habit for that ) and then not doing it in other cases.
This is true. If you're referring to my code, however, I have moved away from that recently and it was previously never a conscious decision.

Quote:
Originally Posted by SnoW View Post
Imagine someone doing something smiliar as this:
PHP Code:
new origin] = { 00};
new 
boolbvar false
The starting values have to be known and reminding them for readability is just silly. This is really bad practice for my opinion.
Why do you use semicolons, then? According to your logic, it's a "relic" from Java and isn't necessary in Pawn, so why do you bear the double-standard? To respond to your statement, though, I don't really see the problem and don't think it's "really bad practice" since it doesn't cost any extra resources, is more explicit, and doesn't create any backwards compatibility issues.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-13-2009 , 17:09   Re: Blocking Buy Commands (Basic)
Reply With Quote #7

If you assign the var, other people don't get any readability, but they can actually get confused that the assigning isn't only possible but must be done.
There's no real problem here or either a solution to this, it's all about opinions.
When using semicolons the code isn't only much more clear and readable, but also the horrible thing that you are somehow limited to invisible lines is gone. When you see in chars where the statements end and the code can be even in one line I can't do anything but use semicolons.
SnoW is offline
Send a message via MSN to SnoW
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-13-2009 , 17:24   Re: Blocking Buy Commands (Basic)
Reply With Quote #8

Quote:
Originally Posted by SnoW View Post
If you assign the var, other people don't get any readability, but they can actually get confused that the assigning isn't only possible but must be done.
What? Either I don't understand your point, or I thought I already explained why it doesn't matter.

Quote:
Originally Posted by SnoW View Post
There's no real problem here or either a solution to this, it's all about opinions.
Well, no. Inefficiency is real and is not a matter of opinions.

Quote:
Originally Posted by SnoW View Post
When using semicolons the code isn't only much more clear and readable,
Not even remotely. I can't see any difference in readability and I think many people would agree with me. Semicolons are a crappy cop-out for the compiler to know when the line ends.

Quote:
Originally Posted by SnoW View Post
[...] but also the horrible thing that you are somehow limited to invisible lines is gone. When you see in chars where the statements end and the code can be even in one line I can't do anything but use semicolons.
In my over four years now using Pawn, I have never once that I can recall needed multiple lines for a single expression. The use of semicolons doesn't even "fix" it, anyway; you can use multiple lines for single expressions without them.

The fact that you can't deny is that using semicolons creates extra work for you. I'm arguing that the work you do is pointless and is a result of the "archaic" Java/C style that you're, ironically, advocating staying away from.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-14-2009 , 05:16   Re: Blocking Buy Commands (Basic)
Reply With Quote #9

Quote:
Originally Posted by Hawk552 View Post
Well, no. Inefficiency is real and is not a matter of opinions.
Umm... Maybe I understood wrong, but where was the inefficiency? The both ways should equal and one shouldn't be more efficient than one.
Quote:
Originally Posted by Hawk552 View Post
Not even remotely. I can't see any difference in readability and I think many people would agree with me. Semicolons are a crappy cop-out for the compiler to know when the line ends.
Many will agree with you, but I guess many will agree with me as well, maybe the ones who use semicolons? It's maybe more readable for me as I've got used to it, but I don't see why I need there a reason. It's just how it is. Somehow I don't see a reason how using start assigment would be any readable to the people who use it.

Quote:
Originally Posted by Hawk552 View Post
In my over four years now using Pawn, I have never once that I can recall needed multiple lines for a single expression. The use of semicolons doesn't even "fix" it, anyway; you can use multiple lines for single expressions without them.
But you can't many in a single line. Which I think in following situation when using "everyone know statement", looks even better than in two lines.
PHP Code:
new Floathealthpevindexpev_heathhealth );
//... 
Quote:
Originally Posted by Hawk552 View Post
The fact that you can't deny is that using semicolons creates extra work for you. I'm arguing that the work you do is pointless and is a result of the "archaic" Java/C style that you're, ironically, advocating staying away from.
It can actually be that the first lang in I used semicolons was pawn. You could compare the extra work to adding a "g" before global variables or even naming variables with long names just to make the code readable. This is still what you do as well I believe.
SnoW is offline
Send a message via MSN to SnoW
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-14-2009 , 09:24   Re: Blocking Buy Commands (Basic)
Reply With Quote #10

Quote:
Originally Posted by SnoW View Post
Umm... Maybe I understood wrong, but where was the inefficiency? The both ways should equal and one shouldn't be more efficient than one.
Okay... let me put this very simply. Which one of these takes longer to type?

PHP Code:

PHP Code:
 
Clearly, the first one does. Thus, if you cannot justify the extra work, using semicolons is inefficient. Multiply this by a few hundred times for any reasonable plugin, or a few thousand times for any big one, and you have a massive inefficiency problem here which is significantly bigger than the arguably inefficient explicit initialization of looping variables and iterators.

Quote:
Originally Posted by SnoW View Post
Many will agree with you, but I guess many will agree with me as well, maybe the ones who use semicolons? It's maybe more readable for me as I've got used to it, but I don't see why I need there a reason. It's just how it is. Somehow I don't see a reason how using start assigment would be any readable to the people who use it.
All action requires a reason or it is irrational. The readability was not my point in the first place; I was just stating that it's not as readable as you think in response to your claim that it looks nicer.

As for the initialization, I already explained that it can be more readable (although I don't do it) since it's clearly stating what a variable will contain without implying it and without costing any extra resources or introducing backwards compatibility problems.

Quote:
Originally Posted by SnoW View Post
But you can't many in a single line. Which I think in following situation when using "everyone know statement", looks even better than in two lines.
PHP Code:
new Floathealthpevindexpev_heathhealth );
//... 
That is terrible programming and is one of the first things that they teach you not to do in computer science/programming/electrical/whatever 101.

I mean, we can detag floats like this to use them as integers:

PHP Code:
new Float:temp
temp 
Float:get_user_fragsid )
client_printidprint_chat"Your frags are %d"temp 
But is this really a good idea? Would you really come to the conclusion, based on the code I have given above, that detagging incorrectly tagged variables is good/useful just because we can do it? Of course you wouldn't.

Quote:
Originally Posted by SnoW View Post
It can actually be that the first lang in I used semicolons was pawn. You could compare the extra work to adding a "g" before global variables or even naming variables with long names just to make the code readable. This is still what you do as well I believe.
This is a terrible comparison. Tagging variables with "g" is actually useful as it provides information that you can't see on first glance without it. I automatically know where the end of a line is without a semicolon, but if I'm looking through a block of code that is unfamiliar, I won't know what is global and what isn't. Giving variables long names is also nothing like using semicolons; it again provides useful information that you won't find on first glance without it. So no, what you're saying is not what I believe.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode