For those who ask: "What programming language should I learn?"

  • Thread starter Thread starter pbuk
  • Start date Start date
Click For Summary
Choosing a programming language to learn depends on your goals. Python is recommended for machine learning, web applications, and data analysis, while JavaScript is ideal for web development. C# is suited for game development and Windows applications, whereas C++ is best for performance-critical applications like games and operating systems. Beginners are advised against starting with C++ due to its complexity and potential for confusion, with suggestions leaning towards Python or Java for foundational learning. Ultimately, the choice of language should align with the specific applications you wish to pursue in programming.
pbuk
Science Advisor
Homework Helper
Gold Member
Messages
4,970
Reaction score
3,220
TL;DR
If you are new to programming, learn Python - it is relatively easy to learn and you can do a lot with it.
LearnIf you want to write code for
PythonMachine learning, AI
Statistics/data analysis
Scientific research
Web application servers
Some microcontrollers
JavaScript/Node JS/TypeScriptWeb sites
Web application servers
C#Games (Unity)
Consumer applications (Windows)
Business applications
C++Games (Unreal Engine)
Operating systems, device drivers
Microcontrollers/embedded systems
Consumer applications (Linux)

Some more tips:
  • Do not learn C++ (or any other dialect of C) as a first language - there are too many things to learn that are unimportant that distract from focusing on what is important.
  • Do not learn C++ (or any other dialect of C) because you believe that it is "fast" in some general sense - the contexts in which this may be relevant are limited to those mentioned above (games, embedded systems etc.)
  • Do not learn C++ because you believe that all interviewers expect you to use it to answer coding questions - in 2023 this is no longer true in many cases, and it is easier and quicker to solve coding problems correctly in e.g. Python. Of course if you are going for a job writing device drivers at NVIDIA this is not going to apply, but if you think you can get a job writing device drivers at NVIDIA you don't need advice on learning to code anyway.
  • Do not avoid Python or Node JS because you believe that they are "slow" - the contexts in which this may be true are unlikely to be relevant to you.
  • Do not learn how to implement algorithms and data structures like linked lists, hash tables, trees, indexing, sorting etc - these algorithms have already been implemented optimally in the languages that you will learn (although the comment about NVIDIA etc. above applies).
 
Last edited:
  • Like
  • Informative
Likes Mark44, DeBangis21, CGandC and 3 others
Technology news on Phys.org
I would say that, between Python and C++, Python is best for the hobbyist and C or C++ is best for job opportunities.
Your comments about the speed of Python not being important ignore that it can be 40 times slower. That is annoyingly slow for many serious applications.
 
