The Good, The Bad, and The BJ
By: Sevion
Contents
Introduction
What is a BJ?
What is a Native?
The Good
The Bad
Conclusion
I would make anchor tags, but they seem to have been removed.
Introduction
What's a BJ?
What is a Native?
The Good
The Bad
Conclusion
If there is anything I've missed or royally fucked up on, please tell me. I want to make this as accurate and informative as I can.
By: Sevion
Contents
Introduction
What is a BJ?
What is a Native?
The Good
The Bad
Conclusion
I would make anchor tags, but they seem to have been removed.
Introduction
I am making this tutorial because there seem to be *many* misconceptions about them.
I.E.: "ZOMG! BJ! I ARE BURNING!!! AGH!!!!!!!!!!!"
Many people seem to believe that all BJ's are terrible and should be avoided at all costs. That cost usually ends up being code readability.
I hate always having to read loop loop loop.... loop.... loop.... or having a quadbillion calls just to do one thing.
Sure, it's an extra call.
ONE (usually) extra call.
Not exactly a lot.
Though, there are some BJ's that are just plain retarded.
Want to know more? Read on!
I.E.: "ZOMG! BJ! I ARE BURNING!!! AGH!!!!!!!!!!!"
Many people seem to believe that all BJ's are terrible and should be avoided at all costs. That cost usually ends up being code readability.
I hate always having to read loop loop loop.... loop.... loop.... or having a quadbillion calls just to do one thing.
Sure, it's an extra call.
ONE (usually) extra call.
Not exactly a lot.
Though, there are some BJ's that are just plain retarded.
Want to know more? Read on!
What's a BJ?
A BJ is simply a function in the blizzard.j.
Simply put, it's a wrapper made by Blizzard to either make JASSing easier or make it easier to develop/shorter descriptions for the UI for GUI.
An example would be the swapped functions.
A BJ, in essence is a misunderstood tool.
It's like a double-bladed sword. It can both harm your code, and make it better.
It's merely a question of which BJ's to use and which to avoid.
Simply put, it's a wrapper made by Blizzard to either make JASSing easier or make it easier to develop/shorter descriptions for the UI for GUI.
An example would be the swapped functions.
A BJ, in essence is a misunderstood tool.
It's like a double-bladed sword. It can both harm your code, and make it better.
It's merely a question of which BJ's to use and which to avoid.
What is a Native?
A Native is a function programmed into Warcraft III already. They are all listed in the common.j.
All Natives are better than BJ's in terms of speed and efficiency, no arguments whatsoever.
However, BJ's are, in most cases, better for readability, and this can be used in favor over efficiency when it's not going to affect gameplay much or at all and when readability is a high priority.
All Natives are better than BJ's in terms of speed and efficiency, no arguments whatsoever.
However, BJ's are, in most cases, better for readability, and this can be used in favor over efficiency when it's not going to affect gameplay much or at all and when readability is a high priority.
The Good
There are good BJ's.
Some are the BJDebugMsg. Yeah, that one is tehpwnagezorz.
BJDebugMsg is like Arnold Schwarzenegger yelling "GET TO DAH CHOPPAH!!!!!!!"
Another few are the math ones like RMaxBJ.
Texttag functions are tehpwn as well if you've ever tried making them with Natives.... *shivers*
Some events like TriggerRegisterAnyUnitEventBJ are alright, though you can also use TriggerRegisterPlayerUnitEvent with GetLocalPlayer()
[PSST! HELP ME LOOK FOR A BJ THAT'S BETTER (efficiency) THAN A NATIVE! I will gets a cookie ]
Some are the BJDebugMsg. Yeah, that one is tehpwnagezorz.
BJDebugMsg is like Arnold Schwarzenegger yelling "GET TO DAH CHOPPAH!!!!!!!"
Another few are the math ones like RMaxBJ.
Texttag functions are tehpwn as well if you've ever tried making them with Natives.... *shivers*
Some events like TriggerRegisterAnyUnitEventBJ are alright, though you can also use TriggerRegisterPlayerUnitEvent with GetLocalPlayer()
[PSST! HELP ME LOOK FOR A BJ THAT'S BETTER (efficiency) THAN A NATIVE! I will gets a cookie ]
The Bad
All Natives are faster than BJ's, however, who the hell can tell the difference between 0.0001 seconds of execution time and 0.0005 seconds?
Seriously?
If you can, you are not human.
BJ's are also very bad.
Consider <FunctionName>Swapped.
What's the point in that?
Well, Blizzard made them in mind that, one extra function call won't hurt and that it would be easier to make the text UI for GUI that way. Though, why they didn't just make the Native oriented that way, I don't know.
An example of this stupidity is:
Seriously, what's the point in calling a function and having that function return a function?
It does nothing else!
All it does is change the orientation of your arguments!
So, while it helps making GUI texts, it's kind of retarded
That, is a stupid thing to do.
Don't use those functions.
A good way to tell if you should or should not use a function is to check the function's code. If it looks retarded, it probably is.
If you're not sure, use the Native form. It's almost always going to be better.
But, BJ's are more safe. Blizzard made them failsafe(ish). If the Native is bugging for you, try the BJ and see what happens.
Seriously?
If you can, you are not human.
BJ's are also very bad.
Consider <FunctionName>Swapped.
What's the point in that?
Well, Blizzard made them in mind that, one extra function call won't hurt and that it would be easier to make the text UI for GUI that way. Though, why they didn't just make the Native oriented that way, I don't know.
An example of this stupidity is:
JASS:
function SetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit, integer level returns integer
return SetUnitAbilityLevel(whichUnit, abilcode, level)
endfunction
Seriously, what's the point in calling a function and having that function return a function?
It does nothing else!
All it does is change the orientation of your arguments!
So, while it helps making GUI texts, it's kind of retarded
That, is a stupid thing to do.
Don't use those functions.
A good way to tell if you should or should not use a function is to check the function's code. If it looks retarded, it probably is.
If you're not sure, use the Native form. It's almost always going to be better.
But, BJ's are more safe. Blizzard made them failsafe(ish). If the Native is bugging for you, try the BJ and see what happens.
Conclusion
What do I think?
Well, there are many pros and cons.
Let me line them up:
Pros:
Cons:
So, you're looking at this and going "Are you retarded? Cons wayyyyy outweigh the Pros!
Even so, if you know how to use them, you can cancel out a lot of the Cons.
It's all a matter of whether or not you know how to use them.
So learn.
I'm willing to bet some very experienced vJASS'ers may have something to learn here.
So, while it's true, BJ's should mostly be avoided, it depends on your situation
The more you use BJ's in submitted resources etc, the more advice you'll receive and the more you'll know about which BJ's to use, when to use them etc.
So experiment!
Learn!
You will become a BJ master! (Oh, God. That sounds dirty )
Well, there are many pros and cons.
Let me line them up:
Pros:
- Can be same speed (Keyword: Can)
- Can have better readability
Cons:
- Can have leaks
- Will have less speed
- Can make lag
- Can teach bad habits (Keyword )
- Can get flamed for using them
- Can have worse readability [Yes, I have seen that before]
So, you're looking at this and going "Are you retarded? Cons wayyyyy outweigh the Pros!
Even so, if you know how to use them, you can cancel out a lot of the Cons.
It's all a matter of whether or not you know how to use them.
So learn.
I'm willing to bet some very experienced vJASS'ers may have something to learn here.
So, while it's true, BJ's should mostly be avoided, it depends on your situation
The more you use BJ's in submitted resources etc, the more advice you'll receive and the more you'll know about which BJ's to use, when to use them etc.
So experiment!
Learn!
You will become a BJ master! (Oh, God. That sounds dirty )
If there is anything I've missed or royally fucked up on, please tell me. I want to make this as accurate and informative as I can.