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.
  • #71
Mark44 said:
promoted
In the sense of "you don't get to do science anymore. You've been promoted to management."
 
Technology news on Phys.org
  • #72
I'm curious, why has Pascal declined in its popularity?
 
  • Like
Likes symbolipoint
  • #73
CGandC said:
I'm curious, why has Pascal declined in its popularity?
It boils down to productivity.
Here's the wiki introductory paragraph:
Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring.
It encouraged the parochial view of "good programming" as the diligent pursuit of "tidiness" rules.
That kind of tidiness really is important, and I don't begrudge it being emphasized in schools. But it many cases, the path to tidiness is best left to the programmer.

For example, all of the early Pascal's and most of rest of them did not have any of the so-called "early out" options for loop - that is, the "break" and "continue" statements. The intend may be tidiness and predictable structure, but the results are anything but tidy. Without "continue", a loop that needs to check 20 "continue" conditions ends up going 20 levels deep in if statements. There are ways to avoid that, but only at the cost of concise and direct code.

Pascal did implement the "goto". The most intractable problem with the routine use of "goto" is that the person reading the code (which is most often the person who wrote it) needs to find the "goto" label to know where the landing point is. Whereas "break" or "continue" relate to the current loop - something that would already be known to the code reader.

Of course, "goto" is most notorious for creating "spaghetti code", the structured programming equivalent of obscure control flags.
 
  • Informative
  • Like
Likes symbolipoint and CGandC
  • #74
You could always write Pascal-like code in C. You could not always write C-like cofe in Pascal.

Furthermore, Wirth had already moved on to Modula-2. If the language's creator isn't an advocate, that's not a good thing.
 
  • #75
Hornbein said:
I also could never figure what advantage Python had over MacLISP or Scheme or some other interpretive language that already existed.
One big difference is Python's standard library, which includes support for enough things that many Python programs can be written without having to depend on any third-party libraries. The Lisp dialects you mention (and indeed Lisp in general) have never had such broad library support built in.

Another big difference is syntax; many people find it very difficult to wrap their minds around S-expressions, whereas Python's syntax is simple and obvious and basically works like pseudocode, so it matches up well with how many people conceptualize their programs.
 
  • Informative
Likes symbolipoint
  • #76
Mark44 said:
Technically, '2' is a character, very different from the string "2".
Yes, but as you note, it is still the value that gets type converted; the integer doesn't. Whereas in the example of implicit conversion with strings in other languages, the integer gets converted to a string.
 
  • #77
Vanadium 50 said:
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.
I saw a lot of that. Correctness is the real challenge. Get that then use a profiler.
 
  • #78
PeterDonis said:
Yes, but as you note, it is still the value that gets type converted; the integer doesn't.
In C, the char type is an integral type, similar to short int, int, long int, and several other integral types. What happens is that it gets promoted rather than converted. If you convert from a non-integral type to an integral type, the value will change, but that's not what happens when a char is promoted to an int.
 
  • #79
After reading this thread, I have come to some opinions - in some cases changed, and in others reinforced.

1. It is better to learn how to program than any particular language.
1A. While people focus on writing code, in real life reading code is at least as important. Writing something from scratch on your own is rare indeed.

2. if you have decided that you don't want to learn programming, and just want to cobble something together, your best choice is what most other people are using. Might be Python. Might be FORTRAN. Might be lots of things.

3. We lumped C and C++ together here, but they really shouldn't be. Their philosophies and styles are very different. I would view C as its own thing, and C++ as it's own thing that just happens to support a subset that is C. But even "Hello world" looks different in idiomatic C and C++.

4. A lot of useful advice is language independent and never touched. RTFM. UTSL. Use pencil and paper before writing the code. Comment as needed - no more and certainly no less. Eat green leafy vegetables. Use a debugger. Print statements can serve as a debugger. And so on.
 
  • Like
Likes pbuk
  • #80
Vanadium 50 said:
1. It is better to learn how to program than any particular language.

Vanadium 50 said:
1A. While people focus on writing code, in real life reading code is at least as important. Writing something from scratch on your own is rare indeed.
However, writing something from scratch is what people do who are learning to program.
Vanadium 50 said:
4. A lot of useful advice is language independent and never touched. RTFM. UTSL. Use pencil and paper before writing the code.
Re the last sentence: An instructor I had a long ago said this: "The sooner you sit down to the keyboard, the longer it takes to write your program."
 
  • Like
