• 🏆 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!

About C++ with Jass

Status
Not open for further replies.
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.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
So,the jass is BIG DIFFERENT of C++?
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.
 
Actually, if you want, you could code in Zinc.
It has a C-like syntax:
(requires JNGP)

JASS:
//! 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 ^^
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
nope.
It's interpreted.
Warcraft III is composed of:
- 70% Jass Interpreter and Functions
- 30% Game Engine

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
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
Actually he was right. JASS gets compiled to an bytecode format which then is interpreted as the game runs [1].
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.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
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.
 
Status
Not open for further replies.
Top