- vừa được xem lúc

Blog#139: What is Node.js? Why is everyone using it?

0 0 10

Người đăng: NGUYỄN ANH TUẤN

Theo Viblo Asia

The main goal of this article is to help you improve your English level. I will use Simple English to introduce to you the concepts related to software development. In terms of IT knowledge, it might have been explained better and more clearly on the internet, but remember that the main target of this article is still to LEARN ENGLISH.


Hi, I'm Tuan, a Full-stack Web Developer from Tokyo 😊. Follow my blog to not miss out on useful and interesting articles in the future.

This article is a translation from another article. LINK

You are learning JavaScript and may encounter everyone discussing Node.js and have questions like "Isn't Node.js a web server? Why do I have to install it? Why is everyone using it?" The purpose of this article is to answer those questions.

The features of JavaScript

You need to understand the difference between JavaScript and other programming languages first. JavaScript is a programming language that runs on browsers like Chrome and Firefox, while other popular programming languages like Python and Ruby usually run on computers. It's like the difference between a browser and a computer - one is for surfing the web, the other is for doing serious work. Or, as I like to say, JavaScript is for browsing the web, while other languages are for browsing the fridge.

Applications that run on a computer (such as Python or Ruby) can access the functions of the operating system (such as reading and writing files or network communication), which is the difference. Or, in other words, computers are like a box of chocolates - you never know what you're gonna get!

Just by accessing a computer, there is a possibility that files on the computer can be read, written, or deleted without permission, so programs that run on browsers (JavaScript) are prevented from accessing the functions of the operating system.

However, it is inconvenient to not be able to access the functions of the OS at all, so the browser mediates limited access to the functions of the OS. Through this mediation, access to the camera and microphone is also enabled, and web conferences are now possible.

What is Node.js?

Node.js is a tool that allows you to run JavaScript on your computer, instead of just in your browser.

Node.js installs an application (a JavaScript runtime environment) called "node.exe" when you install it on Windows, just like when you install Python you get "python.exe". With Node.js, you can access the operating system's features with JavaScript and do things like read and write files and network communication that you can't do on a browser.

Node.js can be used not only for web applications, but also to create other types of applications. For example, you can create command line tools and desktop applications.

Node.js is a server-side environment for running JavaScript?

Node.js is an environment designed to build web servers using JavaScript. That's why it's often referred to as a "server-side JavaScript execution environment". However, nowadays Node.js is also used as an environment to develop "JavaScript to be run in the browser", so it can be used both as a "server-side JavaScript execution environment" and a "client-side JavaScript development environment". In other words, Node.js is used for both!

What is npm?

NPM is a handy tool when using Node.js. It's like Python's pip, Ruby's gem (RubyGems), Debian's apt, Mac's Homebrew, and Rust's cargo.

There's also yarn, but it's okay because it can do the same thing as npm. "Packages" are libraries and frameworks, like Vue, React, webpack, and jQuery.

If you want to use a library with Node.js, you can install it with npm, so you don't have to download a js file and write <script src="xxx.js"></script>. It's like a magical package delivery service!

Why is everyone using Node.js?

Now you can use Node.js, which has enabled you to use JavaScript, to write client-side programs and create web applications and applications for mobile/desktop! Yay!

Purpose 1: I want to write client-side programs in new specifications of JavaScript or TypeScript.

To use the newest JavaScript specifications (ES2015 and beyond), you need to use Babel to convert it or set up an environment with Node.js.

Let's not talk about TypeScript this time.

Purpose 2: I want to create a web application.

You can make web applications with Node.js, just like you can with Ruby + Rails or Python + Django.

Execution environment Language Web framework
Ruby Ruby Ruby on Rails ..vv
Python Python Django ...vv
Node.js JavaScript Express ...vv

Node.js is a programming language designed to build network applications that can handle large amounts of simultaneous connections. It takes on the role of a web server, receiving HTTP requests and processing them.

You can use Node.js instead of a typical web server (Apache or nginx), but often a configuration with Node.js and Apache or nginx as a reverse proxy is used because Node.js alone is not enough.

People who can only do JavaScript may be told to choose Node.js, but the effort to learn Node.js is not much different from the effort to learn other programming languages, so it's best to choose without being tied to a language and to research its features well.

Purpose 3: I want to create applications for mobile/desktop.

Using Node.js, you can create mobile applications and desktop applications. For mobile applications, you use the framework React Native, and for desktop applications, you use the framework Electron. Electron is a framework for creating desktop applications using JavaScript, HTML, and CSS.

Electron: https://www.electronjs.org/

JavaScript is a language used for creating websites, and it's often used for manipulating the user interface (UI). Because of this, there are many libraries and frameworks available for building UI. This is a big advantage because it allows you to create UI that's similar to websites.

Additionally, using Electron, you can create applications that handle the features of operating systems like Windows, Mac, Linux, etc. Furthermore, using Electron, you can create applications that run on different platforms such as Windows, Mac, Linux, etc. using the same code.

Desktop applications like Visual Studio Code, Slack, Discord, Twitch, Skype, etc. are created using Electron.

Purpose 4: Others

Node.js is used for various other purposes, like bundling website assets with webpack, converting Sass to CSS using node-sass, using testing tools like Jest and code validation tools like ESLint, setting up a development-friendly web server locally with webpack-dev-server, and building static sites with Gatsby. It's like a Swiss Army knife for web developers!

Conclusion

Node.js has brought the same level of potential to JavaScript as other programming languages. (The V8 JavaScript engine is also responsible for this, but it was not mentioned in the text because it can make the discussion more complicated.)

As often said, JavaScript does have some weaknesses in its design compared to other languages. Some people may think that it is still on the same level as other languages.

However, JavaScript has a huge user base among young people, and it is evolving at an incredible speed, including its libraries, making it the only programming language with changing trends.

jQuery is now considered a historical relic, but it was born after Rails and Django (it is not easy to compare, but still). It shows how fast things are moving.

Personally, I find it exciting and enjoyable to be able to ride this thrilling wave of evolution in JavaScript that was born in this era.

Finally, I hope that this article will answer common questions such as "Is Node.js not a web server? Why do I have to install it if I just want to write with ES2015?" that are often asked at the beginning.

And Finally

As always, I hope you enjoyed this article and learned something new. Thank you and see you in the next articles!

If you liked this article, please give me a like and subscribe to support me. Thank you. 😊


The main goal of this article is to help you improve your English level. I will use Simple English to introduce to you the concepts related to software development. In terms of IT knowledge, it might have been explained better and more clearly on the internet, but remember that the main target of this article is still to LEARN ENGLISH.

Resource

Bình luận

Bài viết tương tự

- vừa được xem lúc

Cài đặt WSL / WSL2 trên Windows 10 để code như trên Ubuntu

Sau vài ba năm mình chuyển qua code trên Ubuntu thì thật không thể phủ nhận rằng mình đã yêu em nó. Cá nhân mình sử dụng Ubuntu để code web thì thật là tuyệt vời.

0 0 408

- vừa được xem lúc

Hướng dẫn làm bot Facebook messenger cho tài khoản cá nhân

Giới thiệu. Trong bài viết trước thì mình có hướng dẫn các bạn làm chatbot facebook messenger cho fanpage. Hôm nay mình sẽ hướng dẫn các bạn tạo chatbot cho một tài khoản facebook cá nhân. Chuẩn bị.

0 0 232

- vừa được xem lúc

Crawl website sử dụng Node.js và Puppeteer - phần 2

trong phần 1 mình đã giới thiệu về puppeteer và tạo được 1 project cùng một số file đầu tiên để các bạn có thể crawl dữ liệu từ một trang web bất kỳ. Bài này mình sẽ tiếp nối bài viết trước để hoàn thiện seri này.

0 0 73

- vừa được xem lúc

Điều React luôn giữ kín trong tim

■ Mở đầu. Ngồi viết bài khi đang nghĩ vu vơ chuyện con gà hay quả trứng có trước, mình phân vân chưa biết sẽ chọn chủ đề gì để chúng ta có thể cùng nhau bàn luận.

0 0 59

- vừa được xem lúc

Gửi Mail với Nodejs và AWS SES

AWS SES. AWS SES là gì.

0 0 83

- vừa được xem lúc

Crawl website sử dụng Node.js và Puppeteer - phần 1

Bài viết này mình sẽ giới thiệu cho các bạn craw dữ liệu của web site sử dụng nodejs và Puppeteer. .

0 0 164