If you learn a programming language, it should be C / C ++. But if you learn two, here’s an argument that the other should be Python.
Why would you want to spend the time learning another programming language that will be out of date before the next president arrives?
Well, my friend, I will tell you a little secret. If you are willing to learn one more language, it can open up a whole new world for you.
As electrical engineers, if you learn a programming language, it should be C / C ++. You need it to program the microcontrollers, configure the registers, and you’ll be designing and writing test firmware to exercise various parts of the circuit. It allows you to drill down into the nuts and bolts of hardware, write values to different registers, access memory buses, and control hardware peripherals.
But if you learn two languages, I would argue that the other should be Python.
Image used courtesy of christina morillo.
Power and control versus simplicity and flexibility
The reason that C ++ is so useful to hardware designers is the exact reason that it is not so good at writing applications. You have all kinds of control over metal, but how you control it is your entire responsibility. You need to make sure that you deallocate any memory that you allocate, that your pointers actually point to valid locations in memory, and that your data types are allocated correctly and not overflowing.
What you get from all that knowledge is raw power and speed, but heaven forbid you make a mistake as it could send the entire application or even the entire system to the crash.
This is where Python is a pleasure to work with. Sometimes you don’t need all that speed or control things in memory so hard. Instead, you just need something to work with.
Python is one of the fastest growing programming languages. Image used courtesy of David Robinson via StackOverflow.
Python extracts many of the details that we need to deal with in C ++, such as memory management and variable data types. No more worrying about whether a variable will overflow or whether the correct amount of memory was allocated or deallocated. All that happens magically in the background. You just have to focus on putting the code on paper (virtual).
What really makes Python stand out as a good second language is its large and growing community, the great support of open source libraries, and that it supports a diverse set of applications such as web application programming, data science , data visualization and general purpose automation. Those are all hugely powerful domains that are awfully complicated if you try to use C ++.
Even something as simple as opening a file and parsing its contents – something EE has to do regularly for all sorts of things – is painfully easy in Python. Here is an example where we open a file and print its content on the screen:
The case of Python
This article is a starting point for a larger series on Python when it comes to electrical engineers. As we go through this series, I hope it becomes more and more apparent why an understanding of Python will open new worlds to an electrical engineer.
Even though I just used a very trivial file analysis example above, that is the foundation of tons of design automation as well as data science. Beyond that, we will explore various libraries to learn how to configure databases, web servers, create a REST API, extract large data sets, create polished data visualizations, detect objects with a webcam, and provide you with a bit of information. machine learning. I threw out that last one because it’s all the rage in technical (and non-technical) circles. You can impress the tech hipsters you talk to at Starbucks with that.
Data visualization in Python using Seaborn. Image used courtesy of Insight Data.
So put on your programming hats and stay tuned as we embark on a journey to explore new frontiers of technology from the eyes of an electrical engineer. I hope this series will not only allow you to automate things more efficiently, but expand your world beyond hardware and circuit design and complex system design – systems that not only involve electronics but take advantage of mountains of technology. which allows understanding of Python. you to access.
What do you think of Python? What would you like to learn about it? Share your thoughts in the comments below.