• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Scope Deprecation

Do you think scopes should be deprecated?


  • Total voters
    23
Status
Not open for further replies.
Scopes in vJass, In my opinion, should be deprecated.
I think we should start encouraging the use of libraries instead of scopes.
Using scopes is a bad programming practice.
With scopes, you can make implicit requirements.

Anytime you want to make a spell, just use a library.
Libraries make explicit requirements, making debugging much easier.

Please comment on what you think, and if possible, select a poll option.
This is a serious issue because I've been seeing a lot of people uploading
spells encapsulated in scopes having about 1-4 requirements.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
I love scopes even if they're useless libraries (and compiled afterwards). They make coding easy as I don't have to type the whole "uses BLABLABLA, balbla, secondbla, etc optional bla". Maybe with Bribe's remake of JH will have the solution to this with premade libraries built-in but for now I don't agree.

Debugging easier?
If you know that the imported library works then it's not their fault, it's yours! :)

Still when you upload a spell you always post the requirements or did I get this so wrong?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Scopes are nestable. But neither do I use libraries nor scopes properly, I use structs. As for requirements, I would need to state a lot of them and they may also be subtracted again in the creation process, so I do not really like them. In the end, I would just require everything and that equals with writing everything needed above it.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
@WaterKnight:
You do know that you won't be able to declare private structs/globals right? :p

Well, I do not actually exert privacy at the moment but private globals goes. And I have a form of declaring substructs inside a struct, which could also be turned private if I wanted. To realize this, I utilize scopes but in a distorted way.
 
Well, I do not actually exert privacy at the moment but private globals goes. And I have a form of declaring substructs inside a struct, which could also be turned private if I wanted. To realize this, I utilize scopes but in a distorted way.

I get it now ;)
I just realized that you can declare static variables and assume their your globals :p
 
Hence why I once thought that Luck should be made strictly OOP.

But I rather like the idea of "EVENT_ANY_UNIT_INDEXED" over some ugly garbage like "UnitIndexer.EVENT_INDEXED", so I keep libraries IN.

There are psuedo-scopes that can be used ONLY if nested, that basically act as protectors to localize things to a small area of the library/struct/class.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
But I rather like the idea of "EVENT_ANY_UNIT_INDEXED" over some ugly garbage like "UnitIndexer.EVENT_INDEXED"

Well, I do not think so. The oop forces you to adhere to an order and throughout my projects I have relatively strict name conventions, therefore I got an idea how everything is called. In a container "UnitIndexer", I would not name the variable "INDEXED", as this is redundant.
 
I've been encouraging people to use implicit library requirements rather than scopes with ?? requirements, where applicable. No complaints from any one so far.

Edit:

Well, I do not think so. The oop forces you to adhere to an order and throughout my projects I have relatively strict name conventions, therefore I got an idea how everything is called. In a container "UnitIndexer", I would not name the variable "INDEXED", as this is redundant.

What about EVENT_DEINDEX then? It Looks really bad in the wc3 environment.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
What about EVENT_DEINDEX then? It Looks really bad in the wc3 environment.

Not either.

About the requirements, I do not know. While I agree that this could serve better portability as you upload general systems for others, precisely because these are so general, you usually only have a few conditions that can easily be seen if the user actually took the time to read it, a note in description would be enough. Also you would sort your stuff anyway to avoid a mess.
 
Still you usually write them anyway, I guess you will give me down-points for my future uploads ;D

Anyone should get down points for using scopes in my opinion ;)
It should be a common standard to use libraries instead of scopes honestly.
Bad programming practices should be avoided as much as possible :)
If I were a mod, I would reject not approve a spell if it used a scope, but had no leaks, and was super efficient.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
My solution is to use a proper programming language like C++ or JAVA and stop thinking that scripting JASS will go anywhere.

Scopes are useful, they are the sort of thing you wrap around a map sepecific trigger or system just to avoid the chance of name space collisions.

The problem with using libraries for everything is it defeats the purpose of a library eventually. Libraries are meant to provide you with systems to use in your map. Using them for individual abilities is a bit out of their context as they should only be used for ability engines with scopes for ability type instances.

Currently people make abilities which require total parallelisim to create 2 different types which causes a lot of procedural couplin (near total as you basically have 2 copies of the code). With proper design you could have the basic ability library which controls the mechanics of the ability with abilitiy types declared as scopes that interface with the ability library. This however has no benifit in JASS because of its crappy interpreted nature.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Bad programming practices should be avoided as much as possible :)

There is always a flaw in every program...Libraries might be the upgrade for scopes but that doesnt mean that its bad practice to use them, can you imagine that microsoft has Win7 now but many people are still using Windows98 (well mine is XP), so is it bad?, certainly not...

It's up to the user/coder who will decide on what he will use as long as it's functioning well and not leaking...so I vote for scopes, but it doesnt mean that I will not use libraries...
 

Deleted member 177737

D

Deleted member 177737

I think jass is useless so that's my poll selection.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
When will people realize that OO is a piece of shit in almost every case, ESPECIALLY game development related code.

Read on components and entity systems instead.


There is always a flaw in every program...Libraries might be the upgrade for scopes but that doesnt mean that its bad practice to use them, can you imagine that microsoft has Win7 now but many people are still using Windows98 (well mine is XP), so is it bad?, certainly not...

It's up to the user/coder who will decide on what he will use as long as it's functioning well and not leaking...so I vote for scopes, but it doesnt mean that I will not use libraries...

It's not bad that the users use old and crappy software, it's bad that the developers give a crap about them and go out of the way to make everything work for them.
Hell, even Micro$oft ditched Internet Explorer 6 finally. It took them 10 years.


Scripting in C++ or Java is boring.

Scripting in JASS shows immediate results, in an
environment that people actually enjoy.

It's one thing seeing some dime-a-dozen program
print out some strings.

It's another thing to see some wicked spell come
to life in the WC3 world, knowing that you built
that thing.

While I agree it's very satisfying to see actual results in a matter of seconds, putting graphics on the screen is seen as a way harder task then it is.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
I think jass is useless so that's my poll selection.

Actually the WE is useless without JASS...

:I That's not the point.
Scopes are bad because they make implicit requirements.
They're not lacking, they're just bad :eek:

We are entitled to have our own opinions, as for me it's not bad, it's like making a trigger with waits...waits are not bad if it's single player and for 1 unit only...
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
I'm using Windows XP here as well, I can't stand the visuals and toolbars of Windows 7.

I always wondered what was the difference between scopes and libraries, I guess I know now. But if they're the same with the exception of those implicit requirements plus sending data to the top of the script, why have both in the first place?
 
Level 2
Joined
Jul 7, 2011
Messages
4
In my opinion Scopes must be deprecated because making implicit requirments may pop up syntax error (------> not a good thing) involving non existant functions. Libraries on the contrary make these requirments explicit, so i don't know why some people disagree.
 
In theory, libraries are much better than scopes.
Scopes can be used for spells, but who wants to import a spell if they might end up getting like a hundred syntax errors.

Libraries:
- Explicit Requirements
- Accessible functions from the outside
- Clean
- If errors occur involving non-existent functions, refer to this line:
library YourLib requires optional UnitIndexer, optional AIDS, Event, TimerUtils
- Allow you to make optional requirements

Scopes:
- Implicit Requirements
- Everything is Private
- Ugly (I hate the scope / endscope keywords)
- Potential to cause errors
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Your arguments aren't strong enough because if you take a spell from thw you always consider required libraries that are always shown either in the description or in the map itself. You can do optional in scopes as well, just make static ifs like you do in libraries and if the required library is imported it will compile that code instead of comment it out (or remove it, I'm not so in to static ifs engine). It's meant to be private in a scope as scopes aren't meant to pass code between each other. A system should always be made in a library as it will compile it above the scopes and also if another system needs functions from a system then you can require it to put them in a logical compile order.

Errors? Ain't that what pjass is for, is it not? :) And you can have errors in libraries as well, the way you coded your own part. And pjass always finds "undeclared functions" anyway so it's not that difficult to find the required libraries if you missed the "reading" part of a description :)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Is Aloush95 your smurf?

I agree a bit with a point Dr Super Good mentioned. It makes more sense to use libraries for systems than on end level abilities. This is because you won't require these spells elsewhere and they are too detailed. The worst but also most direct case would be that every function or variable you need to call from outside is independent and comes with a unique requirement. This would create a huge list and these calls would be self-announcing, not to mention that spells easily alter in development. But we also have to differ the use by portability and integrity. I would not adopt an ability from the database into my map anyway, cause most would not work, without adjusting them but you at least have a basic layout how it was meant to be in a "neutral" environment. So I think the ideal of posting things here on the site is not the same of what would be effective to have finally in the map. At least, nobody should take stuff blue-eyedly without checking how it works.

Where are scopes private? You can set the members' visibility as you wish. And I repeat that they are nestable. The only thing that annoys me about the keyword scope is that it looks similar to struct. The hundred syntax errors are no problem, the checker is meant for that and you just have to use your brain and have an ordinary overview of what is the scenario, which you had if you properly sorted your stuff without cross-linking libaries.
 
Your arguments aren't strong enough because if you take a spell from thw you always consider required libraries that are always shown either in the description or in the map itself. You can do optional in scopes as well, just make static ifs like you do in libraries and if the required library is imported it will compile that code instead of comment it out (or remove it, I'm not so in to static ifs engine). It's meant to be private in a scope as scopes aren't meant to pass code between each other. A system should always be made in a library as it will compile it above the scopes and also if another system needs functions from a system then you can require it to put them in a logical compile order.

Errors? Ain't that what pjass is for, is it not? :) And you can have errors in libraries as well, the way you coded your own part. And pjass always finds "undeclared functions" anyway so it's not that difficult to find the required libraries if you missed the "reading" part of a description :)

Documentation is only useful for the API.
I don't have to read a block of text just to know what systems I have to implement and what systems are optional to implement.
Reading something like:
library yourLib requires TimerUtils, GroupUtils, optional AIDS, optional UnitIndexer
makes your life easier :)

And I repeat that they are nestable

When has that ever been useful >.>
 
Level 5
Joined
Jun 30, 2004
Messages
170
I remember Vexorian saying that he wanted people to stop using scopes, too. Although don't go running up to him telling him I said that. >_> "It's a bad programming practice because it makes people lazy in their function naming," is what he said. I paraphrase, though. JassHelper doesn't give me the greatest hint whenever I get syntax errors within a scope. It's driven me mad a few times.

I have a question, though. I'm a little confused as to when a library gets declared. Is it after map initialization, but before anything else outside of it? I'm just worried that my spells will go ballistic because I decided to change everything from scope to library.
 
Although don't go running up to him telling him I said that.

Vex is probably dead anyways :p
He left WC3 modding over a year ago =c

I have a question, though. I'm a little confused as to when a library gets declared. Is it after map initialization, but before anything else outside of it? I'm just worried that my spells will go ballistic because I decided to change everything from scope to library.

Don't worry about that :D
If you change from scopes to libraries and include the requirements, you're not going to get errors involving nonexistent functions.

In fact, I found a new reason why we should avoid scopes: "They don't give JassHelper the needed information to pop up meaningful syntax errors."

Also, look at this:

JASS:
scope
    private function hi takes nothing returns nothing
        call SetTimerData(NewTimer(),5)
    endfunction
    private function hi2 takes nothing returns nothing
        call hi()
    endfunction
endscope

Without TimerUtils, this would pop up errors like:
"hi" is not a valid function name.
 
Level 13
Joined
Mar 16, 2008
Messages
941
Why do you use libraries? Because you're able to "use" them.
There is absolutly no point in using/requiring spells (what scopes are most times) and so I think it's a good thing to differ between them.
The only problem scopes have is that they can't require stuff what CAN cause problems.
However, that is not a problem of scopes but the ppl that use it.
Use comments for this and it's done. I would never code spells in libraries.
 
Why do you use libraries? Because you're able to "use" them.
There is absolutly no point in using/requiring spells (what scopes are most times) and so I think it's a good thing to differ between them.
The only problem scopes have is that they can't require stuff what CAN cause problems.
However, that is not a problem of scopes but the ppl that use it.
Use comments for this and it's done. I would never code spells in libraries.

Not coding them in libraries makes it harder for JassHelper to popup meaningful errors (if any)
 
Because of what? Which important errors should be killed by scopes? In addition, JassHelpers fail should be a reason to remove scopes isntead of fixing it? Well...

Can you give me one good reason why scopes are GOOD?
Libraries make explicit requirements while scopes don't.
I don't care if users can still use comments, you wouldn't gain anything when you use a scope.
Using a library for a spell makes it clear exactly what systems are needed for that spell.

It's not JassHelpers fail, it's the coders..

Scopes.Are.Redundent.And.Bring.No.Good.
 
Status
Not open for further replies.
Top