A Brief Summary of Advantages and Drawbacks of Python
Python is the most popular programming language nowadays. Based on my own experience, here is a list of advantages and limitations/drawbacks of Python:
Advantages:
1. Easy to learn: Simplicity makes the learning curve of Python is low. Basically one can pick it up from a few days to a few weeks.
2. Versatile: Python code can be found almost everywhere, such as web applications, desktop applications, data science, big data, spark, cloud, etc.
3. Flexible: Flexible syntax makes its code easy to write.
4. Python is a hybrid of several programming language types. It supports Object-oriented programming, Procedural programming, and Functional programming.
5. Generator is a very useful feature.
6. Python has a comprehensive ecosystem, supporting community, extensive libraries, and 3rd party modules.
Limitations or Drawbacks:
1. Some syntax brings inconvenience when writing code or even makes its code error-prone. Example A: Python code uses indentation to define scope, instead of brackets. Example B: If you want to call a function, the definition of the function must be defined before the caller, otherwise the function cannot be found.
2. Python is interpreted instead of compiled. You may modify code on-the-fly, but the result may be not what you expected, as the old code is cached.
3. Python is not strongly typed language. Type is determined at run-time only. Thus it is not type-safe before running.
4. As an interpreted programming language, Python’s performance is not as good as compiled ones, such as C-family languages (C, C++, Java, C#, etc.). Usually it is slower.
5. By design, there is no explicit pass-by-reference parameter. Although there are some mechanisms to mimic pass-by-reference implicitly, for example, use dictionary as a parameter. Such implicit pass-by-reference behavior may confuse people. People need to be very clear what data type is pass-by-value, and what data type is pass-by-reference.
6. If you want to write multi-threading code, probably Python is not a good choice for it.
A great summary! Very insightful! I totally agree.
What does Compile and Interpreted languages mean? Can you explain them more? Thanks.
Languages like C, C++, Java, C#, need to be compiled to machine code or byte code before running. The compiled code can be or close to what machine can run. So the process is: people write human readable code -> compiler compiles the code into machine code -> computer runs the binary code at runtime. However, by design, scripting languages like Python, Javascript, do not need to be compiled first. The interpreter just interprets the script code line by line then runs it. So the good part of compiled code is faster as it is already half-way, but people need to compile it whenever the code is changed. While interpreted code is more flexible and does not need to be compiled before deployment. A drawback of interpreted code is some errors may be found at runtime only, as there is no compilation process.
Got it. Learned a lot.
SAS is a compile language. It needs to scan and compile syntax first then run it. If it has issues we will get errors before running it.
good summary. I think even java code can have runtime errors as well.