Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How can JS be "Capable of running on the backend as a super fast web server"?

JavaScript Everywhere; Javascript Basics, Dave explains how JS is "Capable of running on the backend as a super fast web server." Please Someone explain this because it's extremely confusing to understand how a programming language can work as a web server.

Thanks in advance.

1 Answer

Balazs Peak
Balazs Peak
46,160 Points

All web server software are programmed in programming languages (just like any other software).

Javascript was originally developed to run in web browsers, as a "front end" (=client side) programming language enabling websites to become more interactive. Over time, JS became more and more popular, and people started to do all sorts of things with it. One of these undertakings was NodeJS, which is (primarily) a Javascript based framework for server-side programming.

Since web server software are inherently running on the server side, it is a prerequisite for them to be developed in a server side language. The moment when NodeJS made Javascript available for server side programming, enabled it to be the foundation of a web server. Not only that, but NodeJS has very specific features that actually makes it easy to be a language for web server programming.

But web servers can be programmed in a variety of different languages. The main feature is that this software runs all the time on a server machine and listens to a port for HTTP request which it can respond to with some content.

Note: Some people say that programming your own web server in NodeJS should be done for educational purposes only. If you want to create a web application and put it into production, an advanced web server software should be used for HTTP request handling, for example Apache. You can use it together with your server side language, which can be NodeJS or many other frameworks and languages.

The main reason for this is security. For example, Apache has been under development for decades, and it has great features for security. If you develop your own web server software, you can end up with security vulnerabilities and some not so kind people can hack your web application or website.