A Battle of Trios: Python vs Ruby vs Golang

A Battle of Trios-Python-Ruby-Golang

Every computing language has its history, strong points and a framework around which it works. Each language has its era, a peak period of efficiency, utility and popularity. Among the programming languages that are in prolific use, we talk about three prime languages here – Python, Ruby and Golang.

Python: This computing language has been around for 24 years and counting. A prime feature – less lines of code to explain larger concepts. This also means lesser bugs. As compared to Java, Python takes less time to develop, though it may run slower than Java. A class apart and flexible, Python has been best suited for building websites and data analysis. Prominent banks are using it, so are sites like YouTube. Python is also widely used in building games, server maintenance and in making art and music. It’s a great language to build scalable applications too, that’s why most startups love Python.

Ruby: Since its arrival in 1995, Ruby has followed the motto of ‘don’t repeat yourself’, thus saving time and effort, as compared to previous time-consuming programs. A simple example would be, how easy it is to get “Hello, World!” on Ruby in a single short code line, as compared to other languages. There is the often criticized Ruby feature of ‘many ways to do things’. A great language for rapid development, Ruby is used by popular social networking sites like Twitter. There is no need for a specification each time, the code has implicit behavior. A minor complain is that Ruby needs to be constantly updated and maintained.

Golang: The latest prime entrant in this field made its first appearance in 2009, developed as it was by experts at Google. The language follows a minimalist approach. Just like Python, there is only one way to do the right thing here. This may seem like a strict rule to follow early on. But once you get a hang of it, this element facilitates clean code. Golang is fast, allowing programmers a certain degree of control over memory usage. Many startups use Go for its concurrency.

Head to Head

Many Ways vs One Way
Python’s tried and tested path has its advantages, as compared to Ruby’s ‘many ways of doing a single thing’ methodology. In contrast, Python has always focused on ‘the best way to do it’ motto. Minute details with regard to whitespace, indentation and layout are strict rules to be followed. The same rules also make Python very readable. Many educational institutions use Python because of its simple structure. Golang also has a single way to do things, helping in clean code.

Verbose vs Choices
Golang takes more lines to write the same thing as compared to Python. Automatic list expansion is a big plus in Python. Go can be restricted in choices too, for instance, the only loop choice is for loop. Ruby is a crisp language, with useful code generators. The meager need for separate documentation makes Ruby a great team language. Testing has its priorities in Ruby, making it a great testing framework too.

A Matter of Speed
Yet Golang is a faster program, it has great built-in functionality. In comparison, Ruby and Python are comparatively slower, mainly because Golang doesn’t need to be interpreted. More on Go: Documentation is an essential part of the language, parallelism is easier done on Go. An exclusive Go feature: A rich standard library that also contains a fully functional web server. Another Go plus point: A strong community that answers queries and a open-source third party code that can fulfill several tasks.

Beginners’ Concerns
In Go, you just have to type go run mycode.go to compile and run the code, this automatic compilation makes it exceedingly fast. Yet, Go has a strict outlay and is not recommended as a beginners’ language. Python and Ruby are better suited for a beginner. Ruby is considered to be a great language to learn, if you already know a language or two. Python, on the other hand, is a great choice to learn as your first coding language. A certain section of users put down Ruby as a great web framework language and nothing more. Ruby and Python are great languages to run, only the former takes up more memory for faster performance.

Usage Pointers
Ruby is fast gaining popularity; one of its predominant uses has been with DevOps. Ruby is in-demand for DevOps frameworks like Chef and Puppet. In case of API or a backend system, Go is considered the best among the three. From the functionality perspective, Python and Ruby are still the trusted hallmarks with regard to team or project programming. In fact, Python has been compared to the English language for its clean structure. Analytics, system administration and data manipulation suit Python.

Time Factor
In terms of executing object oriented code and functional code, Ruby is faster than Python. Ruby edges out Python on the basis of average run time too. Yet, the latest Ruby version has improved execution speed. Off late, with regard to several functionalities, Go has been found to be much faster than the two languages. Again, it boils down to the program that is been executed at a given time, its scale and its output.

Each programming language has its strengths and weaknesses. With changing times, new technologies and software updates, the status quo as to ‘which is the best language to work with’ is constantly changing. We conclude with a quote from a programmer, paraphrased here:

Any programming language can be regarded to be the best, if the programmer knows what exactly are they accomplishing.

  • gopher

    Hello Snehith. Good article, however, I have a concern here.

    “Golang takes more lines to write the same thing as compared to Python.
    Automatic list expansion is a big plus in Python. Go can be restricted
    in choices too, for instance, the only loop choice is for loop.”

    Golang does use more lines in certain regards, depending on what you want to do. I can have a website going in one line of code (not counting general spec start code [i.e packages, imports, main]). The one thing to understand about golang is that it allows configuration on every level possible, allowing as much flexibility as you’d personally like.

    The for loop is amazingly verbose, did you know that? It can act as any type of loop and more because it’s built to be, at core, for/foreach/forrange/while loops.
    This isn’t about a case in restriction of options, it’s about keeping the language clean, maintainable and not having boilerplate. I, as a long time C and C++ games programmer, welcome this.

    Otherwise, good post!

  • Varun Batra

    Ruby is fast or Python? I believe it is Python. Are you sure about it?

    • Snehith Kumbla

      Thanks for the query Varun, there is no clear cut final word on which is faster. But in context of certain functions to be performed, like executing object oriented code and functional code (as described in the article), Ruby is faster.

    • Ruby faster,than Python.So,plus it’s dynamic and interpretative script language.Python also compiling and scripting language.

    • Gowtham Sai

      In my local, python is pretty faster than ruby. Python finished the same in 16 seconds where as ruby took 20 seconds.
      Macbook AIR, 8GB Ram.

  • JamesLin

    People should choose tools wisely, yes, go is faster but do you need the “super fast performance speed” in your projects? And understand the trade off.