Dynamic typing
Majority of people have a single problem with a python feature and drumrolls it’s Ducktyping. In short "If it walks like a duck and it quacks like a duck, then it must be a duck". I agree that this could be a case of lot of bugs if developer’s are not careful with it.
I would even go out and say bugs occurring due to this feature are not uncommon(I have faced them myself) but that’s not a mistake with the language but with the programmer.
If you are not writing unittests to catch those bugs that’s on you and not on the language.
Also with python3 you can specify your variable types, so all those people complaining about python’s static typing (or lack thereof) are all talking about python2. Python3 has already fixed that with optional static typing.
https://www.youtube.com/watch?v=GiZKuyLKvAA
Now people who worked in companies where there majority code was written less than half a decade ago have it written in Python2(which even companies in silicon valley still use and they have no motivation to switch) and there is where you find most of the people complaining about it.
Golang can be dynamically typed too(It supports both). It uses var. Would you blame golang if some bug arises due to using var.
Python is object oriented and hence easier to read
which Golang isn’t. It has its own interface and similar stuff but technically there are no object oriented concepts in golang which is what surprises me when people say it is good for larger projects.
Now I am going to take a leap and offend some people here who love functional more than OO paradigm.
Reading golang looks like a mess, and for a programmer new to the code base, it is significantly easier for him/her to understand Python than figuring out what’s going on with golang.
You are wasting precious dev hours(and hence your money) using it.
Speed of python vs go
Here is where most of the golang supporters win or do they. It is beyond doubt the development time is significantly lesser than golang while golang being interpreted and with concurrency built in, is faster in execution and hence faster than python.
What does it matter to you more saving 1000 nanoseconds per request or developer time is completely contextual.
But but python is not concurrent.. It has GIL(global interpreter lock). It does and that’s not a bad thing.
I would even question do you really need concurrency before using it.
If you can do without it, save yourself the time and helplessness of debugging concurrent programs and the possibility of race conditions they can come with.
Also according to Martelli Model of Scaleability
- 1 core: Single thread and single process
- 2-8 cores: Multiple threads and multiple processes
- 9+ cores: Distributed processing
Martelli’s observation: As time goes on, the second category becomes less common and relevant. Single cores become more powerful. Big datasets grow ever larger.
The only way python natively falls behind is in the second category. Did I use the word natively. I did. Are there python libraries which you can use to achieve performance in the second category. There are.
And the only reason to use them or preferably golang for that matter would be if your application is CPU bound or IO bound and then in that case you might want to use concurrency.
You are better off not using it in most cases.
What do you think. Did I miss anything..Let me know in the comments.
2 Comments
Nishant Patel · January 23, 2019 at 6:03 am
Loved your style and application level of comparison between the two.
As i am not that big fan of Golang, but still python beats most other contemporary languages in terms of flexibility, if we even take into account Rust or Kotlin.
Though Python have GIL in, but yet we have greenlet and gevent to come for our rescue.
Would love to see more articles from you, its great to read them.
admin · January 24, 2019 at 11:11 am
That’s right..spot on. Thanks. appreciate it