This is why I want JavaScript in Torque
by Daniel Buckmaster · in General Discussion · 08/07/2013 (5:23 am) · 52 replies
altjs.org
See that? It's like an extend family of technologies that all work off JavaScript. Languages that compile to JS are the current big thing as far as I can tell. Adding the V8 engine to the core of T3D would not only provide support for writing in JavaScript itself, which as a language has many tradeoffs. It would enable writing your game in any of the fantastic languages that compile to JS, as well as taking advantage of new stuff that targets the V8 engine without being JS at all (Ruby, for example).
Or even insane things like Emscripten which goes from LLVM bytecode to JavaScript. Which is... insane. That means you can write C++, compile it to JavaScript and run it in a browser - or in this case, in Torque3D. Or Lua.
I just thought I'd post this because I found the site and was very impressed. I wish I were able to dedicate some time to actually making this happen; it'd be a massive amount of work, but work that I think would be extremely valuable.
Basically, T3D needs a modern scripting language. The popularity of the internet and browsers as the only universally available interpreting environment means that engines like V8 aren't going away soon, and will continue to receive a lot of attention to both ends (back and front). That's why I recommend JavaScript.
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
08/07/2013 (10:14 am)
Thanks Steve, been a while since I laughed so hard.
#3
Oh and that face is really scary Steve :o)
08/07/2013 (10:28 am)
JQuery is enough argument for me NOT to use JavaScript. I use it when I must and no more during website development or plugin hacks, but their is NO WAY I use that nasty script language for scripting in a great engine like Torque.Oh and that face is really scary Steve :o)
#4
08/07/2013 (10:36 am)
JavaScript... ewww, don't they have a shot at the health department for that? ;)
#5
Realize V8 JIT is x86 only.
To replace the language in TS:
Convert all variables that are strings to use Jame's native variable implementation and port that class to the VM.
Rewrite the Con:: namespace to be specific to the VM.
Modify the TS function macros to create VM specific bindings to the C++ code.
Rewrite TS functions as necessary to match any VM specific needs.
Rewrite the entire TS code base to use the new language.
Lay on the ground in anguish as Packages are not supported in other languages and rewrite that code to be less TS centric.
Wonder why you don't have a game written and it is now 2016 and the president is running for a 3rd term.
To tack on a language in parallel to TS:
Use the console interface API in T3D.
For reference:
www.swig.org/compat.html#SupportedLanguages
Honestly we should write an entirely new game engine is this ultra fast language that is way closer to the metal than C/C++. It is called "assemblery". Better than fried spam or the Elvis sandwich.
08/07/2013 (12:15 pm)
I see a whole lot of talk about replacement of TS, but not a whole lot of doing...Realize V8 JIT is x86 only.
To replace the language in TS:
Convert all variables that are strings to use Jame's native variable implementation and port that class to the VM.
Rewrite the Con:: namespace to be specific to the VM.
Modify the TS function macros to create VM specific bindings to the C++ code.
Rewrite TS functions as necessary to match any VM specific needs.
Rewrite the entire TS code base to use the new language.
Lay on the ground in anguish as Packages are not supported in other languages and rewrite that code to be less TS centric.
Wonder why you don't have a game written and it is now 2016 and the president is running for a 3rd term.
To tack on a language in parallel to TS:
Use the console interface API in T3D.
For reference:
www.swig.org/compat.html#SupportedLanguages
Honestly we should write an entirely new game engine is this ultra fast language that is way closer to the metal than C/C++. It is called "assemblery". Better than fried spam or the Elvis sandwich.
#6
I think that the constitution would need to be changed then. Two terms and you are out.
08/07/2013 (12:59 pm)
Quote:Wonder why you don't have a game written and it is now 2016 and the president is running for a 3rd term.
I think that the constitution would need to be changed then. Two terms and you are out.
#7
08/07/2013 (1:03 pm)
dailycaller.com/2013/01/06/new-york-congressman-introduces-bill-to-abolish-presi...
#8
Thanks for the link :o)
08/07/2013 (1:07 pm)
Woooooooooooooooh WTF. That was unexpected and new(well perhaps not after reading the article). Thanks for the link :o)
#9
My friend who is a little bit in contact with things unseen had a vision before 2008. The vision included the now president entering his 3rd term in office and shortly there after massive storms. It was a disturbing vision. Then during the first term many people in, I assume the progressive groups, started talks of getting rid of presidential term limits. Was it a warning? I have no idea.
Also, last year there was the starting of the impeachment process for the president. That process was shut down by the Republicans. So some people have conjectured that the coup to seize the government has already occurred.
Anyway, Lua rocks!!! Lets replace washington dc politics with it. It will be a dirty process, and make a lot of people mad, but be more effective.
08/07/2013 (1:35 pm)
What an even stranger WTF?My friend who is a little bit in contact with things unseen had a vision before 2008. The vision included the now president entering his 3rd term in office and shortly there after massive storms. It was a disturbing vision. Then during the first term many people in, I assume the progressive groups, started talks of getting rid of presidential term limits. Was it a warning? I have no idea.
Also, last year there was the starting of the impeachment process for the president. That process was shut down by the Republicans. So some people have conjectured that the coup to seize the government has already occurred.
Anyway, Lua rocks!!! Lets replace washington dc politics with it. It will be a dirty process, and make a lot of people mad, but be more effective.
#10
Most of my dislike for them comes from the fact that they're a stack, which makes no sense for the way they're used. If I activate a gameplay package and then a user interface package that both need to use onStart, the UI package calls Parent::onStart()... which calls the function in the gameplay package. Why is the gameplay package the parent of the UI package? I don't know. Do you? I don't. Do you? I don't. Do you?*
The point is to 'outsource' the work, if you will, of providing a fast VM that supports a modern, popular programming language that will make it easier for new developers to jump aboard, give them experience in a language they may actually use outside Torque development, and actually make development easier for everyone.
Of course, there are many candidates for this. Lua is probably my second-favourite at this point, and my third is using Lisp via SWIG. (I'm only half serious about that :P.) But having worked intensively with JavaScript over the last year, I've found it to be a fantastic language with even better replacements (particularly, CoffeeScript).
*I see you did not appreciate my tasteful and hilarious reference.
08/07/2013 (3:30 pm)
Nice one, Steve ;P. EDIT: Actually, I've started to use TS a bit more for this prototype for Lukas, which is basically entirely TS. I've come to appreciate it a bit more. You know, a bit more than utter disgust ;P.Quote:JQuery is enough argument for me NOT to use JavaScript.Care to elaborate? I'm just interested, and in any case you needn't worry. jQuery is for dealing with HTML documents, so it really wouldn't be relevant for Torque. I've found it a real pleasure to work with jQuery actually.
Quote:I see a whole lot of talk about replacement of TS, but not a whole lot of doing...Acknowledged. I guess I started this thread as more of a PR campaign - before anyone cares about implementing JS in Torque, they have to care about JS! I'm just evangelising the language for now. Actual work will come when I can do it :P.
Quote:To replace the language in TS:I'm aware of the amount of work that would have to be done! It's pretty insane, really. Like you were talking about somewhere else, it'd be very important in any sort of work like this to try and make the new console more easily replaceable, and not let its grimy fingers get all through the rest of the engine, like TS is currently.
Quote:Lay on the ground in anguish as Packages are not supported in other languages and rewrite that code to be less TS centric.I'd like to have this discussion actually. IMO packages are a terrible feature and need to die; I'd embrace porting that code away from such a weird paradigm.
Most of my dislike for them comes from the fact that they're a stack, which makes no sense for the way they're used. If I activate a gameplay package and then a user interface package that both need to use onStart, the UI package calls Parent::onStart()... which calls the function in the gameplay package. Why is the gameplay package the parent of the UI package? I don't know. Do you? I don't. Do you? I don't. Do you?*
Quote:To tack on a language in parallel to TS:That's interesting and something I should look into more (including your work with SWIG). Is there a chance we'll see ScriptT3D on GitHub any time?
Use the console interface API in T3D.
Quote:Honestly we should write an entirely new game engine is this ultra fast language that is way closer to the metal than C/C++. It is called "assemblery".I appreciate the humour, but not its target. The implication is that replacing TS with JS is as ridiculous as wanting to use assembly. Which it's not. And my arguments have never been about being 'close to the metal' - if that were the goal we could easily rip the console right out and do everything in C++ (and inline assembly ;)).
The point is to 'outsource' the work, if you will, of providing a fast VM that supports a modern, popular programming language that will make it easier for new developers to jump aboard, give them experience in a language they may actually use outside Torque development, and actually make development easier for everyone.
Of course, there are many candidates for this. Lua is probably my second-favourite at this point, and my third is using Lisp via SWIG. (I'm only half serious about that :P.) But having worked intensively with JavaScript over the last year, I've found it to be a fantastic language with even better replacements (particularly, CoffeeScript).
Quote:Wonder why you don't have a game written and it is now 2016 and the president is running for a 3rd term.It's been seven years and I haven't made a game yet... I see no reason to start now! ;)
*I see you did not appreciate my tasteful and hilarious reference.
#11
I imagine something like MIT related "as is law".
Gotta make sure that even the software users implementing this stuff in robots understand what a free man means ;o) Will make me sleep better by night.
You see that is why JavaScript won't do. As soon as some nasty browser update it self nasty date pickers etc won't work. With JavaScript in use it could suddenly start to misunderstand how a set of rules would work... eeek :o)
Why do I feel like some kind of sign with "G'wn begone with you Git something" from Perry will smack inn if we continue this trend :o)
Oh and Python rooocks! It have been used in Minions Of Mirth.
Ah alas TorqueScript is the King, the only language you will need to know :o)
08/07/2013 (3:32 pm)
Fine with me as long as you keep the very fine Constitution and you declaration of independence you have intact in some kind of readme.txt in the software made with the Lua script planed to use for replacing politics with :o)I imagine something like MIT related "as is law".
Gotta make sure that even the software users implementing this stuff in robots understand what a free man means ;o) Will make me sleep better by night.
You see that is why JavaScript won't do. As soon as some nasty browser update it self nasty date pickers etc won't work. With JavaScript in use it could suddenly start to misunderstand how a set of rules would work... eeek :o)
Why do I feel like some kind of sign with "G'wn begone with you Git something" from Perry will smack inn if we continue this trend :o)
Oh and Python rooocks! It have been used in Minions Of Mirth.
Ah alas TorqueScript is the King, the only language you will need to know :o)
#12
Well I have never used Torque in a web browser, but I seen some issues when a browser like Internet Explorer update it self. I have had issues with outdated JQuery datepickers that made date picker and other stuff like that stop working without warnings(hence also due to some old wordpress plugins who needed newer JQuery packs from the official website) on commercial websites that I had to update and fix. In other words some of the Widgets can annoy me a bit when stuff have to work out in many different types of browsers on older websites ;o)
So if any of it is going to rely on the browser itself it can be messy over time. Just saying from my experience with JavaScript and wordpress plugins(php). Oh forgot to add that forcing browers into compatible mode helps out sometimes.
Hence I prefer not to use it if I had to make a game in a browser(However, never done it).
Now beside that I have been stuffed with Java syntax from the traditional CS classes until I had enough back then(not the same but still).
I guess I am traumatized :o)
CoffeScript? :o) Nice.
08/07/2013 (3:45 pm)
Quote:Care to elaborate? I'm just interested, and in any case you needn't worry. jQuery is for dealing with HTML documents, so it really wouldn't be relevant for Torque.
Well I have never used Torque in a web browser, but I seen some issues when a browser like Internet Explorer update it self. I have had issues with outdated JQuery datepickers that made date picker and other stuff like that stop working without warnings(hence also due to some old wordpress plugins who needed newer JQuery packs from the official website) on commercial websites that I had to update and fix. In other words some of the Widgets can annoy me a bit when stuff have to work out in many different types of browsers on older websites ;o)
So if any of it is going to rely on the browser itself it can be messy over time. Just saying from my experience with JavaScript and wordpress plugins(php). Oh forgot to add that forcing browers into compatible mode helps out sometimes.
Hence I prefer not to use it if I had to make a game in a browser(However, never done it).
Now beside that I have been stuffed with Java syntax from the traditional CS classes until I had enough back then(not the same but still).
I guess I am traumatized :o)
CoffeScript? :o) Nice.
#13
Also JavaScript has nothing to do with Java. They just called it that because Java was trendy at the time and JS uses curly braces - like Java, C, and TorqueScript.
I just had an idea. What if we do what Emscripten did and write an LLVM backend that outputs TorqueScript?
...now I'm just being silly :P.
EDIT: Frank, I'm going to get serious about trying ScriptT3D at some point in the very near future. Like, maybe today. We'll see :P.
08/07/2013 (3:59 pm)
Ok, what I'm advocating has nothing to do with browsers. Search for the V8 engine - among others, it's just a JavaScript engine. No browser required. It just interprets JavaScript.Also JavaScript has nothing to do with Java. They just called it that because Java was trendy at the time and JS uses curly braces - like Java, C, and TorqueScript.
I just had an idea. What if we do what Emscripten did and write an LLVM backend that outputs TorqueScript?
...now I'm just being silly :P.
EDIT: Frank, I'm going to get serious about trying ScriptT3D at some point in the very near future. Like, maybe today. We'll see :P.
#14
Sorry man, I was not trying to trash your idea. If you decide to take this up I will help you with it. Like you I just cannot take it up right now. Too big and too complicated. I do have a very big interest in compilers and at some point I want to experiment with converting TS to JS and Python as targets. This would go a long way to making a new VM feasible. It is just a LOT of work to replace the existing TS considering the editors and other important support code.
- No I don't think JS in Torque is ridiculous. It is a very good idea to leverage the work of Google or Mozilla.
- I think careful planning with class structures could easily emulate any kind of package paradigm.
- I very much like JS as a technology. It works very well for dynamic webpages and I have leveraged it along with JQuery for my customers to with great results.
So again, if I ruffled feathers on this I am sorry.
JQuery might be useful if you define a DOM for the engine.
After using Lua in a Minecraft mod called ComputerCraft I do agree it would work, but after using other languages I am not a fan. I am too spoiled by abstraction and string tools other languages provide.
08/07/2013 (4:05 pm)
@dB,Sorry man, I was not trying to trash your idea. If you decide to take this up I will help you with it. Like you I just cannot take it up right now. Too big and too complicated. I do have a very big interest in compilers and at some point I want to experiment with converting TS to JS and Python as targets. This would go a long way to making a new VM feasible. It is just a LOT of work to replace the existing TS considering the editors and other important support code.
- No I don't think JS in Torque is ridiculous. It is a very good idea to leverage the work of Google or Mozilla.
- I think careful planning with class structures could easily emulate any kind of package paradigm.
- I very much like JS as a technology. It works very well for dynamic webpages and I have leveraged it along with JQuery for my customers to with great results.
So again, if I ruffled feathers on this I am sorry.
JQuery might be useful if you define a DOM for the engine.
After using Lua in a Minecraft mod called ComputerCraft I do agree it would work, but after using other languages I am not a fan. I am too spoiled by abstraction and string tools other languages provide.
#15
08/07/2013 (4:07 pm)
Quote:LLVM backend that outputs TorqueScriptSmally suggested this a while back. I think if that is a direction that was taken we would get some help for that. I really have no clue as to how to approach LLVM as I have not taken a look at it seriously at all.
#16
Well that can make me more relaxed. Also I shall sure check it out :o)
That I put clearly in my post above so here we agree. But Java or JavaScript is still all the same fit for me. Java's JSwing API(horrible) or JavaScript's JQuery(nasty widgets) etc. I do not find any of them nice to work in.
Also the syntax annoys me. Also curly braces or not is really not the problem(it is more the way the syntax and say the pointer works(for Java) that pisses me off). I prefer a language more oriented toward the C family.
Now don't tell me that JavaScript is that(then all languages can be said to be that). :o)
Call me biased :o)
Edit: Oh and I am not saying your idea is bad. The more tools the better of course as people are different and hence choose different tools to work with :o)
Edit, edit: Just checked the link above --- Never thought that would be so many different scripts/dialects of JavaScript :o/
08/07/2013 (4:13 pm)
Quote:Ok, what I'm advocating has nothing to do with browsers. Search for the V8 engine - among others, it's just a JavaScript engine. No browser required. It just interprets JavaScript.
Well that can make me more relaxed. Also I shall sure check it out :o)
Quote:Also JavaScript has nothing to do with Java. They just called it that because Java was trendy at the time and JS uses curly braces - like Java, C, and TorqueScript.
That I put clearly in my post above so here we agree. But Java or JavaScript is still all the same fit for me. Java's JSwing API(horrible) or JavaScript's JQuery(nasty widgets) etc. I do not find any of them nice to work in.
Also the syntax annoys me. Also curly braces or not is really not the problem(it is more the way the syntax and say the pointer works(for Java) that pisses me off). I prefer a language more oriented toward the C family.
Now don't tell me that JavaScript is that(then all languages can be said to be that). :o)
Call me biased :o)
Edit: Oh and I am not saying your idea is bad. The more tools the better of course as people are different and hence choose different tools to work with :o)
Edit, edit: Just checked the link above --- Never thought that would be so many different scripts/dialects of JavaScript :o/
#17
08/07/2013 (5:16 pm)
Why not just Java?
#18
pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-co...
My main issue:
- Boilerplate code that requires an IDE that supports Java to create that code. This is pure evil.
I have programmed in Java, in fact I really liked it at the time, now I cannot live without abstraction that Java does not provide.
08/07/2013 (5:50 pm)
Quote:Why not just Java?I am going to hurt someone...
pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-co...
My main issue:
- Boilerplate code that requires an IDE that supports Java to create that code. This is pure evil.
I have programmed in Java, in fact I really liked it at the time, now I cannot live without abstraction that Java does not provide.
#19
08/07/2013 (5:52 pm)
For the record if ANYONE decides to take on adding a programming language I will help them. I may not be able to dedicate a lot of time, but I have an interest in this area and I know this is a pain in the butt. I know the hot coals someone has to crawl over to make this work. So look me up if/when you need help.
#20
As for why I personally didn't want to implement Java (as opposed to why I feel it's a bad idea for everyone): it's verbose and makes you write boilerplate like repeated type declarations. And it straitjackets you into an OO paradigm that isn't always useful. And it doesn't seem to do modern features like anonymous functions/closures... that may just be my unfamiliarity with the language.
Frank: no harm done mate, I did respond a bit strongly! I guess I'm a bit tired of the (gentle) joking that goes on when someone suggests that an alternative to TS might be a good idea. I'd prefer this thread to be about the benefits of JavaScript as a choice rather than the implementation details - those are important, but only at the point where there's sufficient acceptance of a language for people to start seriously putting it in place.
Dwarf King: I don't know, for a scripting language I think it's important to move away from C responsibilities like memory management and pointers.
But yeah, the sheer variety of JavaScript stuff people are working on is fantastic. My favourite so far is PogoScript, which looks like this:
08/07/2013 (7:42 pm)
Richard: what Frank said. Java isn't really designed for rapid development/prototyping, whereas dynamically typed languages like Python/JS are. If Java could do type inference it'd be a step in the right direction; as it is, it's basically relegated to enterprise development where there are large existing commercial codebases.As for why I personally didn't want to implement Java (as opposed to why I feel it's a bad idea for everyone): it's verbose and makes you write boilerplate like repeated type declarations. And it straitjackets you into an OO paradigm that isn't always useful. And it doesn't seem to do modern features like anonymous functions/closures... that may just be my unfamiliarity with the language.
Frank: no harm done mate, I did respond a bit strongly! I guess I'm a bit tired of the (gentle) joking that goes on when someone suggests that an alternative to TS might be a good idea. I'd prefer this thread to be about the benefits of JavaScript as a choice rather than the implementation details - those are important, but only at the point where there's sufficient acceptance of a language for people to start seriously putting it in place.
Dwarf King: I don't know, for a scripting language I think it's important to move away from C responsibilities like memory management and pointers.
But yeah, the sheer variety of JavaScript stuff people are working on is fantastic. My favourite so far is PogoScript, which looks like this:
sing (n) bottles of beer on the wall =
if (n > 0)
console.log ((n) bottles of beer on the wall)
sing (n - 1) bottles of beer on the wall
(n) bottles of beer on the wall =
"#((n) bottles) of beer on the wall, #((n) bottles) of beer.\n" +
"Take one down, pass it around, #((n - 1) bottles) of beer on the wall."
(n) bottles =
if (n == 0)
"no bottles"
else if (n == 1)
"1 bottle"
else
"#(n) bottles"
sing 99 bottles of beer on the wallFunction parameters anywhere in function names! It's fantastic!
Associate Steve Acaster
[YorkshireRifles.com]