A tale about Python or why it is better not to choose it for beginners

Hello everyone, I am a Full-stack programmer with about six months of experience in team development, as well as about 3 years of experience in creating small and medium-sized projects. Here I want to clarify for newcomers to IT, who are rushing from side to side, trying to find a more in-demand language, and to learn easier, and to squeeze onto the galley.

Simplicity is deceptive

You might think that Python is a very simple language, the speed of writing code is x5, it seems to be needed, look, some graphs, I’m right, but you’re wrong and blah blah blah, but this simplicity and “speed of writing code” ” is deceptive. For now, you probably don’t understand what I mean, but as the article continues, it should become clearer what I said here.
Let's compare, first, identical code in C#, Python and C++:
Python:

Let's compare, first, identical code in C#, Python and Golang

Standard C#

namespace HelloWorld; // Распологаем неймспейс, тоесть, говорим исполнителю о том, какой файл "где находится" в иерархии

class Program // Создаем класс, так как без него приложение нельзя запустить*
{
    static void Main(string[] args) // Создаем программу, которая будет  выполняться исполниетелем, без нее тоже нельзя!"
    {
        Console.WriteLine("Hello, World!"); // Выводим в консоль Hello, World и кайфуем от жизни
    }
}

As we see in the code above, there is a lot of “vagueness”, but in large projects it is precisely thanks to such a hierarchy, or as it is called in OOP style IT circles, that it is easier for a programmer to arrange the hierarchy of classes and methods. For example, we can place all the files in one folder, but access them differently. Example:

Hierarchy:

folder1:
- Program.cs
- Utilities.cs
- Types.cs

But we can indicate in namespace instead of banal %NAME%.Utilities comfortable %NAME%.Utilities.Web, where inside this namespace we can visually demonstrate that there will be a part with web development inside. You can store several in one file namespacebut it is not recommended to do this!

C# with high level writing method

Console.WriteLine("Hello, World!"); // Просто выводим Hello, World!

Immediately, only such a piece of code is open to the programmer. All the unnecessary tinsel, as if from above, disappeared. The compiler will add it automatically, yes, it’s not entirely convenient, but still usable. For a beginner – just the thing!

Python

print("Hello, World!") 
# Здесь как и в C# с высокоуровневым методом просто одна строка с функцией вывода. 
# Ничего нового...

Here is a simple and banal print, you all know what it is, for sure.

Golang

Here is a not very popular one, but quite light and fast, even for corporate development. Example output:

package main // Показываем компилятору что это за пакет, как namespace в c#
import "fmt"; // Импортируем пакет для удобного вывода в консоль

func main() { // Функция, тоже как в C#
	fmt.Println("Hello, World!"); // Собственно, вывод в консоль
}

Take a look at the code written in Google's Golang language, it's a cross between Python, C++ and C#, any idea? But in terms of performance it is as good as C++, and in terms of development speed it is approximately on par with python, despite the fact that it has STATIC typing and an OOP style. We will look at this in the near future, but for now let’s summarize the comparison.

Comparison

C#

Python

Go

A lot of words, but it’s convenient to describe the hierarchy

A few words, what a banality…

There are an average number of words, but you can describe the hierarchy relatively conveniently

You're probably asking: Something is not clear yet, Python uses fewer words to create a basic project with text output to the console, what don't you like, yawaflua?
And I will answer: Watch your hands!

Comparison of languages ​​in terms of ease of writing code!

Here we will make a relatively basic program that iterates over all numbers from 99 to 999, i.e. three-digit, and then checks whether they are evenly divisible by 12 and 11. The Golang program produced 1 MILLISECOND, which is equal to 1\1000 of a second, while python

Program in Golang

Program in Golang

the same program in Python

the same program in Python

As we can see from the comparison, Golang is very similar in program writing. It does not require a semicolon and is statically typed with a lightweight version of variable creation via :=, where the type is set automatically. Golang also beat Python 3.12 by 1 millisecond. You will say: So what, 1 millisecond is not enough, we blink longer, but this is an easy example where numbers are simply multiplied and compared. If we take more loaded examples or older versions of Python, then we get big problems with code optimization. And the lack of static typing makes your code a mess. For example, you want to assign a variable a the number is 7. In golang you would write it like this:
a := 7 // > 7
In Python, you would most obviously write it like this:
a = 7 # > 7

Yes, this is correct, but now you made a mistake in the code and for some reason you are passing not a number (the original one), but a string to the variable:

Go:

a = "Hello, World" // Error: TypeError, нельзя в переменную числа назначать строку

Python:

a = "Hello, World" // > Hello, World, ему все равно на такие манипуляции
This can make developing and debugging your code very difficult!

Summarizing

I've already written on quite a lot of information, so let's summarize:

  • Python, despite the relative speed of writing code, is not as convenient and fast as, for example, Golang

  • Python is quite a slow language (even new versions). I spent little time talking about this here, but Python in production uses too many resources compared to C#/Go/C++ and other normal programming languages.

  • If you choose between Python and Go as the first language for a novice programmer, then I would obviously prefer to recommend Golang!

If you want, I can touch more on the weight and speed of projects in production, write comments, rate, I will try to answer and correct my mistakes. Thank you everyone for reading this article.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *