Programming in weakly typed languages
I’m a firm advocate of strong typing since allows the compilers, JIT’s and interpreters to optimize data according to their data type, which allows a much faster execution and less memory footprint.
However, I see the benefits of having weakly typed languages since it’s easier for newcomers and if speed isn’t an issue especially in small scripts or programs, it’s much simpler just to type the variable name, and let the JIT or the interpreter do the data type conversion when data from different types need to be manipulated without the need of typecasting.
I’m from the time where every clock cycle counted since computers were slow for what it was demand. At that time, the web had given its first baby steps to provide dynamic content.
C/C++ and desktop applications were what the users rely to deliver complex operations.
Then, the internet boomed, and the computers got faster and faster at Moore’s Law rate. The paradigm shifted from personal computers to the web, and later to the cloud. Computers were no longer slow, and we no longer rely on personal computers; step by step, it was the web servers that executed the scripts and applications. The cloud, micro-services and other methods allowed to massive parallelization at controlled cost, and with it, large scaling become possible without the need of mainframes.
At this point, I would like to highlight that type of hinting, although it provides a checking mechanism it doesn’t optimize the code for a specific data type, and it’s still possible for a variable to change its type when its value changes.
Python – A dynamic typed language
Python is known for being an easy language to use. In my perspective, its strong point is its close relationship with C. The fact that integrates so well with C, allowed for a long time to be used as an easy way to allow the users to extend C desktop applications. Almost all the 3D content creation applications allowed the user to write its own python scripts. On Linux distributions is also quite common to have GUI applications written in python.
However, it was its symmetrical relationship with C that allowed it to boom when Data Science became increasingly popular. Python is easy to use but isn’t fast, as Guido van Rossum, its creator, clearly stated, and Data Science is mainly about the very large volume of number crushing which could be agonizing slow if we were only to rely on Python, but Python is designed from the ground up to have its packages written in C, and with the essential data science packages such NumPy, Pandas, Scikit-Learn, TensorFlow, taking the advantage of the GPU and parallelization, Python has skyrocketed in the realm of the Data Science, and it’s now one of the top popular languages.
Also, Python has embraced the power of type hinting since its version 3.5, although, as its authors stated on PEP 484, “Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention”.
In the case of Python, although, version 3.5 has been around since 2015, type hinting is still something that isn’t common in the developers debate about their programming habits.
If I could predict the future, I would see the developers do a slow shift into adhering to stricter and stricter type checking systems, and in the far future, if enough developers write code with types, I believe that the JIT’s and interpreters will be able to optimize the application based on that, almost like it does the strongly typed languages.
written by Alexandre Freire