• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] BJ's versus non BJ's

Bj versus no Bj - what you think?

  • What a discussion ... I give a s**t on the amount of Bj's I use

    Votes: 0 0.0%

  • Total voters
    12
Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Well I'm not the first one who open a discuss about these BJ's but I want get it clearly now.
I remember, when I started with Jass I often heard "omg why you use bj's" or "wtf remove this stupid bj's" and since this time I start to avoid each BJ. Now yesterday I had a little problem and I asked Bribe for help and he gave me a solution with:
JASS:
ModuloInteger()
As you see it's red marked, so I thought, because it's bad, I have to replace it and I did:
JASS:
local integer modulus = dividend - (dividend / divisor) * divisor //check if 0
After I posted it to Bribe he asked me why I replaced it and I simply said "because it's red marked and this is bad". He told me then that some Bj's aren't bad include these Math Bj's and the discussion started.

Now we want ask for some more opinions, because I get ± . ± when I see a bj and I need! to replace them, while he says that's ok to have some Bj's and/or red marked things.

But there's more; lets take the math bj's again. I was wondering, if this "ModuloInteger" is a good one, why does JassHelper give a solution how to use another way where nothing is red marked and why not use it then?

One more point was the fix would increase the map size and I tested 100 of the "red-marked-way" and 100 of the "no-red-fix" and well the map size increase by 0.3 kb. I said to him if someone comes and say "omfg this 0.3 kb will save the world it's imba important" I would just say "shut up".

========

Who said and why that these TriggerRegister Bj's are ok? like:
JASS:
TriggerRegisterAnyUnitEventBJ
So many say "Bj's are bad" but if you looking at this one now, how you know that this is a good one, even when you can replace it so easily?

========

Also what about Bj's like this:
JASS:
bj_MAX_PLAYER_SLOTS or bj_PI

Well they aren't marked red but there's a bj_ in front of it, so I thought I must replace them as well, but again they should be ok when I can type instead of bj_MAX_PLAYER_SLOTS, 15 and instead of bj_PI, 3,14159265?

========

Another thing is this:
JASS:
bj_mapInitialPlayableArea

So many here say this one is fine, anyway that this is a BJ but it's also a leak as far as I know and Pharaoh_ said it too, but what make this one ok for using?

========

One more thing is this:
JASS:
bj_lastCreatedGroup

As I understand Bribe he said, it's ok to use this one and it never gets destroy during the game, but isn't this bad? Why not just creating a local group only when you need it?

========

So at the end I want know what bj's you think are ok to use and why? Also how you, or I can, see that this Bj is ok? I mean is there a formula for it or something?
Hope some people here can give good critics of they opinion and why useing/mot using what bj and/or what kind of bj's.

Greetings and Peace
Dr. Boom
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Variables with bj prefix aren't bad at all. Use them to your heart's pleasure.

Some BJ functions aren't bad, since they don't do any useless or extra work, like ModuloInteger.

Many BJ functions are bad, since they are just wrapper functions for other functions. They call another function. So you could skip calling the BJ and call the native instead.
 
Level 13
Joined
Sep 13, 2010
Messages
550
I competely agree with Maker, I don't think that all BJs are bad there are a few BJ that makes life much happier and saves us for hundreds of Jass-Horror while scripting. Others should be thrown to hell :) Well that would be nice to make a native using GUI :) You know when you are creating functions in (v)Jass you often put call MyASDnamedfunc( Player( int ) , 999 ) this is the same as BJ. MyASDnamedfunc is the BJ and you call it. About those variables: they suck. Most of them only used for GUI but there are some of them could be useful too. Not like LastCreated$$$ thing. If they are saved to one variable of yours it is OK. Almost all type is a handle which is connected to a variable. If there is no variable which is using that handle -> leak. Thats all what I think. I prefer natives, but I will not create a 50 line jass shit if there is a BJ for that.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Some BJ functions aren't bad, since they don't do any useless or extra work, like ModuloInteger.

still you have an additional function call


but you can't really say when inlining a function makes sense or not
http://www.parashift.com/c++-faq-lite/inline-functions.html
some of these statemens might not be true because it is about c++ and not jass and nobody knows how blizzard implemented this language (or maybe someone with lots of free time who can read assembly instructions like plain text does) but for human beings it is close to impossible to judge and under most circumstances it won't matter
still you don't have to use stupid functions like GetXYZSwapped but using functions which improve readability by a noticeable ammount is fine imho
 
Level 16
Joined
May 1, 2008
Messages
1,605
Then why should I change this when I use this one:
JASS:
SetUnitManaBJ

When I see the native, if takes a unit, takes the state (mana) and takes a value returns nothing.

JASS:
call SetUnitManaBJ(u,GetUnitState(u,UNIT_STATE_MANA) + 500.)

call SetUnitState(u,UNIT_STATE_MANA,GetUnitState(u,UNIT_STATE_MANA) + 500.)

What about swapped functions?:

JASS:
AddHeroXPSwapped()

AddHeroXP()

Can I use this swapped one too? Or is there any difference if the function pick: 1) Unit 2) Amount 3) Candy instead of 1) Amount 2) Unit 3) Candy?

Greetings and Peace
Dr. Boom
 
Level 13
Joined
Sep 13, 2010
Messages
550
Swapped things are the common BJs they do nothing in addition. It is only for better look in the GUI. These are "the burn in hell" type BJs. We have tons of them, and we are using none them in Jass. Like
JASS:
function LoadHashtableHandleBJ takes integer key, integer missionKey, hashtable table returns hashtable
    return LoadHashtableHandle(table, missionKey, key)
endfunction
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Some code marked with BJ is nothing more than an adapter and the shitty JASS compiler the game uses does not optimize well so calling them wastes time.

Most of the BJs exist purly because they wanted to obscure useful JASS functionality in GUI or they just could not be bothered swapping the parameters in the action (so an adapter function was needed).

Not all BJs are usless but the majoritory are.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Some also just take the native form but change the range of the parameter to make it more obvious for which who have no experience in programming language and/or to make parameters more comprehensible for a human, such as SubStringBJ, the one which return the player id +1 (don't remember the name).
PercentTo255 used to color values, and so one.
 
Status
Not open for further replies.
Top