What's the Best Programming Language for Beginners?

Share

If you have interesting in programming computers and want to start learning to program, one question that will come up in your mind sooner or later will be: what programming language should I learn? After all, there are various, and you don't even know the difference of one programming language to the other. Is there are lot of difference? Which language should a programming beginner learn first?

In my opinion, the best programming language for people who know nothing about programming is Python. However, it takes a bit of effort to configure it, so it's easier and quicker to start with Javascript, which doesn't need the installation of any special program because it runs in your web browser. Other good options are C# and Java. On the other hand, there are languages that are well-known and popular but are terrible for beginners, such as C++, C, and PHP. Besides these there are also less popular languages, and languages for learning purpose which won't be able to be used in real projects, and, honestly, aren't even worth considdering.

The First Obstacle is the Logic

Although Python and Javascript are excellent languages with many applications, they are not perfect for everything. There are programs that would make more sense to program in C or C++. Application that should be programmed in C# or Java. And even PHP has its own unique advantages. However, if you don't know anything about programming, regardless of your objective, you should start with Python or Javascript.

The reason is simple: logic.

For someone who has never programming in their lives, writing algorithms, even the simplest ones, and understanding how flux control structures work is extremely difficult. Python is a language that's very abstract, in the sense that there isn't a lot that you need to specify in the code, there aren't many possibilities, options, there isn't a lot where you can error. On the other hand, C is a language that is very concrete, that requires you to describe everything in specific terms, and that has a lot of similar code for completely different things, so there's much higher chance for you to make mistakes. The result is that you won't learn one thing after the other, you'll have to learn how algorithms work, and how C works, both at the same time, which makes the process a lot harder. Although you could say this for every language, how much the language gets in the way of learning programming varies from language to language, and Python, in my opinion, is the one that gets in the way the least.

Examples of Differences

So we can have a better idea, I'm going to write here some examples of code in each language, so we can have an idea, more or less, of why some languages are better than the others.

Python

Python code is extremely simple. Observe:

x = 10
x = 'text'
if x:
    x = True

def func():
    x = 30

func()
# the value of x is True.

Code blocks are defined by their indentation. Defining a variables declares it. Defining a variable inside of a function doesn't modify a variable outside the function, but declares a new variable of same name inside the function.

Javascript

Javascript code is similarly simple, except that now we have more to write.

x = 10
x = 'text'
if(x)
    x = true

function func() {
    x = 30
}

func();
// the value of x is 30.

When a variable is defined for the first time, if it's preceded by let it's part of the scope of the external block, if it's preceded by var it's part of the scope of the function, and if it's not preceded by anything it's part of the global scope. With that, although declaring variables at global scope is a terrible practice, the code at least works.

C

C code is not simple.

int main()
{
    x = 10 // wrong
    int x = 10 // wrong
    int x = 10; // correct
    x = 'text'; // wrong
    int x = 'text'; // wrong
    char* x = 'text'; // wrong
    y = 'text'; // wrong
    char* y = 'text'; // wrong
    char* y = "text"; // correct
    if(x)
        x = true; // wrong

    #include <stdbool.h>
    if(x)
        x = true; // correct

    void func() { // wrong

// correct:
#include <stdbool.h>
void func() {
    int x = 30;
}

int main() {
    int x = 10;
    char* y = "text";
    if(x)
        x = true;
    func();
}

C code is executed starting in the function main, which means that you can't just start writing code that will be executed, you need to write a function main CORRECTLY first. The syntax doesn't let you write functions inside other functions (Python and Javascript allow it). You are required to declare variables that you will use, it's not allowed to redeclare them, they must be declared with the correct type, and there's a difference between text (strings) written with single quotes (') and double quotes ("). The final touch is that there is no true keyword in C, it has to be imported, or rather, the code that defines its value has to be included from stdbool.h. Ah! And we can't forget: the semicolon at the end of each line, or it won't compile!

We can say that the advantage of this is that the language turns errors of logic in errors of syntax which the compiler can notice. However, for a person who is a beginner learning programming, even when you write code that has no logic errors you can still get syntax errors that won't help you in anything and will only bring you headaches. Besides this, in this case specifically we're talking about a language that has its origins when computers were much slower. These days we have languages like Go and Rust which are as capable as C, but don't require the programmer to write the type of the variable in its declaration, since it can be inferred by the compiler.

C++ isn't much better than C in this aspect. However, C# and Java have a big advantage when we introduce concepts of object-oriented programming. In C# and Java (and Python and Javascript), the language is responsible for deleting the memory of an object that is no longer used by the program. In C and C++, the programmer is responsible for this, and with that is also required to understand how memory allocations in a computer work.

Although this is all knowledge that is good for a programmer to have, it's not necessary to learn all of this at once. It's not necessary to have knowledge of pointers in C to understand how objects passed by reference work in Javascript. Using a phrase that programmers know: these things are implementation detail: it's not necessary to know how a computer works exactly in order to learn how to write algorithms that this computer will execute.

With this in mind if you want to start learning programming, start with Python or Javascript. You can learn other languages, or the language you need to do what you want, after you have learned the basics of programming.

Comments

Leave a Reply

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