1. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  3. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  4. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  5. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  6. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

About C++ with Jass

Discussion in 'Off-Topic' started by GangSpear, Nov 5, 2011.

  1. GangSpear

    GangSpear

    Joined:
    Oct 25, 2009
    Messages:
    971
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Does Jass can combine with C++?Just like the whole game all use jass create unit or else,and copy the jass into the C++ and paste,does it work? :goblin_boom:
     
  2. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,003
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Nope.

    C++ and Jass are 2 very different languages.
    You can't combine both of them.
    C++ compiles to machine code, while Jass remains as simple text.
    It is interpreted by the Jass interpreter.

    Although, the natives:
    native CreateUnit takes player id, integer unitId, real x, real y, real facing returns unit

    native RemoveLocation takes location loc returns nothing

    native DestroyGroup takes group g returns nothing


    are written in C++ inside Warcraft III, it doesn't mean that you could combine them with C++ while coding in Jass.
     
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,099
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Also for security reasons Blizzard activly removes any ability to execute arbitrary machine code from WC3. An example of one which was removed was the type casting exploit being used to convert an integer into a code object.
     
  4. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,003
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I always wondered why stuff like "%USERNAME%" doesn't work :/ (Blizzard is smarter than I thought)
     
  5. GangSpear

    GangSpear

    Joined:
    Oct 25, 2009
    Messages:
    971
    Resources:
    1
    Spells:
    1
    Resources:
    1
    So,the jass is BIG DIFFERENT of C++?
     
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,099
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Your making no sense...

    JASS is an interpreted scripting language. It is increadbly slow and only works in WC3.
    C++ is a programming language that has to be compiled inorder for a processor to run. C++ can work on any processor instruction set as long as there is a compiler available for it.

    This means that JASS is limited to running on x86 compatbile platforms in the program wc3 (which requires a certain Opperating system compatible with it). C++ can be made to run on any processor such as an ARM7 (like the new nvidia tegra), or the PS3's/360 IMB designed cell technology (I think its power PC) as long as there is a compiler for it.
     
  7. Crazed_seal2

    Crazed_seal2

    Joined:
    Jan 5, 2009
    Messages:
    825
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    C++ is compiled into machine code so when it runs the machine can directly read it.

    Jass is compiled into a format that the game can read then this is turned into machine code which the machine then reads. I think thats how it goes.
     
  8. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,003
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    nope.
    It's interpreted.
    Warcraft III is composed of:
    - 70% Jass Interpreter and Functions
    - 30% Game Engine
     
  9. Orcnet

    Orcnet

    Joined:
    Jul 31, 2010
    Messages:
    3,855
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    no you can't combine them both because C ++ is a programming language and Jass is a code text used only for warcraft III

    its like mixing sugar and spice and it won't be very nice
     
  10. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,003
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Actually, if you want, you could code in Zinc.
    It has a C-like syntax:
    (requires JNGP)

    Code (vJASS):
    //! zinc
    library Lib {

        public constant integer OH_HAI = 0;
        public constant string THIS_IS_ZINC = "You have to use the 'public' keyword for something to be accessible outside of this library.";
        constant string THIS_STRING = "is private";
       
        public struct hi[] {
            private constant integer i = 23;
            private constant string s1 = "The private keyword is only used inside structs.";
            private constant string s2 = "This struct extends an array";
           
            static method thisMethodIsAccessibleOutsideTheStruct() {
            }

            // onInit methods don't exist in Zinc.
            private static method onInit() {
            }
        }

        // Only this compiles.
        function onInit() {
        }

        function MoreSyntax(integer i)->boolean {
            integer f = 0;
            unit h = null;
            h = CreateUnit(Player(0), 'u000', 0, 0, 0);
            RemovePlayer(Player(0);

            // this is a for-loop
            // for (init loop; loop condition; afterLoop)
            for (f = 0; f < 10; f++) {}
            // f++    ->    f = f + 1
            if (f==10) {
                BJDebugMsg("f == 10");
            } else {
                BJDebugMsg("f != 10");
                if (f < 10) {
                    // f+=1 => f = f + 1
                    while(f < 10) { f+=1; }
                } else {
                    // f-=1 => f = f - 1
                    while(f > 10) { f-=1; }
                }
            }
            return false;
        }
    }

    //! endzinc


    Hope this helps :3
    The only reason I'd code in a language is because of how I like the syntax :D
    If you like coding in C++, you can use Zinc for Warcraft III ^^
     
  11. Ironside

    Ironside

    Joined:
    Feb 3, 2009
    Messages:
    2,722
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    But wasn't zinc bugged a lot or something?
     
  12. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    476
    Resources:
    0
    Resources:
    0
    Actually he was right. JASS gets compiled to an bytecode format which then is interpreted as the game runs [1].
    And you can see this tutorial [2] as a proof that executing JASS-Bytecode actually worked (oh glorious times back then, before
    hashtable
    and such :).

    [1]: http://www.wc3c.net/showpost.php?p=1076343&postcount=3
    [2]: http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=137116
     
  13. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,099
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    The language is still almost completly interpreted though. These bytecodes act mealy as execution templates for the intrepreter.

    call TestFunction(GetVal(n))
    The call is cached as bytecode I believe. TestFunction then has its bytecode looked up by runing a hashing function on it many times which eventually results in a pointer to its bytecode. GetVal like wise gets hashed many times before getting bytecode for it. Even n gets hashed many times before it can find the bytecode for it. This means that the bytecode generated does not perform any linking at all so JASS relys on runtime name resolution for any form of named argument and hence why it is stupidly slow. It performs many O(n) string opperations on each name and can have to resolve a name many times.

    This is why longer variable names cause the script to run slower.

    This is different from Galaxy script used by SC2 which does perform compile time linking (since it does not seem to use names internally) where the bytecode contains addresses of virtual machine memory and function bytecodes for running the script.
     
  14. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,952
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Why would you even want to use a crappy language like C++ to begin with?
    Also that zinc-whatever doesn't even look like C++.
     
  15. GangSpear

    GangSpear

    Joined:
    Oct 25, 2009
    Messages:
    971
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Thanks guys,so does warcraft III is made from C++?
     
  16. Crazed_seal2

    Crazed_seal2

    Joined:
    Jan 5, 2009
    Messages:
    825
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Yes, Warcraft 3 was programmed in C++.
     
  17. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,099
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    C++ is nothing really more than a language guide line. The actual behaviour of the language varies depending on compiler. Additionally, the object orientated part of C++ can add extra weight in situations where you want optimization meaning you may fall back to C more often than you would like to.
     
  18. SpectreD

    SpectreD

    Joined:
    Apr 4, 2011
    Messages:
    548
    Resources:
    0
    Resources:
    0
    theres nothing much to say.. vjass is completely different from C++, they are different languages