Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
javascript

Python vs. JavaScript

Educative Answers Team

Right now, Python and JavaScript are two of the most popular coding languages. The former is the dominant language of Artificial Intelligence, while the latter is used mostly for web development.

Both of these languages are interpreted languages, meaning that they do not need to be compiled and translated into machine code before execution. Instead, they are read and executed line by line, without any pre-processing. This means that both languages have the same performance.


Differences

  1. Standard library: Python has a more extensive standard library than JavaScript. This difference may make it necessary to download external libraries to complete a task in JavaScript, a task that could be done in Python without imports.
  2. 3rd party libraries: Python’s community is pretty strong when it comes to providing libraries. In Python, you can find tons of libraries for different purposes (e.g. Machine Learning, Data Science, etc.). Although JavaScript has many libraries as well, they are mixed-up with low-quality libraries. This makes it difficult for programmers to find the right one. However, in Python, many libraries have been standardised due to their quality and popularity (e.g. NumPy for complex computations). Therefore, most of the Python tutorials you see will make use of the same libraries for the same tasks.

Below are the basic syntactic differences between the two languages:

svg viewer
svg viewer

1. The end of a line

The new-line character \n indicates the end of a single line of code
A semicolon ; marks the end of one line of code

2. Code blocks

Only an indentation can indicate the start and end of a code block (i.e. start of a class, function etc.)
Code blocks are represented by the curly brackets {}

3. Declaring and using classes

class Student:

  def __init__(self, id, name):
    self.id = id;
    self.name = name 

  def update_id(self, id):
    self.id = id
  

s = Student(5, "abc")
print(s.id, s.name)
s.update_id(10)
print("New ID:", s.id)

RELATED TAGS

python
javascript
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring