With WebGL rolling around, will we be able to do coding in *REAL* JS?

I mean, IL2CPP is fine, but sometimes to get best performance you’d want to use “base” language (JS in this case). This usage of actual JS to script games (don’t mistake with UnityScript that has virtually nothing to do with JS), at least for WebGL platform (I’m okay if it’d be restricted to WebGL target) would make easier to optimize corner cases (this being direct JS, wouldn’t be touched by ASM.js or IL2CPP and would be put verbatim).

1 Like

Is the idea to share events with the browser window or something? Or to just have all your scripts executed at runtime using js files on your site?

I’m certainly no engineer, but I can’t see why you’d want that. AOT compiling has to be faster in all cases, and he headaches involved in executing and relying on files easily editable by the user…

Or maybe I’m just confused as to what feature you’re really looking for here. :stuck_out_tongue:

AOT compiling is faster, unless it isn’t. Sometimes, in corner cases you just have to finetune your code on lower level if you want it to be fast. And I meant “real” js as another Unity scripting option, besides C# and UnityScript (wouldn’t mind if “real” JS would be limited to WebGL only).

Of course when WebAssembly arrives, that’ll be a moot point, but until it does direct JS support would help with some code that just can’t get fast enough with IL2CPP/ASM.js, despite all possible optimizations applied on developer’s side.

If I’m understanding his posts correctly, he wants to bypass .NET.

1 Like

So the idea would be instead of building a compiled application, you’re building something more like an HTML5 app?

What issues are you running into with performance and speed that C# or US can’t handle properly?

There are few corner cases related to AI and physics that makes games on WebGL slow, as you probably know by now. Those could be dealt with, if we could bypass .NET if necessary. On Desktop we can do so with plugins, but of course no such thing on WebGL app. Hence, ability to write JS directly if necessary would be useful. Especially if it’d be handled in Unity workflow on par with UnityScript and C# (attaching to Inspector, etc.), while also being able to execute arbitrary JS code.

I want this because of a discussion from some time ago where users can save their game on their local machine instead of in a browser cache or server. It’s been mostly resolved by that one individual as long as the web portal let’s you customize the page a little, but this would still be nice.

No. At least, not without resorting to the normal methods of interacting with web pages. Basically writing normal JS into your webpage and calling it from your game, or injecting code from your game into the webpage.

In theory you could break into the compiled code and modify it, but my understanding of the build process is this will end up so obfuscated as to make low level optimization almost impossible.

I know about it, but that’s not what I meant.

I’m curious what the real-life situation is behind this. I can’t imagine JavaScript is faster than any other language, .NET does optimizing for you as well.

Yes. But consider this: Unity now does web export the following way: .NET->C++ (via IL2CPP) → ASM.js. There’s gotta be performance loss on that Rube Goldberg’s export path. And it was shown by various demos comparing performance of webgl and webplayer. Sometime writing certain code in JS directly is what you need to optimize your game.

This all may sound like I’m dissing IL2CPP, but I’m not! This is still great tool and I’d use it over writing JS (or C++) directly any day. The problem is that sometimes performance of exported game just isn’t up to snuff, despite every possible optimization on C# side. Then you should be able to just rewrite problematic scripts in JS verbatim, as last resort.

I may be displaying ignorance here but wouldn’t c++ be the language you want to write in, then?

https://www.google.com/search?q=pointer+hell

If I want to do standalone, native app, I’m most likely just to use Lazarus. Sometimes (usually when I’m drunk) I use Qt Creator or Code::Blocks instead and I regret it every single time.

C# just strikes the right balance between easy of use and power, but obviously it’s always important to use right tool for the job. With Rube Goldberg’s export suite sometimes it works reasonably fast, and sometimes it doesn’t despite all possible optimizations done (google demos showing difference in speed between webgl and webplayer) and when it doesn’t I better be able to manually optimize the thing.

Not if you are building to WebGL

1 Like

References in c# are pointers. JavaScript has pointers. They just aren’t called pointers. I haven’t played with C++ in a while, though. I used to find it intimidating. Kind got turned off to it a long time ago.

Can you write the code as a plugin? I forget how this stuff works but if you write plugins aren’t they used as-is so you can use them for specific, more efficient functions?

I like QT so far. It’s GUI programming is meh though.

I teach C++ on the weekends :smile: I don’t know why kids want to learn it these days, but whatever.

What are those corner cases? I can’t help but feel like most games with them wouldn’t be targeting a browser.

1 Like

I don’t want to put words in people’s mouths. But, in my impression, they want to be REAL programmers. Which is fine. There are still development companies that use it exclusively. The longer answer is that they dont yet know how great C# is.

I learned C++ in the 90’s and 20+ years later it is still going strong in many areas such as embedded development. If you were going to pick just one language to become expert at you could do a lot worse and make a lot less money.