Choosing a Programming Language for Beginners
Lately, I’ve been frequently hearing the question “where should a future programmer start learning?” Which books to read, which programming languages to look at. Much has been written about books, and I don’t want to repeat it. Instead, I want to provide an overview of programming languages that, in my opinion, are relevant in 2017 for beginners to consider. Beginners can learn any language, even C++, which is rightfully considered one of the most complex. Books have been written for all languages aimed at audiences just starting to learn programming. The languages are not listed in any particular order of importance. Just a list.
-
C: One of the lowest-level languages. Fairly simple. Still one of the most used. Most Linux commands and system utilities are written in C. Many high-performance services are written in C (web: nginx, dns: bind). If you’re going to program for money, i.e., only do what you’re paid for, I don’t think you’ll ever need to write something in C. Although I believe the ability to read C is a necessary condition for someone who calls themselves a programmer. This language is very error-prone. It’s very easy to consume all memory by simply forgetting to free unused memory. Or cause a buffer overflow leading to remote code execution on your server. Most security problems are found in programs written in C and PHP.
-
C++: One of the most complex programming languages. I don’t know of any place where C++ is used to its full extent. Everyone has some agreements about the subset of the language that can be used: somewhere templates are forbidden, somewhere exceptions are avoided. This language is still in the top three most common application programming languages. If you want to write in a relatively high-level language that has classes, many third-party libraries, and at the same time you want to be as close to the hardware as possible, then this is for you. Writing in C++ is much easier (faster, more compact) than in C, but you can make almost the same mistakes as in C. This language is practically the de facto standard for game development.
-
Python: A scripting language executed inside a virtual machine. Hence considered very slow, although this isn’t always true. Python integrates very well with other languages like C, so many Python libraries are written in C. If you want to write a program that will process large volumes of numbers, in fact, you’ll be using high-level calls to third-party libraries written in C by smart people. And your data processing speed will be such that you’ll never achieve yourself, even using C. The language is considered very simple. Probably because you can write your own web server in 3 lines that will serve files from a directory. Or in a couple of lines open a file, process it, and convert it to another file. Very concise language. Has a huge number of constructs that allow you to briefly express complex algorithms. A huge number of libraries have been written for Python. You can write web applications, do scientific calculations, train neural networks or use them. Almost everything can be done with Python. The language is considered ideal for beginners. Many universities are switching their curricula to Python. But the danger of this language is that it hides the hardware from you. You practically don’t think about memory or CPU consumption when programming in this language. Many people, having mastered Python and learned to write in one of the web frameworks like Django, get stuck in this ecosystem forever and when trying to write any other program besides a web application, find that they can’t do even simple things. Python is also one of the most complex programming languages for me. It has a huge number of constructs and nuances if you dig deeper. I can spend all day in an interview grilling someone on Python. You can’t make the same mistakes in Python as in C/C++. You don’t need to free memory, the virtual machine does it for you. You don’t need to watch for buffer overflows, array and string implementations do it for you. It’s an ideal language that can be used to write small automation programs that make life easier.
-
Java: Something between C++ and Python. Like in Python, you don’t need to think about freeing memory, the virtual machine does it for you. Like in Python, code is executed in a virtual machine. But it runs much faster than Python because the language is quite low-level. Syntactically very similar to C++, but has little in common with it. This language is practically the de facto standard in large companies. Has extensive frameworks with good commercial support. Considered the most used language in the world according to TIOBE for 2017. One of the most mature markets. It’s fairly easy to find a job. Recent versions of Java have started moving toward trendy functional and reactive programming tendencies, so it can no longer be called a verbose language for corporations. Practically an ideal language for writing server applications. The infrastructure around the language is the most extensive I know. Excellent IDEs, monitoring tools, build and deployment tools. Many commercial companies write programs that make life easier for Java programmers. A huge amount of information sources: books, articles, conferences, courses.
-
Go (AKA Golang): A relatively young language from Google. Like Java/Python, it has a garbage collector. I.e., you don’t need to watch memory, it cleans itself. Like C/C++, the language compiles to native OS code. I.e., there’s no virtual machine and it executes very fast. Syntax is similar to C. From a construction point of view, it’s a very poor language. But very simple. Google deliberately made a universal language that can be learned in one evening and write your first useful program on the first day of learning the language. Many criticize it for its simplicity, which results in verbosity. But the language is perfectly suited for writing fast web applications. Multitasking and parallelism are built into the language. I.e., your programs can run on all processor cores simply if you write ideologically correctly in Go, and not stupidly rewrite programs from other languages to it. Go is often considered a replacement for Python. Many companies rewrite parts of their systems written in Python to Go to save resources (servers). I don’t know anyone yet who would rewrite from Java to Go.
-
JavaScript: The de facto language if you’re writing an application for the browser. I.e., if you’re going to work with the web, you need to know JavaScript. But you can’t know only JavaScript. Some people write server-side applications in JavaScript. I have nothing against this approach, but if you only know JavaScript and write everything in it just because you don’t know other languages, that’s bad. I have nothing more to say about this language. Many people would prefer this language didn’t exist at all. But the fact remains. This language is built into every browser on earth. And until this changes (and it will never change), JavaScript will be one of the most popular languages.
-
Rust: A modern replacement for C/C++. Free from the problems of these languages such as memory leaks. Many interesting things from other worlds have been added to the language. Source code compiles to native. There’s no virtual machine. There’s also no garbage collector, i.e., it should work without pauses for garbage collection unlike Go. Also unlike Go, the language is more compact. This is probably the only language I wouldn’t advise learning as your first. And it’s not even about its complexity (C++ is also complex). The language is just too young. My first attempts to learn it constantly ran into some inconsistencies. You read a book, do as written, and it doesn’t work because much has already changed. On the third try, I finished reading the Rust book and understood some concepts. The ecosystem around the language is also weak. But I believe this language has good prospects. And many people already use it as their main language. But the community and learning sources are still the weakest of everything listed above.
As separate points, I’d like to highlight Objective-C & Swift. You’ll only need them if you want to write something for Apple devices (macOS, iOS, watchOS).
So, returning to the question of which language to learn first? I don’t know. My opinion on this changes from month to month. Sometimes it seems to me that you need to start with Python. Then after another interview with a person who has seen nothing but Python in their life, it seems to me that you need to learn C, as the most primitive language. These are two extremes. In fact, I think a programmer shouldn’t care what language to write in. This phrase regularly appears in various articles. A programmer should understand the task at hand, see the architecture of the program that will solve this task, and simply implement this architecture in the language that, in their opinion, fits best. I.e., it turns out that you should know all these languages to use the most suitable one depending on the task.
At work, I actively use 3 languages: Go, Python, JavaScript. But outside of work, I read articles or books on other languages. Sometimes I use them for my projects. I would like to have knowledge in all languages. Unfortunately, I haven’t gotten to Apple’s Objective-C & Swift yet. And it’s not certain that tomorrow I won’t have a project for which I’ll consider it necessary to use Java or Rust and will write in them.