Python Guide for JavaScript Engineers: A 100k characters e-book based on ChatGPT
Tags: javascript, python, ai, frontend
Published: 2023-12-11 13:00:00


![book-cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8sw7v0shg5bn0mr58ah.png)

## About the Book
Hello, I'm luckrnx09, a frontend engineer who makes a living with React. I'm glad to introduce to you my first open-source e-book, "Python Guide for JavaScript Engineers".

The content of this book is completely free and open-source. You can find the repository here: https://github.com/luckrnx09/python-guide-for-javascript-engineers

### Why Write This Book

In 2022, ChatGPT made a huge splash, ushering in a new era of artificial intelligence. Python once again became the most popular programming language in the field of AI. Many AI-related tools have emerged rapidly, with new ones appearing every day. Python's simplicity and its dominance over the years have made it the preferred language for many popular AI projects. Therefore, learning Python has become a ticket to enter these projects. It is an unstoppable trend in the field of AI.

Recently, I finally took the time to systematically learn Python. However, as someone who already mastered C# and JavaScript, the learning process was not easy for me due to the following reasons:
- I was unsure about the differences between Python and the languages I already knew. To avoid missing important knowledge, I had to study every detail instead of just skimming the surface.
- I was unsure about the similarities between Python and the languages I already knew. As a result, I wasted a lot of time relearning programming concepts that I had already fully grasped.

Due to these two uncertainties, I put in a tremendous amount of effort and persevered to complete my systematic learning. After finishing my studies, I explained key concepts in Python to my frontend developer colleagues by combining and comparing the syntax and features of Python and JavaScript. I found that they were able to quickly grasp Python development just like I did.

Therefore, I decided to organize the key points I encountered during the learning process into a more detailed book. I hope it can help more JavaScript engineers avoid common pitfalls and obstacles when learning Python.

### Key Features of This Book

To improve the learning efficiency, this book extensively uses examples and a comparative teaching approach. I first demonstrate how to achieve a requirement using JavaScript and then reimplement it using Python code. Through this comparison, you will gain an intuitive understanding of the differences between the two languages.

At the end of each example, I also present a table showing equivalent APIs in JavaScript and Python. These APIs may not appear in the example code but are commonly used in development. While it is not necessary to master all of them immediately, knowing about their existence in advance can be very helpful for writing simple and efficient Python code.

### Target Audience

This book is only suitable for JavaScript developers, especially those who are familiar with the latest ES standards and Node.js.

### How This Book Was Written

My open-source project abook https://github.com/luckrnx09/abook, is an AI book-writing tool based on ChatGPT. The core idea is the "examples + comparative teaching" approach mentioned above. The initial draft of this book was generated using that tool. I then spent several months proofreading, adjusting, translating, and polishing the draft to present the final version to you.

### Errata

Due to my limited knowledge, errors may occur during the writing process. If you discover any mistakes in the book, I welcome you to submit a pull request through the "Edit this page" link at the bottom left of the article to help improve the content of this book.

---

## How to Use the Book

### Environment Setup

Python is a backend programming language. For teaching purposes, all JavaScript code in this book should be run in a Node.js environment unless otherwise specified.

### Supplementary Code

This book contains numerous examples and code snippets. I encourage you to type them out yourself to deepen your understanding. Due to time and resource constraints, we do not provide a separate download link for the example code. We appreciate your understanding.

### Refer to the Official Documentation

Official documentation is a primary source of information. Any materials translated, reproduced, or paraphrased (including this book) may be incomplete or contain errors, making it difficult to establish a comprehensive knowledge framework. When reading this book, if you encounter any problems, I recommend consulting the official documentation instead of searching for answers on search engines.

### AI-Assisted Learning

ChatGPT greatly reduces the learning curve for acquiring a new programming language. Therefore, when encountering difficulties, asking ChatGPT for help is a highly efficient learning method. I have recommended ChatGPT to many of my developer friends, but very few have been able to use it effectively. I believe there are two main reasons for this:
 - ChatGPT has a learning curve and requires systematic learning to be utilized effectively.
 - The quality of answers obtained from ChatGPT is closely related to the questions asked. In other words, it tests the questioner's ability in analyzing, summarizing, and presenting the question. Many questioners are unwilling to spend time on these aspects, and they often ask ChatGPT questions without careful consideration.

For learning Python, a simple and easy-to-learn programming language, we do not need to master too many questioning techniques because the scope of questions is vertical and relatively narrow.

For example, when we need ChatGPT to explain how to achieve the same functionality as the JavaScript filter method in Python, we can ask:

<div style={{
    border :'1px solid #666',
    padding: '1em',
    margin: '1em 0'
}}>
Translate the following JavaScript code into Python:
\`\`\`javascript
const numbers = [1, 2, 3, 4, 5]
const odd = numbers.filter(x => x % 2 !== 0)
console.log(odd)
\`\`\`
</div>

The example above demonstrates that there is often a need to transform the actual question we want to ask into a question that we can present to ChatGPT. I believe you have already understood the techniques involved through this example.

Now, let's open the door to the world of Python together!