FactChecker said:
Your comments about the speed of Python not being important ignore that it can be 40 times slower. That is annoyingly slow for many serious applications.
That might be why @pbuk listed areas where either the speed is not an annoyance (for example, web servers are network I/O bound, not CPU bound, and network I/O is roughly 1000 times slower so a factor of 40 slowdown is not a problem) or there are extension modules written in C (or even assembly language) to do the CPU intensive work (microcontrollers, scientific research, statistics/data analysis, and I expect ML/AI to move in this direction if it hasn't already).

I have also used Python for GUI programs and interactive scripts where the program spends most of its time waiting for user input and responses to each user input are not CPU intensive. Here again speed is not an issue because the program is not CPU bound.
 
  • Like
Likes Klystron, pbuk, berkeman and 1 other person
PeterDonis said:
That might be why @pbuk listed areas where either the speed is not an annoyance (for example, web servers are network I/O bound, not CPU bound, and network I/O is roughly 1000 times slower so a factor of 40 slowdown is not a problem) or there are extension modules written in C (or even assembly language) to do the CPU intensive work (microcontrollers, scientific research, statistics/data analysis, and I expect ML/AI to move in this direction if it hasn't already).

I have also used Python for GUI programs and interactive scripts where the program spends most of its time waiting for user input and responses to each user input are not CPU intensive. Here again speed is not an issue because the program is not CPU bound.
I think that is all true. But one must be careful about saying that speed is not important. It is often ignored on small examples and then the program must be converted to another language for larger problems. Of course, if there are C libraries that do the real work, then they can be used, but relying on those libraries can be a problem in itself. A few of my last jobs were to completely rewrite large programs to make them independent of licensed libraries.
 
FactChecker said:
if there are C libraries that do the real work, then they can be used, but relying on those libraries can be a problem in itself
In general, yes, but in the particular cases that were mentioned, there are well-established libraries (for example, numpy and scipy) that have proven themselves to be reliable and fast.
 
FactChecker said:
I would say that, between Python and C++, Python is best for the hobbyist and C or C++ is best for job opportunities.
Can you support that with evidence? Here is some evidence that that is not the case: https://www.devjobsscanner.com/blog/top-8-most-demanded-languages-in-2022/

FactChecker said:
Your comments about the speed of Python not being important ignore that it can be 40 times slower.
No they dont, what I said was that the contexts in which Python can be 40 times slower are unlikely to be relevant to someone deciding what programming language to learn.
 
pbuk said:
Can you support that with evidence? Here is some evidence that that is not the case: https://www.devjobsscanner.com/blog/top-8-most-demanded-languages-in-2022/
I retired as a programmer about 7 years ago. I can say that I saw occasional Python programs but the vast majority was C or C++. IMO, most programmers do not have the authority to determine what language they use in a job; they use the language of the already existing code at that company.
pbuk said:
No they dont, what I said was that the contexts in which Python can be 40 times slower are unlikely to be relevant to someone deciding what programming language to learn.
Learning for what use? Hobby or on a job at a company?
 
I wonder if any of this matters anymore with LLMs - if you can code in any high-level language or just do clear enough pseudo-code, the LLM can convert it
 
  • Like
Likes FactChecker
BWV said:
I wonder if any of this matters anymore with LLMs - if you can code in any high-level language or just do clear enough pseudo-code, the LLM can convert it
That is a good question for future programmers. It's hard for me to imagine what the future, even the near future, will be like. Where I worked, we were not even allowed to use some higher-level optimization options of compilers. :wideeyed:
 
Last edited:
  • #10
While I like the concept of this thread, I am afraid that too often the context of the question is "All I need to know to become a highly paid programmer is for someone to tell me what language to learn." I disagree with this, and I think the job market bears me out.

There is more to programming than syntax.

I want to like Python. I really do. It just seems that Python is today's BASIC. Whitespace being significant is absurd. I might be able to learn to live with that if I didn't see my colleagues producing thousands of lines of unmaintainable spaghetti code.` "Rapid prototyping" is good. "I never have to design" and "I can start coding before I start thinking" is not so good.

I'd like Python more if it was limited to say 500 lines. :smile:
 
  • Like
Likes DrClaude, phinds, pbuk and 2 others
  • #11
BWV said:
if you can code in any high-level language or just do clear enough pseudo-code, the LLM can convert it
Current LLMs do not do this based on the actual meaning of the code, they do it purely based on relative token frequencies. That is not a reliable method of translation.

I believe there has been work done on doing inter-language translations based on abstract syntax trees, which does capture the meaning of the code, but I don't know what tools currently exist for that.
 
  • #12
I would recommend people to learn Java as their first programming language. Yes, you may say it has a lot of boilerplate code. But dealing with indentation errors is not what I would like to encounter when I am absolutely new to programming, and not fully familiar with an IDE. Maybe you will say that learning OOP is not necessary for programming. True, but OOP helps build programming logic in a certain direction. Each variable always having a global scope is also an issue in Python. The loop variable is available even outside the loop. For a newbie, this could give rise to logical errors if not careful. In Java, declaring a variable inside the loop keeps it inside.
 
  • Like
Likes shivajikobardan
  • #13
In general, my experience is that people pay too much attention to speed too early in the process.

Getting the wrong answer more quickly is seldom helpful.
Working hard to speed up a piece of code that didnt take up much of the time to begin with likewise.
 
  • #14
chagpt-coding.png
 
  • Haha
Likes OmCheeto, Demystifier, Filip Larsen and 3 others
  • #15
Wrichik Basu said:
I would recommend people to learn Java as their first programming language.
So in my table where I have "Learn... Java" on the left, how do you complete "If you want to write code for..." on the right?

Wrichik Basu said:
But dealing with indentation errors is not what I would like to encounter when I am absolutely new to programming
C:
// So you are OK with code that looks like this?
void myFunction ()
 {   if (someFlag = true)
    doThis();
    doThat();
  doSomethingElse();}

Wrichik Basu said:
Maybe you will say that learning OOP is not necessary for programming.
All the languages in my OP support OOP (that looks like an "oops", but isn't).
 
Last edited:
  • #16
Wrichik Basu said:
Maybe you will say that learning OOP is not necessary for programming.
Nor is it necessary for learning Python.

Wrichik Basu said:
Each variable always having a global scope is also an issue in Python.
I don't know what you're talking about. Only variables defined at the module level have global scope (which really means module scope) in Python.

Wrichik Basu said:
The loop variable is available even outside the loop.
Yes, but only within the function in which the loop is defined. Only if the loop is at the module level (i.e., not inside any function) will its loop variable be visible at module level. If that's a problem, just wrap the loop inside a function.
 
  • #17
As far as speed goes, let me also say that some people have a knack for writing slow code in any language. :smile:

Beginners? Java has one thing going for it: in C++ there are usually many ways to do something. Java tries to reduce this, ideally to one. Ruby, while not as popular, is similar in thsi regard. It also tries to minimize surprises ("principle of least astomishment") which is good.

There are two things I like about Ada. One is the uber-strong typing. If you understand strong typing, you better understand where and when it can or should be relaxed. The thing I like, and the world hates - well, hated - was the propensity to throw compile time errors. For me, this is a good thing: better to find a problem at compile time

But if I were teaching beginners, I'd probably go with Pascal. It's about as trendy as an Oldsmobile, but like your grandfather's car, it's good to learn on. Strong typing, block structured, and you can go a semester without running into the limits of the language.
 
  • Informative
Likes Klystron and symbolipoint
  • #18
Vanadium 50 said:
But if I were teaching beginners, I'd probably go with Pascal. It's about as trendy as an Oldsmobile, but like your grandgather's car, it's good to learn on. Strong typing, block structured, and you can go a semester without running into the limits of thge language.
I love Pascal, it's the second high level language I learned*. However that was 40 years ago, and also it runs into the same problem as Java: if the best answer is "Learn Pascal", what is the remainder of the sentence "if you want to write code for..."?

* Edit: I forgot about a bit of RPG III before Pascal. Oh and Forth.
 
  • #19
I think the best approach is before learning to "write code for X" one learns to "write code".

I recognize I am in the minoruty here. That doesn't make me wrong/
 
  • Love
Likes Lord Jestocost
  • #20
You might take a look at a random selection ofg programming questions either here or on the interwebs. They start wiyj "I am trying to program X in Y language" and end with:

"You have an uninitialized variable"
"That variable has moved out of scope."
"You made changes to a copy of the variable/object not the original"
"That condition neve`r gets tested for`:

and we might as well be saying "Bleeble gozzle nordle zev."
 
  • #21
pbuk said:
I love Pascal, it's the second high level language I learned*. However that was 40 years ago
Somewhat OT: For me it was the third, after a bit of PL/C and some BASIC (which used to be an all-caps acronym for Beginner's All-purpose Symbolic Instruction Code (as I recall). Not long after that was Fortran and another Wirth language, Modula-2. Pascal for me was also about 40 years ago.
 
  • Like
Likes symbolipoint
  • #22
pbuk said:
Oh and Forth.
Which, ironically, pushes Pascal into fourth.
 
  • Haha
Likes Vanadium 50 and pbuk
  • #23
Vanadium 50 said:
You might take a look at a random selection ofg programming questions either here or on the interwebs. They start wiyj "I am trying to program X in Y language" and end with:

"You have an uninitialized variable"
"That variable has moved out of scope."
"You made changes to a copy of the variable/object not the original"
"That condition neve`r gets tested for`:
I have, that was my motivation for writing the OP (which I hope may be stickied here when refined).

My experience is that many of these questions start with "I am trying to program X in C++", and it becomes clear sooner or later that the questioner is wasting their time learning C++. So the post is really about discouraging people from learning C++ unless they have a specific relevant goal in mind, in which case their learning can be directed by that specific goal.
 
  • #24
pbuk said:
So in my table where I have "Learn... Java" on the left, how do you complete "If you want to write code for..." on the right?
"To build your programming logic and thought process, assuming you are absolutely new to programming."
pbuk said:
C:
// So you are OK with code that looks like this?
void myFunction ()
 {   if (someFlag = true)
    doThis();
    doThat();
  doSomethingElse();}
Zero indentation is not preferable, but at least Java will not throw an error if you give three spaces instead of four on a particular line. In addition, for an absolute beginner, the braces are a must, in my opinion. Shorthands can come later. I have seen my friends in college, who have had no programming experience before, suffer badly due to indentation issues in Python. Especially because our uni does not use any IDE, but only gedit or Notepad.
pbuk said:
All the languages in my OP support OOP (that looks like an "oops", but isn't).
Agreed, but OOP is not necessary if you want to program in Python. In Java, unless you are using JDK 21 with unnamed classes and instance main methods, you have to have an idea of classes. Complete idea is not necessary, but you need to be able to understand what objects are, variable scope in static methods and so on.
 
  • #25
Wrichik Basu said:
"To build your programming logic and thought process, assuming you are absolutely new to programming."
Ah, but that's a different table that looks like this:

If you want toLearn
Build your programming logic and thought process, assuming you are absolutely new to programmingOne of: Java, JavaScript, Pascal :wink:, Perl, PHP, Processing, Python, Scratch, TypeScript, Visual Basic, ... (each has strengths and weaknesses)

Given that no two programmers can agree on what should be on the RHS that is not a very helpful table.

Wrichik Basu said:
In Java ... you need to be able to understand what objects are, variable scope in static methods and so on.
I do not consider that a strength as a first language - there are more important things to learn first.
 
  • #26
All I can say is Javascript is too tough. Specially ES6.
 
  • #27
shivajikobardan said:
All I can say is Javascript is too tough. Specially ES6.
I don't agree, particularly in comparison to C++ which you have decided to focus on.

What I think you have found tough in javascript is moving from the procedural/object oriented paradigms to the event driven paradigm: this is a difficult leap in any language.
 
  • #28
@pbuk How does one make themselves familiar with the event driven mechanism of javascript? Also why're you against data structures leetcoding? I agree C++ is tough but I had no option because of STL.
 
  • #29
Who is the audience?

Is it people who know zero programming and want to learn their first language?
Is it people who want to get a high-paying job in computer science without learning all that icky computer science?
Is it people that need to be steered away from C++ as a good starting point?
 
  • #30
shivajikobardan said:
How does one make themselves familiar with the event driven mechanism of javascript?
Practice. The two classic apps to practice with are a calculator and a to-do list: there are plenty of tutorials on the web. This applies not just to JavaScript but to every event-driven application, the difference with JS is that event handling is built into the language rather than handled by third party libraries e.g. Swift for Java, Tkinter for Python, GTK, qt, etc. for C++. I guarantee you that creating a GUI to-do list app in C++ is many times harder than in JavaScript.

shivajikobardan said:
Also why're you against data structures leetcoding?
I'm not, there are some great practice tasks on Leetcode e.g.
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
and Leetcode defaults to Python for new users (Edit: I've just realised it defaults to Python 2: this is insane and should be changed to Python 3) - this is a great task to practice your programming skills.
shivajikobardan said:
I agree C++ is tough but I had no option because of STL.
I don't understand what this means, can you phrase it differently?
 
Last edited:

Similar threads

Replies
86
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 397 ·
14
Replies
397
Views
19K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 16 ·
Replies
16
Views
2K