Civil and Structural engineers have multiple reasons to learn how to code. Many times, we see that our students try to learn the popular coding language Python as their first language. However, what we find is that often times, students encounter headwinds that make it difficult to achieve success in applying Python to civil and structural engineering workflows. In this article, we are going to help you understand
- Why Python is a popular language to learn for Civil Engineers
- The Python Pitfall for Civil Engineers
- Should you learn Python as a Civil Engineer?
By the end of this article, you will learn some practical steps for you to not just to learn Python, but to decide if Python is right for you as a Civil or Structural Engineer and other languages to consider that are more commonplace in the Civil Engineering industry.
Why Civil and Structural Engineers learn to Python
From what we see with our students, the typical journey for a civil engineer learning to code starts with shopping for a coding language. Most of our students start with a quick google search for “What is the best coding language?”. This will result in many lists of coding languages, but most of these lists will have at the following 3 languages:
- Python
- Javascript
- C#
Most lists you are likely to find rate the the languages such that number 1 in the list is the ‘best’ language, with Python quite often taking the top spot. So if you are a civil or structural engineer looking to learn coding, you are likely to see that Python is rated as one of the top languages to learn. As a smart and ambitious civil engineer, you naturally will want to learn the ‘best’ language, and proceed to choose Python as your first coding language.
The Python Pitfall
There are a few pitfalls inherent in what we just described and we see our students falling into this trap all the time. Here’s a few reasons that by following this process, you are setting you up for failure in applying programming to your Civil and Structural engineering workflows.
There is no such thing as the ‘best’ coding language
There are hundreds of coding languages that exist in the world. You can imagine that it takes quite a lot of work to create a coding language – nobody is creating languages that people do not use. So why are there so many? Because different coding languages perform better for different use cases. There is no one ‘best’ coding language for every application in the world. So if you as a civil engineer decide to learn Python because it was deemed the ‘best’ coding language out there, remember that it really comes down to what you are trying to achieve and the effort/reward ratio for you to arrive at that goal.
Python can be easy to learn, but difficult to apply to civil engineering workflows
So without a doubt, a civil engineer that learns Python has learned a very useful skillset. However, as we have discussed, different coding languages are optimal for different applications. If we look at the ‘best’ coding languages that Google recommends, each of them has a unique challenge for Civil Engineers to adopt them in their jobs and workflows. Let’s take a look at the most recommended language – Python. Python is generally ranked as a top programming language to learn because it is easy to learn, flexible, and used extensively in data science. So one would think Civil Engineers learning Python would be off to a good start. However, the average Civil Engineer will find it hard to use Python for anything that relates to typical civil engineering software such as Finite Element, BIM, or CAD programs. For instance, while Python can used with CAD, it requires the use of third party packages that must also be learned. This involves learning a whole new skillset, understanding how to use open-source code and navigating code documentation, all of which can be daunting for a beginner and delays arriving at outcomes for your Civil Engineering workflow.
Learning Python doesn’t necessarily give benefits to your workflows
Even if you do learn Python, the tutorials and courses you find will not help you apply the language to civil and structural engineer workflows. We have discussed before that much like engineers need a certain knowledge of first-principles from mathematics, material science, and physics, an engineer trying to learn computation will benefit from learning some first-principles from computer science. Note that learning these first-principles is not equal to learning a computer language, but rather, learning some core concepts that will be present in any computer language. These first principles will be the ‘why’ behind your scripts, whereas the coding language will be the ‘how’. This is why our Computer Science for Engineers courses are prerequisites to most of our coding tutorials on TCE. Learning these these first-principles will accelerate your learning curve towards being a computational engineer.
What we find is that our students often struggle with going from Python tutorials to their jobs as civil engineers. Yes, these tutorials teach them how to code in the Python language, but the examples and homework problems of the tutorials are all distant from day to day civil engineer tasks. Civil engineers often succeed in learning python, but fail in applying python to their work without specific examples of how to use python to automate their calculation, or use python in CAD or BIM. Practically speaking, while civil engineers can use Python, it is not tremendously common for computational engineers to use Python in practice.
Should I learn Python for Civil Engineering?
The answer to this question is “it depends” (annoying, we know!). Remember, your choice of coding language should be related to what you are trying to accomplish.
If you want to gain an appreciation of coding and using code then the answer is ‘yes’, as learning Python will help you with this. Are you trying to automate the creation of a Finite Element Model from a Revit model? In this case, you will find that other languages will allow you to achieve success with a fraction of the effort. Are you trying to generate the geometry of a building’s structural frame, its facade elements, or even its utility network? In this case, you will find that Python does not lead you very easily to wins in your workflows and you should use other coding languages instead.
Practically speaking, the most common coding languages you will find used day to day in a civil or structural engineering company are:
1) Grasshopper
2) Dynamo
3) BHoM
4) C#
You can read more about the pro’s and cons of each of these languages in our post on Common Programming Languages for Civil and Structural Engineers. In most cases in civil engineering companies, Python will be used through Dynamo, but can also be employed through Grasshopper and BHoM as well.
In conclusion, before jumping into Python as a civil or structural engineer, make sure to remember that learning a coding language is a fundamental skill of the 21st century, but also, applying coding your civil or structural workflows is about more than knowing a coding language, and that different coding languages will be easier to implement in civil engineering than others.