Likes Eclair_de_XII, Vanadium 50, phinds and 1 other person
  • #81
Mark44 said:
"The sooner you sit down to the keyboard, the longer it takes to write your program."
what he said (very small).jpg
 
  • #82
Mark44 said:
However, writing something from scratch is what people do who are learning to program.
Maybe it shouldn't be. Being able to write HelloWorld, FizzBuzz and maybe even TicTacToe leaves people unprepared for geting an inch thick stack of green and white tractor-fed paper on their desk with the instruction "1% of our vendors aren't getting paid. Fix it."
Mark44 said:
The sooner you sit down to the keyboard, the longer it takes to write your program
A week of coding will save you an hour of thinking.
 
  • Haha
Likes PeterDonis
  • #83
Vanadium 50 said:
A week of coding will save you an hour of thinking.
I love it :oldlaugh:
 
  • Like
Likes berkeman
  • #84
Vanadium 50 said:
Maybe it shouldn't be. Being able to write HelloWorld, FizzBuzz and maybe even TicTacToe leaves people unprepared for geting an inch thick stack of green and white tractor-fed paper on their desk with the instruction "1% of our vendors aren't getting paid. Fix it."
Well, of course -- it's a long way from writing a toy program to being able to analyze why a big program isn't working for 1% of the vendors, but you have to crawl before you walk, and walk before you run.
 
  • #85
I agree you have to start somewhere. But if you go to college to learn to write English, you spend a greate deal of time reading, and less time writing. If you go to school to learn to write code, it's the other way around. I am musing aloud as to whether the English Department may have it right.

There are two other problem, and maybe they should be attacked first. One is that there are graduates who still can't code. At all. They can;t write FizzBuzz, much less a fully-compliant payroll application.

The other is that they think they can. For some reason, there is a shockling lack of self-awareness on the part of some programmers that I just don't see in physics or math.
 
  • #86
Rene Dekker said:
For systems programming on any Apple platform: Swift.
I haven't programmed since MS quickbasic in the '90s. I'm reading Swift.org, but it is over my head.

If I write a program in Swift on Mac, can I save it as a windows program and send it to a windows user? Are their any program languages that can do this? Or do you need a windows machine to compile code that can run in windows?
 
  • #87
Vanadium 50 said:
But if you go to college to learn to write English, you spend a greate deal of time reading, and less time writing. If you go to school to learn to write code, it's the other way around. I am musing aloud as to whether the English Department may have it right.
I don't think it's actually the other way around with regard to teaching programming. Before a student is asked to write a program he or she will have been exposed to examples that use the same concepts as are asked for in the program to be written. I'm speaking as someone who has taught programming classes for about 35 years in at least six different languages.
Algr said:
If I write a program in Swift on Mac, can I save it as a windows program and send it to a windows user?
AFAIK, no. A compiler generates code that can run on a particular operating system. If you write a program in Swift that runs on a Mac, the OS is iOS <some version>. A Windows user would need to have some kind of emulation software on the Windows machine, software that would emulate the Mac OS.

It's possible that you could send the Swift source code to the Windows user, who might then be able to port that source code to C, C++, C#, or whatever, and then compile and run that ported version.
 
  • #88
