4 ms·
Ask HN: In what areas is Go better than Python?
I know Python quite well and I plan to learn Go. But before that, I want to know whether is it worth or not.
I believe everything that Go does can be done in Python. Are there any areas where Go is significantly better ?
Please enlighten me.
- kelseyhightower 11y agoI don't think looking for better is the right way to go about this. There are many things that are different in Go which you might find a nice fit for a specific use case. Also, nothing wrong with learning another language to increase the number of tools in your toolbox. I'll list a few use-cases where I found Go to be a great fit for me. Building command line tools: Both Go and Python are great for building command line tools. One place where Go is different is that it's super easy to produce statically linked, self-contained, binaries. The result is less dependancies to manage at install time. Many users find tools distributed in a self-contained binary easier to get started with -- no need to have the right runtime (python 2.x) installed. Example: https://github.com/kelseyhightower/confd https://github.com/kelseyhightower/confd Building web services: I'm always building small services to solve a problem and this is one area where Go really shines for me. Out of the box Go ships with a "high performance" web server. Just import the "net/http" package and off you go. While the built-in web server is not a full replacement for something like Nginx (rate limiting, rewrite rules, etc), it does allow you to go really far without the need of an external web server for performance. Example: https://github.com/kelseyhightower/coreos-ipxe-server https://github.com/kelseyhightower/coreos-ipxe-server There are other benefits to Go like performance gains if you are willing to trade in the flexibility you get from a dynamic language like Python and migrate to a strongly typed language that must be compiled before running your code. While Go is strongly typed it does not get in the way of getting things done. The Go compiler is fast and stays out of the way. I'm not sure what your background is, but I did a talk a few years ago at GopherCon 2014, "Go for Sysadmins" (https://www.youtube.com/watch?v=wyRbHhHFZh8 https://www.youtube.com/watch?v=wyRbHhHFZh8), that provides a nice introduction into why I like Go and some live demos to drive key points home. Hope this helps.
- aviaryan 11y agoThanks for your input. Two points that really shines out for me are the "compiled binary" and the "performance" factor. I will give Go a go.