Loading video player…

Python vs JavaScript for Python Developers (Overview)

Python isn’t the only language out there, and one of the other languages frequently fighting Python for the top of the “most popular” lists is JavaScript. JavaScript is the de facto language on the web but also has a robust toolset on the server side. This course explores JavaScript from a Python programmer’s perspective.

In this course, you will learn:

  • Where JavaScript comes from and where it is used
  • How JavaScript’s type system is different from Python’s
  • How to write functions in JavaScript
  • The two ways of creating objects in JavaScript
  • General language syntax in JavaScript
  • Surprises and behaviors in JavaScript that Python programmers wouldn’t expect
Download

Sample Code (.zip)

27.5 KB
Download

Course Slides (.pdf)

1.4 MB

00:00 Welcome to Python vs JavaScript for Pythonistas. My name is Chris and I will be your guide. As unfortunate a fact as this may be, Python isn’t available everywhere and doesn’t do everything.

00:13 This is a problem being worked on, but in the meantime, there are other languages. There are a whole bunch of sites that rank programming language popularity.

00:21 Python and JavaScript have routinely been in the top five for a number of years now. JavaScript is the de facto language for coding on the web. That was what it was originally written for, but it also has a robust set of capabilities on the server side as well.

00:37 Join me in this course and you will learn the basics of JavaScript through a Python programmer’s lens. I will cover JavaScript by highlighting where it is similar to your favorite language, where it is different, and where knowing both can get a bit confusing.

00:50 In particular, you will learn where JavaScript comes from and where it is used, how JavaScript’s type system is different from Python’s, how to write functions in JavaScript, the two different ways of creating objects, and general JavaScript syntax and usage. Finally, I’ll spend a lot of time on the things you might not expect—those corner cases where people new to JavaScript get caught, especially if they have assumptions coming from other languages.

01:20 A quick note on versions: Most of what is covered in this course will not be specific to any versions, but for the record, I’ve tested the code using Python 3.9 and Node 14.12.0.

01:31 Almost all of the JavaScript will be compliant with the ES6 definition and I will point out anything that was introduced later than that. Finally, for the lesson on the web console, I’ll be using Firefox version 88.

01:44 All the major browsers have similar console tools and you’ll be fine using whatever browser you’re comfortable with if you’re following along.

01:52 JavaScript was originally written as a way of performing client-side form validation inside of web pages. If you find yourself wondering “Why did they do it that way?” it is probably because the original intent of JavaScript was fairly small-scale and specific. Over the years, the language has grown immensely. With it being run in browsers, the many competing browser companies have had a lot of influence on the language. Although JavaScript is standardized, a lot of the features were first implemented outside the standard and then adopted. For a long time, the behavior between browsers wasn’t consistent, especially when interacting with a web page. Those days are mostly gone now, but it does explain why the language has several different ways of doing the same thing.

02:36 Although born for the web, JavaScript now exists on the server as well. Node.js allows you to run JavaScript on the command line or in a web server. This can be a powerful boost to your coding.

02:46 It allows you to use the same language in the client and server.

02:52 The spiritual ancestor of both JavaScript and Python is C. This means that a lot of the basic syntax like variable assignment, loops, and functions will feel familiar to you.

03:02 Functions are first-class entities in both languages, and both provide tools for object-oriented coding.

03:09 The underlying type system in JavaScript is different from Python’s, but the differences aren’t a lot and you could probably code in JavaScript without even realizing the difference.

03:18 The modern standard of JavaScript is a fairly clean language. The challenge comes from the fact that it is still backwardly compatible with old versions.

03:26 If you ever heard people complaining about the move from Python 2 to Python 3, you might get a better appreciation for why that pain was necessary as you see the hodgepodge that is JavaScript.

03:37 This backward compatibility means there are two ways to create objects, two ways of declaring functions, and two ways of comparing things. If you stick to the newer version of each of these things, your life will be easier. If you’re reading other people’s code, though, no guarantees. This course covers a lot of ground. By the end, you’ll have a much better understanding of JavaScript and how it differs from Python. I’ll admit that while creating it, I had a couple of “Oh!

04:04 That’s why it does that!” moments. Hopefully, some of my pain can spare you the same.

04:11 Next up, a brief history of the universe, starting with the invention of the world wide web and how that resulted in JavaScript.

Become a Member to join the conversation.