Reader small image

You're reading from  Hands-on JavaScript for Python Developers

Product typeBook
Published inSep 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838648121
Edition1st Edition
Tools
Right arrow
Author (1)
Sonyl Nagale
Sonyl Nagale
author image
Sonyl Nagale

Chicago-born, Iowa-raised, Los Angeles-seasoned, and now New York City-flavored, Sonyl Nagale started his career as a graphic designer focusing on web, which led down the slippery slope to becoming a full-stack technologist instead. With an eye toward the client use case and conversation with the creative side, he prides himself on taking a holistic approach to software engineering. Having worked at start-ups and global media companies using a variety of languages and frameworks, he likes solving new and novel challenges. Passionate about education, he's always excited to have great teachable moments complete with laughter and seeing the Aha! moments in students eyes.
Read more about Sonyl Nagale

Right arrow
Node.js versus Python

Why would a developer choose Node.js over Python? Can they work together? What do our programs look like? These questions and more are at the heart of some of the differences between Python and Node.js, and it's important to understand when and where to use a particular language. For example, there are tasks for which a certain language is more suited than others, and it is the technologist's duty to advocate for the proper language. Let's investigate the use cases and different considerations when choosing Node.js versus Python.

The following topics will be covered in this chapter:

  • Philosophical differences between Node.js and Python
  • Performance implications

Technical requirements

Philosophical differences between Node.js and Python

It's common to have a main language that you know, work with, and are comfortable with. However, it's important to realize that not all programming languages are created for the same purpose. That is why it's very important to use the right tool for the job at hand. Just as you wouldn't attempt to build a house with a pocketknife, you probably wouldn't use a table saw to whittle a stick into a point for a campfire for s'mores.

If you've been in the industry for a while, you have probably heard the term stack. In technology, a stack is the architectural combination of technologies used to create a program or multiple programs in an ecosystem. In the past, applications tended to be large-scale monoliths, built in a "one application to rule them all" mindset. In today's world, the use of monoliths is decreasing in favor of multiple, smaller applications and microservices. In this manner...

Performance implications

When Node.js was first gaining popularity, there were concerns about its single-threaded nature. Single thread means one CPU, and one CPU can be overwhelmed by large traffic influxes. However, for the most part, all of these thread concerns have been assuaged by advances in server technology, hosting, and DevOps tools. With that being said, the single-threaded nature also shouldn't be a deterrent in and of itself: we'll discuss in just a little bit why the Node event loop plays an important role in any discussion around Node.js's performance.

In a nutshell, to really differentiate on performance, we should focus on perceived performance. Python is an easy-to-understand, robust, object-oriented programming language; there are no disputes about that. However, one of the things it does not, cannot, and will not do is run in the browser. That spot is taken by JavaScript.

Why is this important and how does it relate to performance? In a nutshell: Python...

Summary

Python is great. Node is great. Both are great. So why are we having this conversation? While both technologies are strong and mature, each has a role to play in the technology ecosystem. Not all languages are created equal, and not all languages handle problems in the same way.

To summarize, we have learned the following:

  • Node.js is asynchronous and works well with event-based thoughts, such as JavaScript in a browser reacting to page events.
  • Python has established itself as a leader in data analysis and machine learning, as it's able to process large datasets quickly.
  • For web work, the technologies may be interchangeable, but a complex architecture may involve both (and more!).

In the next chapter, we'll begin working with Express, a foundational web server for Node.js. We'll create our own websites and work with them.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-on JavaScript for Python Developers
Published in: Sep 2020Publisher: PacktISBN-13: 9781838648121
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Sonyl Nagale

Chicago-born, Iowa-raised, Los Angeles-seasoned, and now New York City-flavored, Sonyl Nagale started his career as a graphic designer focusing on web, which led down the slippery slope to becoming a full-stack technologist instead. With an eye toward the client use case and conversation with the creative side, he prides himself on taking a holistic approach to software engineering. Having worked at start-ups and global media companies using a variety of languages and frameworks, he likes solving new and novel challenges. Passionate about education, he's always excited to have great teachable moments complete with laughter and seeing the Aha! moments in students eyes.
Read more about Sonyl Nagale