I’ve decided to learn a new programming language this year. It’s going to be Python.
Why Python you ask?
It’s something new, kind of different than Java (the programming language I currently work with) and provides some awesome features. This is my current top 5 list of Python features.
1. Dynamically Typed
Python is dynamically typed whereas Java is statically typed. The difference between the two type system is that Java determines the type at compile time and Python at runtime.
This makes Python a lot more flexible. You don’t have to define the type of a variable, Python infers it from the variables value.
Although Python is dynamically typed it is still is strongly typed. This means a variable that holds a string value will always be of the type string. You cannot modify type of a string by e.g. adding a number to it.
2. List Functions
Python provides some awesome list functions. This is one of the most powerful features of Python.
You can easily define a list.
You can also apply a lot of functions on lists.
However, the coolest feature for lists is that you can apply functions directly on lists (and all its items). You can use this to modify all elements in a certain list. And you do all this in one line.
3. Named Arguments
You can define named arguments for methods and set default values for them. Later, when you invoke the method you can set the values of the arguments by name.
This allows you to use certain default values and only pass the necessary values to the method.
Python is really easy to read. There isn’t any clutter, nearly nothing that isn’t absolutely necessary.
Differently than Java, which uses curly braces for defining blocks, Python programs use intention for doing that. This also means, that most Python programs will look similar.
Therefore it is easy for developers to read any Python program by any developer. You will probably agree with me that this is one of the most important features of any programming language.
5. Purely Object Oriented
In Python everything is an object. There are no primitive data types as in Java.
Even though it doesn’t change the basic programming principle it makes Python differently from Java. I wanted to learn a purely object oriented language for once. Therefore Python seems to be a very good fit.