TorqueScript 2

Scripting questions, discussions, etc
21 posts Page 1 of 3
MangoFusion
Posts: 50
Joined: Wed Feb 04, 2015 12:00 am
by MangoFusion » Thu Oct 29, 2015 7:03 pm
Hey guys,

Anyone hanging around IRC may know I've been working on a rewrite of the TorqueScript VM (codenamed TorqueScript 2) over the past few months, based on the T2D codebase. The rewrite involves changing the bytecode & the interpreter runtime in order to improve runtime performance, as well as paving the way for more useful features.

Why rewrite the VM? The main reason really is its fairly slow compared to modern interpreters (e.g. lua). Another reason is that the way TS manipulates variables makes supporting constructs such as arrays, lua tables, and closures a complete pain.

Some of you may be wondering "why is MangoFusion bothering rewriting TS when we should be using [popular language X]?". The main reason in my case is I have a few projects which rely on TS in the pipeline and it would be more trouble than its worth sticking my feet into someone elses mysterious mess. Also I think embedding another language tends to create too many compromises I'm not too happy with, and they often fall short of supporting everything useful for game development (e.g. serializable coroutines).

At the end of the day, with the exception of a few neat runtime features, TS2 will mostly just be a drop-in replacement for the existing TS vm. I don't have any plans to add in anything too complicated like a JIT or a hand-optimized interpreter since both things would incur a bad maintenance cost as well as make everything harder to compile in.

Also I should stress TS2 is merely the codename, so I will likely designate a new name for it before pushing it out there.

--

Now enough about what TS2 will be. What is it now? Well it can currently parse, compile, and execute bytecode for much of the core torquescript language. The only major language feature I haven't implemented yet is array support, but that should be rather trivial.

I'm currently working on fixing up the console interop so calling methods on objects from c++-land works correctly, which will also allow stuff to boot correctly (up until now I've just been testing it with main.cs basically).

Future plans are to decouple the script code from the rest of the T2D codebase and spin it off into an embeddable project. Because quite frankly, i'm probably nuts.

In any case I will be pushing my TS2-related changes to a branch this weekend, in the hope someone might find it useful.
andrewmac
Posts: 295
Joined: Tue Feb 03, 2015 9:45 pm
 
by andrewmac » Thu Oct 29, 2015 7:07 pm
I'll be merging it into Torque 6 as soon as it's available. It should be an easy transition since Torque 6 isn't script heavy at the moment and hopefully it'll provide good test results for you. Looking forward to it!
Nils
Posts: 164
Joined: Thu Feb 05, 2015 3:32 am
by Nils » Fri Oct 30, 2015 2:53 am
This sounds good @ MangoFusion! :D :D :D
Last edited by Nils on Fri Oct 30, 2015 7:43 am, edited 1 time in total.
chriscalef
Posts: 381
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Fri Oct 30, 2015 3:46 am
Yay, thank you Mango! Just to clarify though, this is in T2D? Is it easy to drop into T3D?
Timmy
Posts: 371
Joined: Thu Feb 05, 2015 3:20 am
by Timmy » Fri Oct 30, 2015 9:19 am
Awesome work mango!
rlranft
Posts: 304
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Fri Oct 30, 2015 3:50 pm
Nice. Another reason to stick with TorqueScript is that there is a ton of example script that is already present and functioning - it doesn't have to be ported and tested in MyCoolScript or whatever. And it makes it easy, therefore, to test the new interpreter - if it breaks it's not compatible....
MangoFusion
Posts: 50
Joined: Wed Feb 04, 2015 12:00 am
by MangoFusion » Sat Oct 31, 2015 9:22 am
@ chriscalef

it's actually based on t3d's scripting implementation (e.g. it has foreach), so it should be reasonably easy to port back across. I'd caution about using it in an actual project until its actually been proven stable of course. ;)

@ rlranft

There's a few differences with how arrays work (which had to be changed to allow for true array support). Besides that everything else is the same.
rlranft
Posts: 304
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Sat Oct 31, 2015 4:59 pm
What did you do to arrays? Make them more like Lua tables? In normal use, how many cases do you figure would break? I mean, right now there are some unorthodox ways to access array members but they're not in general use - it wouldn't hurt if those went away... lol.
chriscalef
Posts: 381
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Sat Oct 31, 2015 5:31 pm
@Mango: sounds good, I can wait but I'm excited that you're working on it!

While we're on the subject of Torque Script though, you wouldn't happen to have done anything re: the floating point precision, would you? I just lost half a day on a bug in my code that turned out to be because of the six digit limit on float values passed from the engine to the console, and while I understand it's for efficiency, I sure would appreciate that value being set somewhere under the control of the user so the tradeoff of efficiency versus precision could be more transparent.

My particular case involved use of lat/long coordinates, where -123.076 is simply nowhere near enough precision. I resolved it for my own case by moving that part of the logic into the engine, where it probably should have been anyway for performance, but all the same, that's a pretty painful data truncation to have just built in to the engine with no easy way to modify it. IMHO.

Thanks again for your efforts!
Steve_Yorkshire
Posts: 316
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Mon Nov 02, 2015 5:59 pm
Also I should stress TS2 is merely the codename, so I will likely designate a new name for it before pushing it out there.
KawaiiDesuSempai Script!
;)
21 posts Page 1 of 3

Who is online

Users browsing this forum: No registered users and 2 guests