Learning Python from a JavaScript POV
Published: 2020-09-14 14:56:57

Technology is ever-changing and rapidly growing. There are many languages that fall into the category of niches such as PHP and Ruby while other languages such as Javascript, Python, and C languages dominate the industry. Together let's demystify learning other languages and dive deep into some Python basics and discuss how it differs from Javascript.

### Brief History

***Python*** was first implemented in December 1989 as a replacement for the programming language ABC to interface with Amoeba operating system. Python is a high-level object-oriented programming language designed to be easy to read. It uses a garbage collector for memory management and terminates as soon as there is a problem in the code. These problems are considered syntax-related or exceptions. 

***Javascript*** was submitted to ECMA as the standard specification all browser vendors like Mozilla, Apple, and Google could conform to. Javascript gained popularity with the introduction of Ajax technologies that used Javascript to create web applications that allowed for background loading without reloading the entire page.

### Python VS. Javascript

REPL stands for a read-eval-print-loop which is a language shell that takes the user inputs and returns the results to the user after execution. REPL has to be installed with Javascript but comes with the installation of Python. 

Hash tables are very useful for working with large sets of data in an efficient manner. Though we can construct hash tables in JS, Python dictionaries and sets are built-in hash tables and can be used in conjunction with keys and values.

A javascript array is very similar to python list.
```js
const array = ["Hello", "World", "!"];
console.info(array); // prints ["Hello", "World", "!"]
```

```python
py_list = ["Hello", "World", "!"]
py_list # Prints ["Hello", "World", "!"] 
```

We can access by index and modify.
```js
const array = ["Hello", "World", "!"];
array[0];
 // Prints "Hello"
 array[array.length-1]; // Prints "!"
array[0] = "Bye";
array; // Prints ["Bye", "World", "!"]

```

```python
py_list = ["Hello", "World", "!"]
py_list[0] # Prints "Hello"
py_list[-1] # Prints "!"

py_list[0] = "Bye"
py_list  # Prints ["Bye", "World", "!"] 
```

We can also check the length of the lists and extend it with new values. 
```js
const greeting = ["My name is"];
greeting.push("Jessa", "!");
console.info(greeting); // Prints ["My name is", "Jessa", "!"]
```

```python
py_greeting = ["My name is"];
py_greeting.extend(["Jessa", "!"]);
py_greeting # Prints ["My name is", "Jessa", "!"]
```

We can also concatenate elements.
```js
const greeting = ["My name is ", "Jessa", "!"];
const newGreeting = greeting[0] + greeting[1] + greeting[2]; // Prints "My name is Jessa!"
```

```python
py_greeting = ["My name is ", "Jessa", "!"]
greeting = py_greeting[0] + py_greeting[1] + py_greeting[2]
greeting # Prints "My name is Jessa!"
```

### Major Differences

Javascript is can be used for front-end development while Python is used for the back-end which makes Python great for machine learning and math-intensive. Javascript is a more complex language than Python, but Python is easy to work with and maintain because it has a better design. 

### Conclusion

The goal of this post to encourage Javascript developers to explore other languages. Adding other popular languages such as Python will increase the number of optional career paths and ease the ability to learn other languages. Commit to a lifetime of learning to make a meaningful contribution to the industry. Thanks for stopping by and as always happy coding! 

Credits: 
https://www.codementor.io/@johnselawsky/why-you-should-learn-several-programming-languages-where-to-learn-them-103pdtcctd
https://en.wikipedia.org/wiki/Python_(programming_language)
https://en.wikipedia.org/wiki/JavaScript