I'm offered to build a project, a web application, or basically a website. But the client prefers that I use electronjs to develop it.
But as far as I know (Correct me if I'm wrong), electronjs is for building cross-platform desktop applications ONLY which can run on any OS like Windows, Linus, Mac, etc but not on a browser via URL. Since it uses HTML, CS, JS, or basically the browser's language, it may have confused my client to think that it can be used also for building web applications.
So my questions are:
Can I use electronjs for building a web application?
If yes, is it wise to use? Or building it in reactjs is better?
You are right. Electron was developed for building standalone desktop applications. It bundles a node.js server with a chromium browser to give the feeling of an application but of course uses web technology.
That said you can of course do a lot of things electron can by using a node.js server. But a lot of things - especially clientside file manipulation, or playing around with windows is than limited.
On the other hand you can build an electron application that accesses an online Server to retreive data or display webpages.
I would say no. Electron is used to build cross-platform desktop apps, and is not generally used to build websites. You could probably do it, but this is limited to very special circumstances, I would advise against it. You're probably better off using a framework meant to develop Single Web Apps, like React or Vue.
Like #Torf said with electron it's possible to have a nodejs application run in it's own chrome browser window (which looks like it's own application). But it's just a "website" which is displayed. So you can code a simple site and use it as website, windows application etc. it looks the same on all platforms.
What the hell then code-server does?
https://github.com/cdr/code-server
The fact that it is not yet generically implemented, does not mean "no".
Code-server is literally example of electron app that can be run inside a docker container, but have it's gui - as it is - rendered in a webpage.
Yes, not yet generically done, but is exactly possible.
No, it doesn't make sense to develop a website in ElectronJS. ElectronJS compiles and builds to formats that are not web-browser compatible. Like exe, zip, dmg, deb, etc.
You can develop a website in languages/frameworks which are designed for this purpose.
Related
Our team intends to use JavaScript library observablehq/plot from an app written in C# and running on .NET 5. As a proof of concept, we were able to successfully use that library running in a separate process on Node.js. The downside of this approach is that we would need to implement all data serialization and inter-process communication ourselves, and we would need to bundle Node.js in our app installer. We are looking for an alternative approach that would not require Node.js, but instead would directly host V8 JavaScript engine in our .NET app. Currently, we are considering using ClearScript package for that. While we were able to successfully run simple JavaScript code using it, we discovered that observablehq/plot and its dependencies use some APIs that are present in Node.js, but are apparently unavailable in ClearScript out-of-the-box (it seems that Node.js implements some of those APIs in JavaScript, and some in C++). Making those implementations available to ClearScript running in .NET app looks like a significant task whose cost I cannot estimate at this point.
I would like to ask if anyone had to solve the same or similar problem, and what approach would you recommend? Is there an easy way to make all necessary APIs available to observablehq/plot running on ClearScript? Should I consider hosting Chromium/Edge browser engine in the .NET app instead? I haven’t yet tried this, but I assume it is possible because my understanding (correct me if I’m wrong) is that WebView2 control can be used in WPF apps running on .NET, and it is implemented using Chromium and V8 JavaScript engine. Is there any other approach you can recommend?
Update: The app GUI is built on Avalonia and SkiaSharp. It is possible that eventually we will choose another charting library, perhaps, one not written in JavaScript. But my task at hand is specifically to investigate whether and how we can use JavaScript libraries in our app, taking observablehq/plot as an example, and investigate its features and performance characteristics.
If you are building a WPF desktop app you should try a WPF based chart library that feats your needs.
Open source libraries:
OxyPlot
InteractiveDataDisplay
ScottPlot support pan and zoom.
Paid libraries:
Telerik RadChart
DevExpress
More info about WPF charts in this post.
If you are using Blazor WebAssembly:
Use jsRuntime and JSObjectReference to import and call your Javascript observablehp library.
If you are using Xamarin.Forms the best professional library out there is probably SyncFusion:
Syncfusion Charts
Update:
Avalonia Framework only will support this through a webview / embedded browser as you stated above. Here you have 3 options:
Cefnet is a .NET CLR binding for the Chromium Embedded Framework
CefGlue same than above
WebView Avaloria-CefGlue
For more usefull tools and libraries to use with Avalonia please refer to Awesome Avalonia.
There are a lot of ways to develop an app nowadays. You can create a full native app, hybrid app, pwa or website. There are probably some formats of apps I didn't mention however that's besides the point. The last two decades have proven that smartphones are the way most of the people(users) are interacting with apps and that's clearly also how they want to interact all the time literally all the time! Developers(wizards) have been working to meet those demands by creating solutions like .Net blazor, Xamarin, Vue, Angular, ect to meet the demand for apps and their development. Currently app stores from Google and Apple are the way apps are distributed only for use to pay them a cut of our app revenue so we look to the web. When we want to create a highly secure app (server-side) we look to the web. When we want to support most operating systems we look to the web. I assume you get the point. only there is one thing that stands in the way and that is excess to the users native device APIs. There are alot of native APIs that are already available in HTML5 only we know that those aren't the specific ones we need for the app we develop. So what are the ways we can expos native device APIs to web apps?
Look at Cordova Plugins: https://cordova.apache.org. If you want to expose API into web, you just should write some player application (web browser) witch will translates JS commands into native API callbacks. To achieve it, you can use WKScriptMessageHandler.
Here you can find an example.
It is not very complicated, but if you want to cover all API, it will very complicated code.
Also, you forget about one coin of a web application: long time of a response, especially with low internet connection. I do not think that is a good idea.
I was thinking about building a scheduling/time tabling app with Node JS that is primarily used in/as a mobile native app. Im certain I have worded the specifications wrong, but I was hoping for some guidance on where to start researching:
Any useful libraries/services
The general way to go about using Node JS for mobile
Anything you might think it useful
Thanks!
I am assuming you want to launch this mobile app natively on multiple platforms (IOS/Android/WP).
If that's the case, you can directly go for hybrid app frameworks which will help you write once and deploy natively on multiple devices. The best two hybrid frameworks that I found are React Native and Xamarin ( different people can have different opinions about different hybrid frameworks )
React Native will give you the opportunity to use JSX which is very close to Javascript. While in Xamarin you'll work purely in C#.
As far as your question regarding deploying natively via node.js is concerned, I don't think it's possible. If you read this blog post. It says the following.
Technically, you can run Node on Android, but not iOS. This is because Node uses Google’s V8 JavaScript engine. The V8 engine compiles JavaScript to a native code before executing it, a process known as Just-In-Time (JIT) compiling. iOS does not allow JIT compiling unless the device is jailbroken which why Node applications cannot be deployed native on iOS.
Obviously, any mobile strategy that ignores iOS is doomed to fail
So my suggestion would be to use one of these hybrid frameworks for front end and build a node.js based backend service where you can write a REST API to retrieve results for calls you make from the frontend.
There are tons of tutorials out there regarding how to build REST API's in node.js. this can be a good start.
There's a specific app that I want to make, and I was wondering if I can use JavaScript to code it entirely.
There are a number of frameworks out there that let you write your code in HTML, CSS, and JS and then compile/build apps to native devices I for instance Apache Cordova or Phone Gap do this.
Choices are countless. Try Cordova for hybrid app development.
You're most likely thinking of a single page HTML5-based "app".
(though it's arguably not an app, it's just a web page).
These are often built using frameworks such as Angular, Backbone, or Ember.
Watch out, there's still constant debate on the merits of HTML5 vs. native apps.
Currently, we have a number of GUIs that have been developed using PyQt4 and PyQtGraph.
We need to make these interfaces accessible to a number of remote users and are hoping to do so by serving the GUIs through an HTML/CSS/JavaScript Web-Application.
The link below provides a few suggestions for this task, but these seem to apply to a project that is in its initial stages of creation. I'm familiar with the development of Python-JavaScript Web-Applications using the Pyramid Server and would like to use this same method for providing users access to PyQt4 GUIs that have already been developed.
https://softwareengineering.stackexchange.com/questions/109572/can-i-create-a-desktop-python-gui-application-and-run-it-as-a-web-app
So my question is, can I serve a functional PyQt4 GUI as a widget using HTML/CSS/JavaScript?
This is hard. In theory you could use a VNC-like approach that sends an image of the window to the client browser and sends user events back to the server. This will probably have poor interactivity depending on the networking and would require a lot of server power, depending on the number of users. (For an example of this, see: https://github.com/campagnola/webqt)
You're probably better off distributing the application with something like py2exe, py2app, cx_freeze, etc.
I personally haven't tried it but you could look into Wt: http://www.webtoolkit.eu/wt/
It is a C++ framework that has a Qt flavour. It has a Java version called JWt. Hence, a Jython binding exists for us Python programmers: http://www.webtoolkit.eu/wt/other_language
It is not a direct replacement of Qt, and might need modification to your Qt code to work as a Wt web app, but it certainly seems worth it to look into.