Andromeda - a galaxy extension

Discussion in 'Starcraft 2 (SC2) Editor Help' started by gex, Apr 6, 2010.

  1. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    All I can say is that this makes me want to use SC2 for map editing ^>^.

    Just a quick question on interface and override ; ). I assume they both operate through triggers? I really don't see how they couldn't ; D.

    Only asking this because I assume they removed all pointers, including function pointers ; P.

  2. gex

    gex New Member

    +6 / 0 / -0
    overrides just changes the function call. Interfaces and virtual methods use binary if tables (faster than triggers).
  3. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    I have fallen in love with Andromeda : P.

    Now if only you could do outs and possibly refs. I know in Galaxy they could make pointers very safe by doing refs like in c# ; \. They could just deny unsafe code ; p.

    Also if only enrichments were just extension methods/properties/fields ; |. That just seems to make so much more sense than the current enrich syntax >.<.
  4. SerraAvenger

    SerraAvenger Cuz I can

    +236 / 0 / -0
    Before I'm saying anything else, I have to admit I don't like the Java syntax. I think it's very bloated.
    Based on that, my opinion towards this project is heavily biased.

    I don't like how this tries to blend java syntax with galaxy syntax. I think that there's actually two ways to make a good syntax for a preprocessor language:
    a) make it stick to the compile target syntax
    b) design a completely new syntax

    I liked vJASS because it felt very natural when I came from vanilla JASS, and I liked Zinc because it was a bottom-up attempt to create a formidable syntax experience. While I did have problems with both the Zinc and the JASS syntax, they both felt very integer and natural.

    I don't have that feeling with andromeda. It feels somehow very grotesque. The enrichment feature is cool, but feels very strange. If it is possible to enrich custom classes/structs, then method definitions and stuff are completely redundant. If it's not possible, enrichment seems very inconsistent to me.
    //Private function, galaxy style
    static int a(){}
    //Private function, Andromeda style
    private int a(){}
    Feels very strange to me.

    Implicit casting between text and string is very nice.
    Function overloading is a dangerous playground. I think within your current syntax it is good to have, but I also think it's detrimental to clear code.
    Overriding stuff seems completely wrong to me. It creates incompatible code, plus it doesn't even work as intended.
    "Note that the override keyword has another meaning when being used in methods (class functions)." Two different meanings for the same keyword? Doesn't seem good either.

    About the object inheritance: I don't like that concept. I do love golang's way to deal with structured types. Actually, I do love golang.
    If I had the time to do a preprocessor for golang, I'd probably want to go with a golang-similar syntax. Yeah, I know - golang works completely different from galaxy, so I don't know if actual golang content would be appropriate - but I'm sure that golang syntax would be very effective to use.

    You might want to think about using a golang-interface-like language construct in andromeda though. That was one of the few things I was missing in Zinc.

    Best wishes and a lot of luck with your project, the all-too-unhappy Serra
  5. Lyerae

    Lyerae I keep popping up on this site from time to time.

    +105 / 0 / -0
    I think I agree with almost all of the post above me.
  6. Jesus4Lyf

    Jesus4Lyf Good Idea™

    +394 / 0 / -0
    (@Nestharus) I hope that's a joke. If binary if tables means what I think it does, something like SpellStruct would become O(log(n)) complexity.

    Things being extended by 20 different classes is a reality. But, perhaps even in this circumstance, the binary if tables are faster...

    Furthermore, how can override being implemented by simply changing the function call function like override at all? If a parent class calls a method which is overridden by the child, the overriding variant should be what is called. How can you achieve that if it just changes the call? Surely, it must be dynamic based on what the child class is...

    This bug would cause SpellStruct not to work at all, since it is based on having default do-nothing methods which get overridden, but called from within the parent class (or "struct").
  7. gex

    gex New Member

    +6 / 0 / -0
    Yes, sad but true, but they re still faster. I always prayed for function pointers in my petition, but almost no one agreed that they would be necessary. With function pointers we had super fast O(1) with low constant time.

    Of course I can add a optimization that triggers are used once you get above 64 (that is around the point where they get even) overrides of one function.

    nono, we are talking about different things. Overrides in classes use the binary if tables. I meant native overrides.
  8. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    what about

    I have never heard of an "enrichment" as a feature in any language, including Java >.<.

    I know Java does not have extension methods and it's really only a c# thing, but there are proposals for them all over the place ^.^

    And again, I tried googling enrichment for any language and nothing turned up : (.
  9. gex

    gex New Member

    +6 / 0 / -0
    It is a term from some maths stuff ( for example). We also had "enriched specifications" in some weird formal class at university. This was the first thing that came to my mind :D.

    But yes, they are comparable to C# extension stuff. But I really hate the C# syntax for that.
  10. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    Hm... well I looked through and there are way too many proposed things on how to do Java extension methods and what not...

    enrich is def fugly ; O.

    Well, this is my proposal

    Ignore my :'s, just remembered Java syntax is extends ; D. I'm too used to c# atm : p.
    end edit

    //can extend off of primitive types. type of this is always typeof(base)
    //in this case unit
    class Unit : unit {
    //constructor for point without defining the class
    //primitive types are treated as objects automatically, so
    //can add extension methods without making a class
    public point(real x, real y) : point { return ... }
    //when override used and there is no base, the override is treated as the base, so has no effect ^.^
    //for example, if above method wasn't defined and this was instead, they'd be the same thing
    //in this way, it'll always be a good practice to put override in front of any extension method
    //public override point(real x, real y) : point { return ... }
    //without extending off of a type, type of this is int
    class Boo {
    public int tester(int arg) : Boo {
        return arg+1
    //add sort method to arrays
    public void sort() : [] {
    class Lala {
        //override the extension method it finds in scope
        public override int tester(int arg) : Boo {
            return base.tester(arg)+1
    class Gogo : Boo {
        public override int tester(int arg) {
            return base.tester(arg)+1
    And obviously regular extension methods can just be override or a derivation. No need to extend those as that doesn't really make sense ; D.

    Yea, I don't like the weird extension syntax of c# either, but I think the above is actually good.

    Also I don't know if you did this or not, but for structs it should be like struct extends array in vJASS and for classes it should be what you currently have ^.^.

    Also can you code your own allocation/deallocation methods for classes? Sometimes I use unique allocation like in PlayerManager and TeamManager ;o.
  11. gex

    gex New Member

    +6 / 0 / -0
    Your code snipped just mixes enrichments (or extensions if you wanna call it like that) with classes. An enrichment is NO CLASS. It has no object that backs it up, it just adds methods to something else. Mixing up the syntax hurts my, I admit maybe to formal, brain.

    Having an own syntax makes clear that no object stuff is generated here. Your worst problem seems to be the enrich syntax, i.e. the first line of the enrichment. But does it actually matter if there is class "Unit : unit" or "enrich unit"?

    I think this little detail is just not worth so much discussion ;).

    About own allocation mechanisms: At the moment, this is not possible. Maybe it will come. However, own allocation mechanisms are really barely usable (since the used array allocation is already almost unbeatably fast, so no need for any speedup).
  12. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    I personally cannot use andromeda if it cannot support custom allocation/deallocation because a bit of my stuff wouldn't be able to translate over, one of the big ones being TeamManager ; |.
  13. krainert

    krainert Member

    +10 / 0 / -0
    Just read the specifications, and this is fucking awesome. Good job, gex :thup:
  14. gex

    gex New Member

    +6 / 0 / -0
    v0.1.1 released!

    It fixes MANY bugs and adds interoperability with tools like phyngal.
    Check out the download and changelog here

    tell me, what is this magic allocation method I am missing here? If you can show my why it needs such a special kind of allocation, you might get custom allocation into andromeda faster :).

    thank you :eek:
  15. Sevion

    Sevion The DIY Ninja

    +423 / 0 / -0
    He means giving the user the ability to override an allocation method. I.E.
    class Something
        int allocate()
            //My Own Allocation Stuffs....

    local thistype this
    if free > 0 then
        set free = free - 1
        set this = freed[free]
        //do get freed code
        set this = memory
        set memory = memory + 1
        //do get new code
    //do always code
  16. gex

    gex New Member

    +6 / 0 / -0
    I know what he means, but this is bug prone, since allocation in andromeda also sets the type for the instance (which cannot be done by oneself, since it is a hidden attribute). Even if it was possible, I cannot ensure that a user does it correctly in his allocation. If the class field is set incorrectly virtual calls will call the wrong function and other bad stuff will happen (instanceof will give wrong results for example).

    I know it was possible in vjass. However, can you give me a situation where it is really benefitial? Right now, it has just too many disadvantages compared to the benefits.
  17. SerraAvenger

    SerraAvenger Cuz I can

    +236 / 0 / -0
    Yeah, you see, that's the big flaw in the Java mentality. "No we can't do operator overloading - users can do bad stuff with that" "No we can't allow others to extend this class - they can do bad stuff with that" ... ... ...

    Really, it's so counter productive...
    read this:
  18. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    gex, I think you should crack the whole language open and let people do w/e they want to do and inject wherever they want to inject.

    If they inject into something and bug up their own code, then that's a bug they will have to fix, not you.

    Denying power in anticipation of someone's code bugging up is like denying someone from driving a car because they might get into an accident...

    You work on making sure your portion is bug free and we'll make sure the code we write is bug free.
    • Like Like x 1
  19. gex

    gex New Member

    +6 / 0 / -0
    I get your points. But cannot you just deliver me a scenario where an own allocation is useful? That would really help me.

    I still have much to do with Andromeda and other projects so I have to set priorities to everything I do. An own allocation method has just very low priority since I think there are currently features missing that are more important.

    Yes, that is java mentality. However, I don't know if it is a problem. Maybe it makes java so popular. You cannot mess around with it. In big projects with many people involved, you cannot be sure that everybody does everything right, so the best way to save hours of debugging is to make the language restrictive. However, I do also see the disadvantages of it (I loved to have an own allocation method in java, because java's is so damn slow. 70% of Andromeda's execution time is dedicated to object creation :( ).
  20. Nestharus

    Nestharus o-o

    +83 / 0 / -0
    Just so long as you get it in by like some time in August I'm ok : D.

    Here are some situations-
    Sometimes you may create a handle that stays permanently created for the object. It is created upon new allocation. In these cases, it's important to be able to decipher whether the instance you retrieved was a recycled instance or a new instance. This is best done within the allocation process. I've done this in the Spawn Framework for timers.

    Sometimes allocation is done via a list, stack, or queue, depending on the collection the given object may be part of. This type of specific allocation for specific collections allows fast range allocation and deallocation, plus it takes up less memory.

    Sometimes a relational object (pardon my db terms) may be created for a set of objects using matrix arithmetic (predetermined instance that still runs through a constructor). I've done this sort of thing with alliances between two teams, alliances between two players, spawn to origin relationships, and a few other things I can't think of at the moment. By doing this, I get both the benefit of an array (direct access), and benefit of a linked list (fast iteration).

    I just need to be able to control every inch of code because I work at every level from the bottom allocation to top framework design/code generation. Furthermore, I pretty much write out all my code from scratch as I either don't trust auto generated code or I just don't like it, lol (vjass worthless double free deallocation checks and what not). It'd be nice if you could provide generated code of each feature of your language so I know exactly what I'm working with. I know I tested each and every little thing in vjass to see precisely what was going on ^.^.

    quicko safety rant
    I personally don't like all that extra safety. I say only have safety in debug mode complete with error messages. If code is coded right, safety isn't needed. Only need safety when you are dealing with player input (text commands and what not).

    Safety is just extra fluff that provides false positives.
    end quicko safety rant

    And an interesting question... what would happen if I did this?

    int x
    inline int hi() { return x }
    int hi2() { return x }
    static {
    I assume if it works correctly, it'll throw an error =).

    Other questions about how you intend to finish inline that I can ask later relate to when it copies variables into other variables and when it doesn't. For example, it should only have to copy a variable if it does a write to that variable somewhere in the inlined method. Variables that are only read should not need to be copied ; ).

    Another question. How do you plan to do foreach? for (type var: col) or foreach (type var in col)

    And what are the properties that are going to be used for constructing the loop? I assume next and hasNext following Java? This type of methodology would not work on all collections. For example, I've done collections without a head.

    team 1 allies team 2
    Alliance alliance = new Alliance(team1, team2) //team1*teamMax+team2
    Alliance alliance2 = new Alliance(team2, team1)
    team1.first = alliance
    team2.first = alliance2

    In this case, the heads are not nodes and cannot be nodes as their instance ids may collide with a node instance id. In this way I suggest first, next, and hasNext.

    Now about some very useful vJASS features that might also be useful in Andromeda-
    Will there be a thistype keyword ever? I know it's not in Java or really any language, but it was always very useful. You could just do this for constructors and what not

    thistype() { }
    ~thistype() { }

    Will you be able to declare a thistype this like in vJASS?
    Will you be able to write to the this var? (I know it's normally readonly)

    For specifically inline methods and global args (if Galaxy doesn't get pointers back), will you allow refs and outs?
    If Galaxy never gets function pointers, will you add vJASS style delegate fields as well as delegate properties? This would allow for multi inheritance and easy linking of classes.
    operator overloading (+, -, /, *, ++, --, >, <, <=, >=, ==, [], [,], etc etc)
    array properties?

    As you can see, I'm very curious as to the specifics of your language from features I don't see listed or planned to what kind of code is actually generated and what would happen in specific situations ; D.

Share This Page