00 Preface Deeply Understand Python From an Engineering Perspective

00 Preface - Deeply Understand Python From an Engineering Perspective #

Hello, I am Jingxiao.

I am a full-stack engineer at Facebook, currently working in the field of machine learning, specifically focused on recommendation systems and algorithms for artificial intelligence. During my career, I have led the development and implementation of multiple products with millions of users, gaining extensive engineering and practical experience.

When people first hear about machine learning, many may think it’s “difficult” or “impressive”. But in fact, my journey in programming was not always smooth sailing.

Unlike those who grew up in big cities or started programming at the age of 11 or 12 through competitions, I had almost zero programming foundation when I entered university. C language in my freshman year was the first programming language I learned from the beginning. The world of computer languages fascinated me, and it became my initial motivation to become a programmer.

Like many people interested in programming, even if the teacher was just reading from outdated course materials on the podium, I would listen attentively and take diligent notes. Additionally, I bought many thick books and searched numerous blogs and posts online, typing code line by line following the examples. There were many concepts I didn’t understand, such as pointers and recursion, even after reading a lot of materials. But with rote memorization, I could pass the exams, although the process was quite painful and tiring.

Later, in order to gain a deeper understanding of computers, I went to Columbia University to pursue a Master’s degree in computer science and gradually learned various new programming languages, such as Node.js, Python, PHP, Scala, and so on. During this stage, I found the learning process to be much easier while working on projects.

These two stages of learning had a huge difference in terms of rewards and experiences. Could it be just because “getting started is always difficult”? I have reflected on this question more than once and finally discovered that the problem lies in the learning materials.

Why do I say that? Firstly, many things in books or online are too theoretical, with very few examples. It’s difficult to truly grasp them by only memorizing. Secondly, there is a lack of original viewpoints and experiences in these materials. Most of them are copied from each other, lacking practicality and deviating from real engineering. They provide little value for reference.

However, it is clear that we individuals cannot solve the problem with available learning materials. What we can do is to overcome the shortcomings of traditional resources and find alternative learning methods. The most important thing is to approach learning from an engineering perspective, focusing on practicality, practicing more, reading more, and working on more projects in order to achieve substantial improvement.

During my years of working at Facebook, this viewpoint has been validated. The newcomers around me tend to rely solely on studying and practicing with books when learning a new language, making it difficult for them to apply their knowledge. On the other hand, experienced colleagues take a different approach. They can quickly grasp the basic syntax and then consult experts on the more difficult and error-prone aspects. Finally, they complete a project themselves, achieving a comprehensive understanding. With this approach, they can master a new language in just a few weeks.

Such a gap can be disheartening, and it is also the initial motivation for me to start this column - to help more entry-level programmers grow rapidly. As for the theme of this column, I chose the programming language Python, and the reasons are quite clear.

First of all, it comes from my personal understanding. Through years of learning and work experience, I realized deeply that mastering a programming language and its learning methods is the foundation for further development in any field. Moreover, in practical work and life, I have come across many examples where individuals excel in algorithms and theory related to machine learning but have only average programming or engineering skills. As a result, when it comes to engineering-focused tasks or collaboration, they often find themselves lacking competence, which is a great pity.

Besides, it is undeniable that Python is indeed the most popular and necessary programming language of this era. Python can be applied in multiple domains, including data processing, web development, artificial intelligence, etc. It has a concise syntax, high development efficiency, strong portability, and can easily integrate with other programming languages such as C++. Nowadays, many schools even offer Python courses for liberal arts students or even middle school students, demonstrating its importance.

Therefore, I have decided to create this column to explain the programming language Python from an engineering perspective. I am not a language expert, and I won’t dwell on obscure knowledge points. Instead, as an engineer, I will start from practical examples encountered in my work and use them as the main thread to explain Python’s core technologies and applications.

All the content in this column is based on the latest version of Python 3.7. It includes a lot of exclusive interpretations, cases, and my own discoveries and experiences after reading the source code. At the same time, in terms of level division, I hope to strike a balance between difficulty levels, progressing gradually. The column will cover both core fundamentals and advanced operations, striving to be suitable for both beginners and experienced programmers.

In terms of content, the column is mainly divided into four major sections. 1. Python Basics

The first part mainly explains the basic knowledge of Python. Of course, unlike other basic textbooks, this column’s basic section not only covers basic concepts and operations, but also includes many advanced and difficult knowledge points, as well as some important and potential pitfalls. If you think you already know the basics, so you don’t need to study this part, then you are completely wrong. For example,

  • What are the differences between list and tuple storage structures? How do their performances compare in detail?

  • Do you really understand the time complexity of string concatenation?

Without a solid foundation, everything will collapse. A deeper and substantial understanding of the basics is the cornerstone of a more solid knowledge structure. I hope this section can not only help entry-level programmers fill in the gaps and strengthen their foundation, but also provide experienced programmers with a renewed understanding of the basics from an engineering perspective.

2. Python Advanced

This part covers some advanced knowledge of Python, such as decorators, concurrent programming, and so on. If your work only involves writing scripts of less than 100 lines, you may not need them very much. However, if you are involved in the development of large-scale programs, they are extremely necessary. Through this section, I hope to familiarize you with various advanced techniques and help you truly understand Python and its characteristics as a programming language.

3. Python Coding Standards

This part focuses on teaching you how to write more standardized and stable programs. Through my work experience, I have seen many programmers who can write programs but do it in a rather “unsightly” way, resulting in continuous errors during debugging and making modifications very difficult. Therefore, I believe it is necessary to have a separate section dedicated to explaining this problem.

Of course, I will not use ambiguous standards to preach, but rather teach you how to improve code quality through specific programming practices and techniques. For example, how to decompose code in a reasonable way, how to use assertions, how to write unit tests, and so on.

4. Python Practical Projects

Those who have not been on the battlefield and fired a gun cannot become commanders; language learners without practical experience cannot become experts. In this part, I will use a concrete practical case – a quantitative trading system – to help you comprehensively apply the Python knowledge you have learned so far.

To truly master a programming language, it is not enough to simply learn individual knowledge points. It is also necessary to connect these knowledge points and work on medium-sized projects in order to have a deeper comprehension and improvement.

Although this column consists of only 40+ articles, each one is full of practical knowledge. I hope this column can help more entry-level programmers and those with some project foundations to truly master Python and provide you with some learning insights.

After 100 days, let’s advance to become Python experts together!

Exercise code for the course: https://github.com/zwdnet/PythonPractice