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

Routine Poutine
Routine Poutine
26,050 Points

Are the host objects for Nodejs parallel to host objects in other backend languages?

I want to learn Nodejs as my first backend language. If I learn the host objects for it outside of the browser, will I in turn know more about host objects in other languages? If not, how is Nodejs different from other backend languages, like Python or Java?

1 Answer

Eric M
Eric M
11,546 Points

Hi Matthew,

The differences between Node.js, Python, and Java are quite considerable in general and in back-end web programming specifically.

A host object in JavaScript refers to an object that's part of the environment executing JavaScript rather than an object that's a native part of the JavaScript language. For instance, front-end JavaScript runs in your browser, so the browser provides host objects for JavaScript to interact with at runtime, such as the window.

Node.js doesn't run in the browser, it was created to be able to run JavaScript independently, so its host objects are specific to that paradigm. (From your question I suspect you know this though)

Learning about Node.js host objects probably won't help you understand host objects in other languages - because they don't necessarily have them. By gaining a deeper understanding of Node.js host objects, though, you will likely understand more about back-end programming in general. While the host objects themselves won't carry over the concepts of how the language might interact with its environment will be conceptually helpful.

Python has a Python interpreter runtime, Java has the JVM (Java Virtual Machine), and JavaScript has the browser or Node.js. They all execute code differently to one another, but they all provide an abstracted environment.

JavaScript is a fine first language to learn and Node.js has a lot of usage.

Good luck and happy coding!

Routine Poutine
Routine Poutine
26,050 Points

Thanks so much! May I also ask:

Why do we declare a variable in order to "require" a module in NodeJS?

If it is a module, wouldn't we just call it like a function?