Algr said:
Are their any program languages that can do this?
Java can do it because Java does not compile directly to machine code, but rather creates an intermediate form which can then be executed on any machine (including Mac's and Windows) that have a Java Virtual Machine (an app to run Java intermediate code)
 
  • Like
Likes Vanadium 50
  • #89
Algr said:
Are their any program languages that can do this?
Any interpreted language that has an interpreter on both platforms will do. Java is one, as @phinds mentioned. Another is Python. Another is C#.
 
  • #90
There are really four approaches to this:

(1) Use an interpreted language and have each platform provide its own interpreter. Python was mentioned as an example. BASIC was an older example. The issue here is that platform-specific versions may vary: running Applesoft BASIC code on an IBM PC might or might not work.

(2) Use a compiler, and port the compiler to different platforms. V and the GCC compiler is an example of that. The issue is that many faetures, especially the "cool" one like sound and graphics exist in extensions, so the programs are very "plain jane".

(3) Use a common environment like the Java Virtual Machine upthread, This solves both problems, but requires a strong core team - in this case provided by Sun - to write and test the virtual machines for each platfom.

(4) Write an automatic converter from one dialect to another, one environment to another, or even one language to another. I would say that this works for small programs, but as the program gets larger and more complex, the more likely some human intervention is required.
 
  • #91
Vanadium 50 said:
Use a common environment like the Java Virtual Machine upthread
How is this different from 1? The JVM is just a bytecode engine that runs Java bytecode; it's no different from the Python interpreter running Python bytecode, or any other interpreted language. You still have to have a JVM separately compiled for each platform. Yes, Java has historically had a core team that devotes attention to the JVM for multiple platforms; but so has Python, and so have other interpreted languages, like Perl.
 
  • #92
PeterDonis said:
How is this different from 1?
There is more standardization.
 
  • #93
Vanadium 50 said:
There is more standardization.
In what way? Python code runs the same on every platform that has a Python interpreter.
 
  • #94
Thank you all!

It sounds like Python is the best choice for me, or maybe Java. I'm not really looking to make any money off of programming, just make fun little programs to send to friends.
 
  • #95
Algr said:
Thank you all!

It sounds like Python is the best choice for me, or maybe Java. I'm not really looking to make any money off of programming, just make fun little programs to send to friends.
I recommend javascript or java.
 
  • #96
I'm still researching for an improved answer for the question in the title and a couple of points that have been made in this thread and are put well here have come out as important so I thought I would jot them down here so they don't get lost:

Relevant considerations:
  • What should someone gain from their experience with a first language?
  • The first language learned is not the only language ever learned.
  • A first language should not force a particular programming paradigm (sorry Java: not everything is a noun).
Not relevant:
  • Is language X "better" than language Y? (Unanswerable without context.)
 
  • #97
I think your third point somewhat contradicts your second. While I am not 100% sure what you mean by "paradigm" or even "force" (is making it easy to accomplish a task in one way 'forcing'?) but if the thought is the student will eventually learn multiple languages, why is this a problem?

I've been thinking about what one expects students to be able to do. This is probably the upper limit:
  1. Read a text file of ~100 words. If there are more, read the first 100.
  2. Convert each word to a number by summing the ASCII codes for its letters.
  3. Drop the leading digit from each number, then square it.
  4. Sort this list.
  5. Write the sorted list to a file, and display the mean. median and mode.
If you think this is too easy, look at some of the questions we get. Look at people struggling with FizBuzz.

This can be done in C. C++, FORTRAN, Pascal, Ada, Java, BASIC and lots more. (I might try it in SQL, which looks like a fun project). The code - indeed - the approach - will be different in several of them, although it lends itself to block-structured procedural cide with several independent subroutines. Is this a problem?
 
  • #98
pbuk said:
I'm still researching for an improved answer for the question in the title and a couple of points that have been made in this thread and are put well here have come out as important so I thought I would jot them down here so they don't get lost:

Relevant considerations:
  • What should someone gain from their experience with a first language?
  • The first language learned is not the only language ever learned.
  • A first language should not force a particular programming paradigm (sorry Java: not everything is a noun).
Not relevant:
  • Is language X "better" than language Y? (Unanswerable without context.)
Funny, reading this post made me think about a similar question that could be asked:
  • When learning how to speak, what language should a child learn?
And then all of your points or questions would still be as relevant:
  • What should someone gain from their experience with a first language?
  • The first language learned is not the only language ever learned.
  • A first language should not force a particular grammar paradigm
And the answer to the original question would seem to be: The language your teacher best mastered.

This is how we learn how to speak: By watching our parents (and other people in our surroundings) how they speak themselves.

Do you move to another environment, with other people? You learn the local language by default. If it is vastly different, you may have some difficulties that will follow you for the rest of your life because of how you first learned how to speak. Maybe not.

You may even end up translating everything into your original language. It might not be as efficient, as trying to translate the variety of Inuktitut words for "snow" into Arabic, but it is always possible. One language was just not made for the reality described by another one. So is Inuktitut or Arabic the best first language? It could be either or maybe even neither. It depends on where you live and with whom you hang out with.
 
  • Love
Likes pbuk
  • #99
I think we're back to the audience question. It seems that there are three kinds of people who ask this question:
  1. Those who want to learn multiple languages and are picking their first
  2. Those who want to learn exactly one language
  3. Those who want to learn exactly zero
You might not think there is anyone in #3, but there are - it may even be the biggest. In the last few weeks we had two people (at least) on PF who asked how to do something and the answer was one line* - one line! - and they complained it was too hard. Why do people still use FizzBuzz as a test of programmers? Because people still fail it. It provides real, actionable information. Fortunately, we can disregard these people from this question: if you can't program in any language, you can't program.

The people who want to learn exactly one usually do so because they inherited a pile of code that they need to maintain and modify. It might be Python, FORTRAN. C/C++. or others. They are largely uninterested in programming - they just want to change the axes on these plots. And here the answer is easy too - learn what you need to maintain.

Which leads us to Category #1. And does it matter? If you are filling your toolbox, does it matter if you buy a flathead and then a Phillips screwdriver or do it in the other order? I probably wouldn't start with C++, just as I wouldn't start my tool collection with a Swiss Army knife, but I don't think someone who did would be scarred for life. I would consider C, but probably wouldn't either, because it lacks an enum and its pointer handling sacrifices logic for convenience. (Example, if x[5] is 10, what is 5[x]? I'd argue it shouldn't be anything at all!) There's a lot to be said about Ada, and if it weren't designed by people who had ambitions to be hall monitors in grade school, people would use it today. We mentioned Pascal, and despite its age, there are lots worse choices. But my point is that for this target audience, it's less important.

* I'm not counting includes or declaration of input or output variables,. Just the line that did the work.
 
  • #100
Been busy elsewhere so catching up...
Vanadium 50 said:
I am not 100% sure what you mean by "paradigm"
https://en.wikipedia.org/wiki/Programming_paradigm
Vanadium 50 said:
"force" (is making it easy to accomplish a task in one way 'forcing'?)
No, forcing is saying you can ONLY accomplish a task by jumping through non-intuitive hoops. For instance in some functional programming languages you can only create a loop by writing a recursive function and having the compiler sort out the fact that recursion is a really bad way for a computer to execute code and convert it to iteration.

Vanadium 50 said:
I think your third point somewhat contradicts your second ... if the thought is the student will eventually learn multiple languages, why is this a problem?
  • Because making something harder than it needs to be is detrimental to progress.
  • Because bad habits or misconceptions learned early need unlearning later.

Vanadium 50 said:
The code - indeed - the approach - will be different in several of them, although it lends itself to block-structured procedural cide with several independent subroutines. Is this a problem?
It becomes a problem when the student has to spend more time struggling to implement the algorithm in the target language than they spend working out the algorithm.
 
  • #101
Vanadium 50 said:
I probably wouldn't start with C++, just as I wouldn't start my tool collection with a Swiss Army knife.
And that is the whole point of this thread. For some reason, many people choose to start their tool collection with that Swiss Army knife - even if they are only interested in painting pictures or writing novels.

Currently PF doesn't exactly help that picture: of the 4 sticky posts in this forum, the only language (or instruction set) specific titles are "Guide to C++ Programming For Beginners" and "AVX-512 Programming: Extracting Column Subtotals from a Table". AVX-512 FizzBuzz anyone?
 
  • #102
Well, PF has gone a bit sticky crazy. But that's neither here nor there.

If the argument is "C++ is not the best starting point", why not argue that? Don't try to pick the optimum alternative for every case.

I happen to agree that it's not the best starting point, but don't think this is the Biggest Problem We Face Today. Not where I would start, but it doesn't permanently damage people either. And I don't think the people who jump to it will be swayed by a PF post or even an insight.

My advice to "what language should I learn" has consistently been "it is more important that you learn to program than what the language you first learn" and this advice is fairly consistently ignored.
 
  • #103
Vanadium 50 said:
My advice to "what language should I learn" has consistently been "it is more important that you learn to program than what the language you first learn" and this advice is fairly consistently ignored.
what he said (very small).jpg
 
  • #104
Vanadium 50 said:
My advice to "what language should I learn" has consistently been "it is more important that you learn to program than what the language you first learn" and this advice is fairly consistently ignored.
I had the great good fortune to be taught this from the very start many decades ago. At the time there were relatively few computer languages but even so the prof was emphatic that programming was not about syntax, it was about clearly thinking through the problem and how to solve it before worrying about how to do it in any particular language.
 
  • Like
Likes Vanadium 50 and Klystron
  • #105
1688400085154.png
 
  • Haha
Likes bigfooted, suremarc and Mark44

Similar threads

Replies
8
Views
1K
Replies
7
Views
1K
Replies
15
Views
2K
Replies
17
Views
4K
Replies
8
Views
2K
Back
Top