Python vs Go and implementation

reza andriyunanto
Apr 27, 2018 · 3 min read

Go? why? that is programming language from 2 year ago. And why Go must appear when python, java and another else was exist?

Here the explanation :

Go was born out of frustration with existing languages and environments for systems programming. Programming had become too difficult and the choice of languages was partly to blame. One had to choose either efficient compilation, efficient execution, or ease of programming; all three were not available in the same mainstream language. Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python and JavaScript rather than C++ or, to a lesser extent, Java.

So, if you are using python now and want to try using Go, here some different between Go and python.

1. Dependency library

As python user, we use pip to get library that not exist on our local development directory. For example when we want to install Flask, you write like this :

$ pip install Flask

And we can find all the library of python from PyPI to search all package that available to get.

As Go user, we use govendor to get library that we need to use, as simple as python, for example, we want to get library gin, that is framework to create a RESTful API,

$ go get

Whut? wait, is that get code from github? yes, actually you can use another repository like gitlab, but with additional settings.

2. Performance

I using Go for RESTful API and python for data processing, so if I compare that case, that will not fair, so I show you result from someone test, that you can check on this link.

from that result, Go is overkill vs python, but we must remember there any case that Go losses by python. As we know, Go is great on their concurrency and Python win with all those support for data processing. Thats why micro service architecture was exist.

3. Syntax

You can breathe free, in Go, you still don’t need semicolon for the code, except, you want to write more than one line code in one line, so you need break each using semicolon. Here snippet Go code :

func autoMigrate() { 
var profile
Profile db := InitDb()
defer db.Close()

I assume that you was know about python style code, the another different is when python using indentation, in Go still using curly bracket to grouping code that belong to which function.


Like what I was write before, go so powerful to handle concurrency, here is sample code that implement concurrency to scrapping data, many data from url.

And Python is suitable when you need processing data, because there many package that support for image processing. Here is example python code to process many of news and give recommendation to user when user input keyword.

On the next, I will discuss about how to process many of news and give recommendation to user when user input keyword in this article.

reza andriyunanto

Written by

Backend Engineer, Tech Enthusiasm, Love data and sometime curious about anything.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade