[THANKS] Javascript is great, but any potential for adding .NET library functions?

1 favourites
From the Asset Store
Customize the animation of character when item changed
  • The addition is Javascript is awesome and opens the door partially for some advanced coding options. But the one boost Unity has over Construct is the ability to script in .NET C# language which is much more powerful than JS.

    While I wouldn't expected C3 to support another actual scripting language, it would be awesome if we could develop libraries in .NET (which has portable versions for Android, iOS, Mac, Linus and of course PC) and be able to consume those libraries inside of C3.

    Again, for those worried, not suggesting the other stuff be replaced at all, but expanding to more developers would never be a bad thing.

  • One of the things the new scripting feature allows for is to load WebAssembly modules, which effectively let's you leverage a ton of existing C/C++ code in the browser, with almost native efficiency.

    You can see how it is done in the Loading external script and WebAssembly example, found in the Scripting section of the Start Page when you open C3.

    Asides from that you can look into https://developer.mozilla.org/en-US/docs/WebAssembly for how to get started compiling existing C/C++ code into WebAssembly. Of course, C/C++ is the most prominent example, but you can find other languages that can be compiled to WebAssembly if you poke around the internet a little bit.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • .NET libraries depend on a full .NET virtual machine and runtime, which is a completely different technology stack to the browser, so I doubt it's technically feasible. As DiegoM noted there's the option of WebAssembly for C/C++. It might be possible to compile .NET libraries to WebAssembly, but it would be really awkward, since you'd probably end up with a massive WebAssembly file that has to bundle the entire .NET virtual machine and runtime with the library.

    Meanwhile there are literally millions of JavaScript libraries out there. For example npm alone has 1.2 million packages! That would be a much more fruitful place to look for libraries to use with C3. I also think that makes the argument as to whether JS or .NET is more powerful a matter of debate.

  • Thanks both. How do native iOS and Android EXEs work then? Are you loading some internal browser to run the code?

    Ashley As for powerful, there is a lot .NET can do that JS cannot obviously. But you're right, there is a price to be paid. Unless it's something really niche and specific, looking for third party libraries vs. coding my own (I'm a developer professionally) would be far preferable.

    Was just looking through some game utilities I've written in C# and lamenting that replicating them into JS would not be impossible, but not nearly so elegant codewise.

    Oh well.

  • Dot net core has an upcoming web framework called blazor. Which hosts the dotnet framework in web assembly. I am not sure if that's coupled with the blazor framework. If they have it in separate wasm file you might be able to leverage it, but only the dotnet standard libs, 3rd party dotnet library won't work. and to be honest I don't really see alot of benefit adding the dotnet framework on top of c3. Any thing you think you need dotnet for will probably be easier in javascript

  • Dot net core has an upcoming web framework called blazor. Which hosts the dotnet framework in web assembly. I am not sure if that's coupled with the blazor framework. If they have it in separate wasm file you might be able to leverage it, but only the dotnet standard libs, 3rd party dotnet library won't work.

    There is one for Mono that I've found already and it creates the WASM file that I could use should I decide to go that route.

    and to be honest I don't really see alot of benefit adding the dotnet framework on top of c3. Any thing you think you need dotnet for will probably be easier in javascript

    If you're not a .NET developer I'm sure you wouldn't see a lot of benefit.

    But I am and I know for a FACT that anything I need .NET for will be 10x easier than Javascript. Don't get me wrong, I use JS where JS needs to be used. But for the heavy lifting, .NET runs rings around it in terms of power and simplicity of code. No contest.

    They each have their lanes and their uses. And this isn't a thread to discuss the advantages of .NET. Just was wondering if it would be possible to add this upgraded toolset.

    Seems not though, so onward I go.

    P.S. Don't mean to sound harsh, but your reply to me seemed addressed to a newbie who sees all these shiny things and doesn't understand them. I do understand the question I was asking and the pros and cons (mostly pros) of being able to use .NET. Full scripting like Unity would be the bomb. But Unity didn't become accessible until after I was down the C2 route. I kept "meaning to" get around to it, using the 2D skills C2 taught me and the 20 years .NET experience I have (yeah, I'm a longtime developer). But never did... So forgive me if I desire the best of both worlds in C3 too. :)

  • no man, you got me wrong, that not how i intended to sound, I am also a professional dotnet developer, 7 years, not as tenured as you. I was just pointing out that that the standard dot net library will not provide you that much benefit, if you port it to wasm to use in javascript, not just will you face the interoperability cost, you will also not get much from most of the dotnet standard classes that deal with low level os calls, File system. Since c3 is run from a browser, you will hit the browsers sandboxed limitation, and even using 3rd party library (any unity api is out of the question since those are compiled to mono), but you will also have compile those down to wen assembly.

    on that note, one of the guys who use to work at microsoft started working WebWindow (https://blog.stevensanderson.com/2019/11/18/2019-11-18-webwindow-a-cross-platform-webview-for-dotnet-core/) which if it gets mature could be of interest to wrap construct3 games.

  • no man, you got me wrong, that not how i intended to sound, I am also a professional dotnet developer, 7 years, not as tenured as you. I was just pointing out that that the standard dot net library will not provide you that much benefit, if you port it to wasm to use in javascript, not just will you face the interoperability cost, you will also not get much from most of the dotnet standard classes that deal with low level os calls, File system. Since c3 is run from a browser, you will hit the browsers sandboxed limitation, and even using 3rd party library (any unity api is out of the question since those are compiled to mono), but you will also have compile those down to wen assembly.

    on that note, one of the guys who use to work at microsoft started working WebWindow (https://blog.stevensanderson.com/2019/11/18/2019-11-18-webwindow-a-cross-platform-webview-for-dotnet-core/) which if it gets mature could be of interest to wrap construct3 games.

    Thanks so much for the clarification. I'm not seeking to use .NET libraries per se... but C# coding to do some specific processing and algorithms. No graphics handling etc (that's for C3 to handle). But Linq for sorting, sifting, combining data, etc. for one is a major timesaver.

  • Never really used this myself, but if u really wanted linq there are alternatives. github.com/mihaifm/linq

  • Have you actually tried modern JavaScript with all the latest features? It's a fantastic language with great simplicity, powerful high-level features and expressive syntax. We used it to build all of Construct 3, and I'm a big fan now, it's a great language. Much of Construct 2 was written in C++, and I think we are much better off working in JS.

  • Never really used this myself, but if u really wanted linq there are alternatives. github.com/mihaifm/linq

    Cool. Will check it out. Thanks!

    Have you actually tried modern JavaScript with all the latest features? It's a fantastic language with great simplicity, powerful high-level features and expressive syntax. We used it to build all of Construct 3, and I'm a big fan now, it's a great language. Much of Construct 2 was written in C++, and I think we are much better off working in JS.

    Ashley No... Perhaps JS has matured beyond being a simple liaison between "real" coding and the web UI, LOL. Will dig more.

    Does C3 support most of the newest stuff though? Saw for example in the docs that modules for example were not allowed (IIRC). Hate to get excited about the new JS only to find the stuff I need does not work. :)

  • In general, C3 supports whatever the browser supports, and browsers are regularly updated to add the latest JS features.

    C3 currently loads all runtime scripts using <script> tags rather than modules, mainly for backwards compatibility (although this may change in future). That's the only reason you can't use import/export statements, but you can use dynamic imports, and the modules you import from that can use import/export statements, so it is in fact supported if you take that route.

  • In general, C3 supports whatever the browser supports, and browsers are regularly updated to add the latest JS features.

    Two followups:

    So what about third party libraries? I can include these in say my plugin code in the file manifest and use them inside my plugin?

    And I've asked before but never seen answered. How does all this "in browser" stuff work for native apps/exes?

  • And I've asked before but never seen answered. How does all this "in browser" stuff work for native apps/exes?

    The answer is Cordova for iOS/Android and NW.js for Windows/Mac/Linux.

    The laymans explanation is that those applications run on the native platform but interpret HTML/CSS/JS just like a web browser but they don't include any browser UI nor default browser keyboard controls. Basically they make your web app look like a native app.

  • > And I've asked before but never seen answered. How does all this "in browser" stuff work for native apps/exes?

    The answer is Cordova for iOS/Android and NW.js for Windows/Mac/Linux.

    The laymans explanation is that those applications run on the native platform but interpret HTML/CSS/JS just like a web browser but they don't include any browser UI nor default browser keyboard controls. Basically they make your web app look like a native app.

    Cool...

    So they are kept pretty current then (for all this new JS stuff?)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)