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

  • Thread starter pbuk
  • Start date
In summary, when deciding which programming language to learn, it is important to consider your goals and the specific applications you are interested in. For hobbyists, Python may be a good choice due to its ease of use and versatility. However, for job opportunities, C or C++ may be more in demand. It is also worth considering the speed and efficiency of each language in different contexts, such as web development, scientific research, or game development. Ultimately, it is important to choose a language that aligns with your goals, rather than relying solely on generalizations or assumptions about a language's speed or popularity.
  • #1
pbuk
Science Advisor
Homework Helper
Gold Member
4,580
2,881
TL;DR Summary
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 DeBangis21, CGandC, phyzguy and 2 others
Technology news on Phys.org
  • #2
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.
 
  • #3
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
  • #4
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.
 
  • #5
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.
 
  • Like
Likes pbuk
  • #6
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.
 
  • #7
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?
 
  • #8
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
  • #9
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:
  • #31
@pbuk I mean because of standard template library it is easier to study leetcode in c++.
 
  • #32
shivajikobardan said:
@pbuk I mean because of standard template library it is easier to study leetcode in c++.
I think you are mistaken, what gave you that idea?

The STL implements in C++ features that are built in to other high level languages. So the leetcode C++ template for the above problem uses std::vector from the STL not to make it easier, but because it has to.

The Python template uses Python's built in lists, the JavaScript template uses JS's built in arrays...,
 
  • Like
Likes PeterDonis
  • #33
I) Speed is not the only issue
When you have a speed or timing constraint that gets you worrying about milliseconds or microseconds, then C and C++ look very good. But in many applications, particularly embedded applications, the greatest imperative is for the object code footprint - including engines, libraries, and the runtime environment.

II) First language for hobbyist:
I suggest HTML/CSS/JavaScript. For Chrome and Firefox, it's as convenient as the F12 key.

III) First language for the pre-professional:
There was once a time when there were only two types of programmers, Cobol and Fortran - and Fortran programmers were expected to be comfortable with assembler.
Now the market is not so simple: Here's an article that gives the rundown.

But as important as it is to have a SW skills attractive to potential employers, more important is that you find it attractive. Otherwise, you will never enter the marketplace. It is okay for your first language to be cheap, easy, with lots of opportunity to quickly see the results of your creative efforts. Once you known what programming is, and you have proven to yourself that you can survive happily in such a world, then perhaps something like this will work for you:

1) Find some job listing that describe what you want.
2) Practice the additional software language and tool skills that you need to move in that direction.
3) If you ended up choosing skills that are too much of a challenge, you may need better mentorship or you may need to retarget the kind of job you are looking for.

and best of luck
 
  • Like
Likes symbolipoint
  • #34
Wrichik Basu said:
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.

I can fully support this. As a first programming language, I would always recommend Java. It makes you learn about structured code, forces object oriented thinking, separation of concerns, and keeping track of type-checking, without the added complexities of C++.
Python is great for prototyping (basically the modern Perl), but is very hard to manage in large scale programs.

JavaScript is a lousy language, but unfortunately mandatory for client side web programming.
For systems programming on Windows, learn C#. For systems programming on any Apple platform: Swift. For any other platform (including Android): Java.

To add to that: in the day-to-day practice of programming, you will find out that you spend a lot more time learning libraries than learning the programming language.
 
  • Like
Likes Wrichik Basu
  • #35
Vanadium 50 said:
Who is the audience?
Mainly this:
Vanadium 50 said:
Is it people that need to be steered away from C++ as a good starting point?
 

Similar threads

  • Programming and Computer Science
Replies
8
Views
878
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
7
Views
879
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
12
Replies
397
Views
13K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
Replies
7
Views
238
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top