Modding Requests from SupCom Modders

Discussion in 'Planetary Annihilation General Discussion' started by KNight, August 19, 2012.

  1. tpapp157

    tpapp157 New Member

    Messages:
    27
    Likes Received:
    1
    This was one of the main things I felt Supcom was missing. The destroyers that walked on land were so cool but they were the only unit that did anything like that.
  2. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    No, they were not. There were also hovering units which were also all terain. But thats not the point of this topic, please make a new toppic if you whish to discuss this.
  3. ghargoil

    ghargoil New Member

    Messages:
    312
    Likes Received:
    8
    I'd say that the two most sensible languages would be Python or JavaScript:

    • Both are embeddable
    • Both are popular, widespread languages; many interested modders won't have to learn a new language and read through its documentation before getting into the thick of it
    • Python is probably among the easiest languages for beginners to learn
    • JavaScript is so pervasive everywhere that it's likely anyone who has done some coding has seen or worked with it, and its syntax is similar to C/C++/Java/C# etc...
    • Both are multi-thread capable (Python has to be Stackless python or PyPy, or done such that there's a new interpreter for each thread to bypass the GIL, and apparently SpiderMonkey requires a new interpreter per thread too...)
    • Both have existing and on-going projects as well existing ones involving sandboxing: exec in scope, RestrictedPython, Python Sandboxing, Google's Caja Project, and this paper on JavaScript isolation come to mind
    • Both have a couple of JIT/Compiled-code alternatives: PyPy (which supports threading) and Shedskin (which takes legit python code and translates it into C++ code) -- Note that I am unfamiliar with JavaScript embedding and/or compilation, but it looks like SpiderMonkey from Mozilla is both thread-safe and performs JIT compilation
    Last edited: August 26, 2012
  4. thygrrr

    thygrrr Member

    Messages:
    252
    Likes Received:
    1
    Yes, Javascript has actually matured into a pretty versatile, pretty widespread thing.

    Don't forget stackless python, which offers microthreads which is actually what you want in games.It's used heavily in Eve online.

    And PyPy isn't too shabby, either.
    Last edited: August 26, 2012
  5. ghargoil

    ghargoil New Member

    Messages:
    312
    Likes Received:
    8
    By the way, good posts in general -- sorry if I haven't responded specifically to them, I felt that I agreed with them more or less, and there was no need to :p
  6. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Multithreading in Javscript? Since when?

    It is still a pure event driven language which allows to resolve several events "in parallel", but there are no synchronisation features and every javascript engine i know runs on a single core only. And those who don't (say hello to IE) create race conditions because Javascript has no methods for thread synchronisation. Especially SpiderMonkey resolves events only one at a time to prevent race conditions, which means that there is no parallelism at all.

    So far only two languages with real threadsupport have been suggested: C# (or any other .Net-language, they are all interexchangeable since they only differ in notation but not in scope) and Python.
    Last edited: August 26, 2012
  7. RaTcHeT302

    RaTcHeT302 Guest

    I'm trying to get into Lua as a starting language, I also made my first basic house in Maya, yay (mediocre stuff for others, a huge baby step for me).

    Now I have to learn more about the extrude tool, faces, sides and other stuff.

    Anyway, is Lua the most reliable for modding? Or are there much better languages wich we can use?
  8. thygrrr

    thygrrr Member

    Messages:
    252
    Likes Received:
    1
    Yeah. I concede that point.

    Wow I didn't know you were clued in so much about compilers/back ends! Respect. :geek:

    I think, however, that you don't need the fastest coolest backend to run decent scripting in a game. You need decent lightweight concurrency, and things like stackless python or in particular pypy offer that.

    As for AI code, better algorithms (Hoare is my hero) beat better compilers.

    PS: Did I mention PyPy supports powerful sandboxing measures? I'm not sure if their windows implementation is spotless, though. Seems like they are still stuck with VCRT 2008, and 32bit. But this might just be their binary distro - MacOS and Limux ports are 64bits already.

    I developed too much on Macs and iOS recently. I am kind of out of the loop on Windows tech post 2009.
  9. ghargoil

    ghargoil New Member

    Messages:
    312
    Likes Received:
    8
    Looks like you have to run a separate JS Runtime (like Python) per thread in SpiderMonkey now. Other than that, you can still run threads for JavaScript.

    That, and extensions for Google V8 support threading.

    C# is not an interpreted language, and it's already been confirmed that binary mods will not be supported.

    ... so this brings us back to Python and JavaScript.

    Edit, missed some new posts:

    I would recommend Python 2.x as your first scripting language.

    Nice, I haven't tried out PyPy personally, but there's a good chance I will in the near future.
  10. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Yes, C# produces binary (to be more precise it's only bytecode, not native assemblies!), but .Net has also some advanced sandboxing features via the AppDomain model. And when i'm talking about C#, then i mean only the managed part of this language where the whole application runs in the CLR VM. No untrusted C-code and no inline-assembler. The AppDomain-model allows you to prevent access from almost everything without loosing the (for a VM) outstanding performance of .Net.

    The multithreading attemps for JS you posted are not flawless. Still no thread synchronisation (or even no thread communication at all, not even shared memory for SpiderMonkey) and the V8 mod is also quite funny as it just emulates threads while the whole V8 engine ist still only singlethreaded, it also lacks basic features like preemption.
  11. martindevans

    martindevans New Member

    Messages:
    14
    Likes Received:
    0
    out of Python, lua, javascript or C# my vote personally goes to C#. It's going to be executing quite a lot faster than the other options and has great support for multithreading (threads, Tasks, async, PLINQ - choose your poison :roll: ). So for a powerful modding API C# is imo a clear winner (of those suggested so far)

    That said, I'm developing a game (written in C#) designed to be extremely moddable and I'm not using C# for the scripts. Why? Because it's a pretty complicated language to learn and so having a pure C# API does add a requirement for modders to know a fair bit about coding and not just starting out with "(Lua|Python|Javascript) for Dummies". Of course, you might consider a barrier between total newbs and modding PA a good thing for code quality :lol:

    So if we want a simple modding API, you probably need to pick one of the scripting languages suggested. My personal pick would be Lua, but that's just my personal opinion of it's beautiful minimalism really. I definitely wouldn't pick javascript, python has a larger standard library of useful tricks, lua is more minimal, and javascript has a lot of gnarly corners :(

    Personally given the choice now, for such an active comunity as PA, I'd pick a powerful modding API and if a simple one is needed then a scripting interface for a new language can be written within the existing powerful-but-complex scripting system, the inverse obviously does not apply!
  12. ghargoil

    ghargoil New Member

    Messages:
    312
    Likes Received:
    8
    Someone with more experience with Linux can clarify, but my experience with .NET and Mono on Linux was pretty awful. While the language itself may be an improvement on Java, its cross-platform support is not.

    Obviously, the closer you get to machine code, the faster your benchmarks will be on average. Given that it's unlikely that mods are going to be doing heavy number crunching, I don't really see a big advantage to this.

    Unless Uber is going to go with a .NET engine to begin with, I would not be very excited to see a .NET based modding system.

    And, really, anything that can be done in C# can be done in any proper scripting language.

    Being able to write in a more 'difficult' language doesn't mean you get "better code". (whatever that means)

    Lua is minimalistic and has a smaller footprint than Python (I don't know how it compares with JavaScript), but other than that, it's not as mainstream, popular, or pervasive as JavaScript or Python.

    The 'powerfulness' of a modding API has pretty much nothing to do with the selection of these languages and everything to do with how Uber designs the modding API... because it's their modding API. Apart from that, cross-platform capabilities are needed, as well as proper sandboxing.
  13. KNight

    KNight Post Master General

    Messages:
    7,681
    Likes Received:
    3,268
    I'd love this too, just make sure it applies across all unit types, not just the select few.

    Mike
  14. RaTcHeT302

    RaTcHeT302 Guest

    Ok, thanks.
  15. mrwonko

    mrwonko Member

    Messages:
    39
    Likes Received:
    0
    Why would you prefer 2.x over 3.x? Sure, ideally you'd know both since you'll run into both in practice, but I'd go for the newest one first. That said, there are not that many differences as far as a beginner is concerned.

    Most reliable... That's one of those "which is best" questions, which tend to turn into huge discussions such as the one you're witnessing. It's perfectly fine for modding, but so are some others. I'd actually agree that for learning a language Python may be better suited, but there's nothing wrong with Lua.

    Yup. :)

    It's quite widespread in games though, so chances are modders have had contact with it. It's not particularily hard either - sure, you need to wrap your head around metatables, but besides that... As far as I'm concerned Lua is one of the most mainstream embedded languages, it's just rarely used as a standalone language.
  16. DeadMG

    DeadMG Member

    Messages:
    217
    Likes Received:
    8
    I checked out the Stackless stuff in PyPy. Holy ****, that's an arcane and terrible threading API. In comparison to something like TBB or PPL, you'd spend a thousand times longer trying to get decent concurrency.
  17. martindevans

    martindevans New Member

    Messages:
    14
    Likes Received:
    0
    I've not tried mono personally, but I have heard that they've taken significant steps forward recently. That's certainly something important to look into though.

    Well, yes... but C# is pretty far from machine code!

    Mods can be doing heavy number crunching too, I'm sure when Sorian is writing an AI mod he'll appreciate a fast language with solid concurrency support ;)

    Anything that can be done in any language can be done in any other. But that's not practically true or useful to say. C# has some excellent support for data processing which is a paint to duplicate in other languages for example. This is the kind of stuff that makes some tasks a lot easier and generally ends up with messy code otherwise.

    Lua isn't used as a standalone language very often, but in the games industry it's almost the de-facto standard for scripting!

    In the words of the game developer magazine, when they awarded lua the award for best programming tool of 2011:
    Lua has become an extremely popular programming language, so much so that it's achieved a critical mass of developers in the game industry, meaning Lua skills are transferable from company to company.

    It's a mix of both, if uber don't expose enough capabilities through the API then it's not very capable, if they pick a bad language then it's not very useful.

    tl;dr imo for a scripting system C# > Lua > Python > Javascript
  18. stanhebben

    stanhebben New Member

    Messages:
    30
    Likes Received:
    0
    What about Java? In the end, that's what Android is using, so it certainly has proven its value. And it might be easier to use it on different platforms while keeping everything secure. It's got great free IDEs and the JVM can be embedded into a larger application - and on multiple platforms - without too much trouble.

    It doesn't differ that much from C# in terms of speed, but Java just seems more platform-independent to me. And it also seems like Java's security model is simpler, making it easier to create sandboxes in it.

    Either way, what's most important to me is a solid architecture, good structure of the code they write and good documentation (or at least, good clarity in their code so we can see what's happening) no matter the language they are using.

    I also prefer a statically typed, structured language over languages that allow you to do strange stuff. This may offer less flexibility but it also means there are fewer ways to do unexpected things. It just requires people to write things properly.

    Yes I have browsed the SupCom Lua code at the time while knowledge about it was still limited...
  19. ghargoil

    ghargoil New Member

    Messages:
    312
    Likes Received:
    8
    The 2.x series is currently more widespread and supported than the 3.x series. As they're extremely similar, you could easily learn the differences once you knew one or the other... but it'd probably be easier to start with the one with more examples and more support (both from community, as well as companies, as well as libraries).

    Yeah,that's what I meant; outside of embedded scripting, it's not really used. On the other hand, Python is used widely outside of embedded scripting and it is used in embedded scripting.

    --

    Re: Mono vs. Java

    If I had to take a pick of which one I disliked [personally] less, it'd be Java. It's supported and runs well on all OSes, and it's a very mainstream language.

    I don't know anything about sandboxing in Java or C#, so I can't comment on that.

    While it's theoretically possible to sandbox arbitrary compiled code, it's neither practical nor provides adequate granularity for control. I don't know where either of these fall in respect to that.

    Edit:

    Also, I think the discussion of Java/C# vs. scripting languages is moving away from the point of a scripting language for modding / game-logic: [very] high-level programming with ease.

    Neither Java nor C# are as high level as these scripting languages, though a case could be made for an alternative to Java, Scala.
  20. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    this

    While I would welcome Java as the language of choice for mods -it is basically my native programming language-, I dont think either C# or Java are suited for this.
    They are both way too typesafe to go as script-languages. Also they usually need to be compiled.
    reptarking likes this.

Share This Page