Can javascript write desktop programs?
Javascript can write desktop programs. In JavaScript, you can use the Electron software framework to develop desktop programs; Electron is an open source library for building cross-platform desktop applications. It provides a rich local API that enables developers to create desktop applications using pure JS.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
What is a desktop application
##Desktop application, also known as GUI program (Graphical User Interface), but there are some differences from GUI programs. Desktop applications transform GUI programs from GUI to "desktop", making the cold concept of a computer like a piece of wood more humane, more vivid and dynamic.
So can javascript write desktop programs?
javascript can write desktop programs. The world of JavaScript is getting more and more powerful, and you can use frameworks like Eletron to easily develop desktop applications.
Electron is a cross-platform javascript desktop development library. Electron is an open source library developed by Github that uses HTML, CSS and JavaScript to build cross-platform desktop applications. Electron does this by merging Chromium and Node.js into the same runtime environment and packaging them as apps for Mac, Windows, and Linux systems. Electron provides a rich native (operating system) API that enables you to create desktop applications using pure JavaScript. Unlike various other Node.js runtimes, Electron focuses on desktop applications rather than web servers. Electron allows you to use pure JavaScript to call rich native APIs to create desktop applications. You can think of it as a variant of io.js focused on desktop applications rather than web servers.Reason for using Electron for development:
- Using Web technology with a strong ecology for development, the development cost is low, Strong scalability, cooler UI
- Cross-platform, one set of code can be packaged into three sets of software for Windows, Linux, and Mac, and the compilation is fast
- Can be directly extended on existing web applications to provide capabilities that browsers do not have
- You are a front-end
Development experience
Compatibility
Although you are still developing using WEB technology, But you no longer need to consider compatibility issues. You only need to care about the version of Chrome you are currently using. Generally speaking, it is new enough to allow you to use the latest API and syntax. You can also manually upgrade the Chrome version. . Likewise, you don’t have to worry about style and code compatibility issues with different browsers.Node environment
This may be a feature that many front-end developers have dreamed of. Using the powerful API provided by Node.js in the WEB interface means that you You can directly operate files, call system APIs, and even operate databases on the WEB page. Of course, in addition to the full Node API, you can also use hundreds of thousands of additional npm modules.Cross-domain
You can directly use the request module provided by Node to make network requests, which means you no longer need to be troubled by cross-domain.Powerful scalability
Use node-ffi to provide powerful scalability for applications (will be introduced in detail in later chapters).Who is using Electron
Electron has been developed, including the familiar
VS Code client,
GitHub client,
Atom client, etc. I was very impressed by Xunlei’s copywriting when it released Xunlei X
10.1 last year:
Starting from Xunlei Thunder X using the new framework can perfectly support high-definition displays such as 2K and 4K, and the text rendering in the interface is also clearer and sharper. From a technical perspective, the new framework is more flexible and efficient than the old framework in terms of interface drawing and event processing, so the smoothness of the interface is also significantly better than that of the old framework Thunder. As for the specific improvement? You'll know once you try it.You can open
VS Code and click [Help] [Switch Developer Tools] to debug the
VS Code client interface.
Electron operating principle
Electron
combines Chromium
, Node.js
and API
that calls the operating system's native functions.
1. Chromium
Chromium
is an open source project launched by Google
to develop the Chrome
browser, Chromium
is equivalent to the engineering version or experimental version of Chrome
. New features will be implemented first on Chromium
and will be applied to Chrome
after verification. Therefore, the functions of Chrome
will be relatively backward but more stable.
Chromium
provides Electron
with powerful UI
capabilities, allowing you to develop interfaces without considering compatibility.
2. Node.js
Node.js
is a development platform that allows JavaScript
to run on the server side, Node
It uses an event-driven, non-blocking I/O model to be lightweight and efficient.
alone cannot have the ability to directly operate the native GUI
, Electron
integrates Nodejs
, this It allows it to develop the interface while also having the ability to have the underlying API
of the operating system. The Path, fs, Crypto
and other modules commonly used in Nodejs
are in Electron
can be used directly. 3. System API
In order to provide
GUI support for the native system, Electron
has a built-in native application program interface for calling some system functions. Provide support for calling system notifications and opening system folders. In development mode,
is developed separately from the calling system API
and the drawing interface. Let’s take a look at Electron
About How processes are divided. 4. Main process
distinguishes two processes: the main process and the rendering process, each of which is responsible for its own functions.
The process that runs the main
script of package.json
is called the main process. An Electron
application always has one and only one main process.
Create rendering process (can be multiple)
- Control the application life cycle (start, exit APP
- And do some event monitoring for
APP
)Call the underlying functions of the system and call native resources
- Node.js API
- API
provided by Electron
(including some system functions andElectron
Additional functions) 5. Rendering process
Because
Electron uses Chromium
to displayweb
page, so the multi-process architecture of Chromium
is also used. Each web
page in Electron
runs in its own rendering process.
You can think of the rendering process as a browser window. It can exist multiple and independent of each other, but unlike a browser, it can callNode API
.
Render the interface using
- HTML
- and
CSS
Use
JavaScript - Do some interface interaction
- DOM API
- Rendering process provided
API
[Related recommendations:
The above is the detailed content of Can javascript write desktop programs?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
