2 Lessons From Learning Dynamically Typed Language

Categories: Software Development

Lessons from learning python

Last weekend I decided to rewrite my pet project to python in order to run it on Google Cloud Functions. I treated it as an excercise as I did not have any prior experience in either python or Google Cloud Functions. My project was previously written in C#, but as you probably know, Google Cloud Functions do not support that language yet. Therefore I had to rewrite the project into a language that the service supports. I decided to go with Python as it is gaining a lot of popularity recently. I have to say tha this was a very interesting exercise. As a seasoned C# and Java developer, I did not expect python to be that hard. The syntax of the language is very easy to pickup. However, the way you work with the language is entirely different from what I’ve known.

There’s no compiler or IDE you can rely on

In Java and C# world you are very dependent on your IDE. The IDE completes the code for you, the compiler validates the types and the grammar that you use. On the other hand, you cannot rely on a compiler or an IDE when you write Python code. In Python world, you need to rely on the output of the interpreter more than anything else. I still don’t know how to debug or work with a python app efficiently, but I have made some progress over the course of my pet project.

Lesson 1 - Use type hints in Python 3

There are two things that helped me with getting up to speed in this new language. One of them is a feature available from Python 3.5 onwards. This version has introduced a static type hints that you can use in order to get code completion from IDEs such as PyCharm. This enabled me to get some of the intellisense experience that I used to have back when I developed C# code in Visual Studio.

Lesson 2 - Write Unit Tests!

I believe that it would have taken me an order of magnitude longer if I did not write unit tests for my program. Thanks to them, I was able to finish my small project within 8 hours. Testing a function and making sure that a piece of functionality works enabled me to move not so quickly, but I had confidence that whatever small task I have finished, it was coded correctly.

This project also assured me how valuable unit tests are and that they are definetely a necessity in a dynamically typed language.

Good Luck!

If you are going to try dynamically typed language soon, I hope that those 2 tips will make your journey less painful. The first steps in any language are very difficult, especially if the paradigm that you are shifting to, is entirely different from your previous experience.

So if you are getting frustrated with your IDE not being able to help you while you’re developing python code - rest assured that you are not the only one :)

See also

Share this post with your friends

comments powered by Disqus