Python is a dynamically typed language. It basically means that you don’t have to declare exact types while declaring a variable. A very good and a very bad thing. As usually, there isn’t anything just good or just bad.
Some cons of Python
A very short list (there will be examples and more information in future posts):
- No const class fields.
- Docstrings are fine, but I can’t declare comments describing class fields, I’ve been using doxygen with C++, and there is such a way for generating documentation for classes.
- Terrible syntax – blocks declared using whitespace (sometimes I think like using the whitespace language).
- Terrible syntax – try to copy some lines from one file to another. You’ve got a 99% of a chance to have something incorrect. Incorrect here means not only that after the code paste there will be problems with interpreting code, sometimes I have problems that code is correct (as for the interpreter) but it works in a quite different way than I wanted.
- No real constants, they are defined by some convention. Constants have to be named with capital letters only what means for others: “Don’t touch that”. But there is nothing that prevents some funny hacker from changing them.
- Due to the dynamic nature of Python, you’ve got to write lots of tests. Writing tests is of course a very good idea, but as for a C++ program you’ve got to test only program logic. In C++ You know that if a function gets an integer as an argument, then the compiler will check that for you. You just cannot pass a string. In Python you have to even check if a function argument is an object of a class that you’ve expected. Truly said: no one makes so extensive testing. The same goes here for other dynamic languages like ruby.
What is better?
- Perl - well… no, due to some funny random code execution (post about this is almost ready)
- Ruby - that’s my favourite so far
- Java - too heavy as for my needs
I’ll give Ruby a chance, now I code in Python, I’ll see how it works.