There are tools that help us now to compile or node.js apps into executable such as "pkg". But I am interested If this can improve a web server written in expressjs?
No, web servers based on the Express framework will always require running on the V8 JavaScript engine of Node.js, which is also used by the Google Chrome browser.
You cannot compile a JavaScript program to machine code and run it standalone, like you can with programs written in C++.
If you create an executable program with JavaScript, for example using Electron, it's actually just a modified Chrome browser that runs the JavaScript, so the JavaScript is not actually compiled, it is still code interpreted by the modified Chrome's V8 engine at runtime.
Chrome and its V8 engine are written in C++ and compiled to machine code, so they can be run standalone.
Related
I need to display a native app (in my case, a video game built on unity) in a web browser page.
Local video and input streaming would be a solution, but video encoding is consuming too much computer resources.
Is there a way to display a native app in a web browser page?
Sure, you need to compile your application for WebAssembly. Or, to be more precise, cross-compile it, since WebAssembly binary code runs on a virtual stack machine.
You take your native code, compile it into a .wasm module, and then load that .wasm module with WebAssembly.instantiateStreaming().
There are many toolchains that can have WebAssembly as the compilation target. I think the 2 most popular ones are Emscripten and wasm-pack.
There is also wabt, but that is rather a set of lower level tools, not quite a toolchain.
And since you mentioned Unity, I have no experience with it, but there is some official documentation on WebAssembly.
Here is a game that was developed in C# and cross-compiled to WebAssembly.
question
I am wondering what the main differences are between Electron and JXcore.
background
I was thinking about how I could make a NodeJS server into an app and I came across both of these. They seem to do the same thing, except that JXcore supports mobile and Electron doesn't.
side question
If Electron doesn't support mobile then how was the slack mobile app created?
Thanks in advance!
From the JXCore site(http://jxcore.com/tech/):
JXcore is a fork on the open source Node.js project
It uses LLVM to compile javascript as opposed to V8 which NodeJS does.
In terms of what are the main differences- Electron is a framework for building native, cross platform desktop applications, where it appears JXCore is a javascript engine forked from NodeJS.
Electron is built with NodeJS, and Chromium. So to make it fair, the comparison would be better stated "How does Electron work with NodeJS vs JXcore". Since I don't have any experience with JXCore, I can't answer that question. I would venture to say the only way to know that is to fork electron and replace Node with JXCore.
Based on your background, I would assume you are thinking about making one application that works cross platform across mobile and desktop environments. To that, I would say it is possible, but you are going to have 2 different projects. There are things in Electron that you wouldn't want included in your mobile app, since they are working with completely different operating systems. You are right that electron does not support mobile (it wasn't built for that).
As far as your side question goes, there are any number of technologies that slack could have used to create their mobile app. They could have used Java , Swift, Objective-C, .NET, Ruby, or Javascript.
There are cross platform tools such as RubyMotion, NativeScript, React Native, and Xamarin that could also be used to create native mobile apps, that all compile down into the native language the mobile OS understands.
A final approach could be the use of tools such as Cordova/Phonegap which create mobile apps via a "web view". Essentially, this is like creating an app that launches a web browser to interact with your phone.
If you are looking for an example on how to build once and use everywhere, I would look at the github repo found here https://github.com/NathanWalker/angular-seed-advanced. This shows a common codebase that can be used in Electron, Web, and Mobile.
Are there any node.js runtime wrappers generators similar to gradle wrapper that allows to build node.js application without installing the node runtime globally?
Yes, there are many projects that aim to make bundling Node.js with your apps easy:
node-bundler
Nexe (doesn't support dynamic require statements)
EncloseJS (paid)
If you're starting a GUI project from scratch, then Electron or NW.js allow you to bundle up a browser with your app to allow using JS, HTML and CSS.
There are also some experimental JavaScript-to-uninterpreted compilers in the work:
ts2c converts TypeScript to C which can then be compiled with gcc or clang, and there's an unreleased project called Nectar that aims to compile JS to machine code directly.
I'm working on a node.js module which uses native C++ addons. I plan to move my development from vim+nemiver+node-inspector to something more integrated. For that c9 seems to do the job.
Is it possible to debug both javascript (with v8) and C++ (with gdb) at the same time?
My old setup supports this by using nemiver and node-inspector side by side, but it isn't a very pleasent workflow.
Are there any examples of to use XULRunner to embed the browser control inside a app? (preferably in c or c++ for native win32 apps)
I have tried QT, wxWidgets, Awesomium, chrome embedded, LLmozLib, midori and Embedding/NewApi/Win32
The best one is wxWebConnect (which is part of wxWidgets framework). Why, cause you don't need the whole mozilla code base to build it plus the actual browser control is perfect as in plugins work, everything is rendered correctly (gmail, youtube etc etc)
So what's my problem or question? Well the wxWebConnect uses XULRunner to embed the browser control, my application is native win32 app and not wxWidgets app. I've searched the net to find another example of how use XULRunner to embed the gecko browser in native win32 apps..without luck!
Anyone know of projects/code that just use XULRunner and not require the entire mozilla source tree?
Thanks.
There's a list of XULRunner-based applications at
https://developer.mozilla.org/en/XULRunner_Hall_of_Fame
Whether you use wxWebConnect or embed XULRunner directly you are still going to have as part of your applications deployment the XULRunner engine and it's folder hierarchy. That's the nature of the beast.
Try GeckoFX, if you are okay with using .NET. Looking at the GeckoFX code might also give you enough insights to embed xulrunner in your native C++ Win32 app.