I've taught hundreds of people programming. For one year, at my first real job, I was tasked with teaching the programmers within a big company Pascal. All of them were already professional programmers using Fortran, COBOL, or assembly language. The company had a commitment to modernize their software development practices and one facet of this was to introduce a more modern language--Pascal at that time (circa 1976).
I enjoyed that year and, for the most part, my "students" were easy to teach, and Pascal held up well. They were all programmers already, so I didn't have to go slow through the basics and introducing ideas like recursion (absent in Fortran, COBOL, and assembly language of the period) kept the classes new and interesting to the students.
Unfortunately, standard Pascal isn't really a good choice for a first programming language today, even though modern Pascals have removed many of early Pascal's limitations (packages, batteries included libraries, etc.)
So, how can we decide if a language is a viable first language? Employing the wisdom of crowds, here are the top 30 languages in the 2023 IEEE Spectrum rankings:
I contend that we should limit our choice of first-languages to some language in the top 30. This rules out many languages that I consider important, but we should stick with a language that is likely to benefit the student more than others as a first-language. That means not teaching Lisp or Racket or Ada or Ocaml or Prolog or even D for that matter as a first language.
To narrow our top 30 down to a handful of alternatives, I'm going to use my own subjective difficulty rating and remove C++ and Rust and Scala from the list because they will be too hard for beginners.
Furthermore, let's remove languages that aren't general purpose; this knocks out SQL, HTML, R, Shell, PHP, SAS, Matlab, Assembly, Visual Basic, and Verilog.
Some languages require more complex build or execution environments; I would remove Java, Dart, Kotlin, and Groovy from our list for this reason.
Finally, there are some languages that are not as easy to use outside of specific hardware or operating systems; I consider these languages C#, Swift and Objective-C to be ruled out.
For good measure, I'm removing Perl from the list (a bit too irregular) and Fortran (not widely used outside of some important areas).
Our condensed list now look like this:
Possible first languages: Python, JavaScript, Go, TypeScript, Ruby, and Julia.
To narrow it down even a bit further we can observe that one should learn JavaScript before learning Typescript. (Is this opinion shared by HN?)
Ruby and Python seem like close cousins with Ruby being a bit prettier and Python being much much more popular.
Julia is a bit specialized and a bit harder than the others so now we are left with just three: Python, JavaScript, and Go.
I think first programming languages need to fit with what the person's motivation is. If they want to do statistics, data analysis and the like then surely Python, R and the like will be a good starting point instead of Bash Shell. Also, the teacher having a very good command of said language as well as all the tools for the environment they'll be using (*nix container, Windows, Mac, etc.) makes a big difference. Things like setting up VS Code to debug something is a daunting task for a beginner with no idea on how to set it up (if they devote themselves to setting it up). Language choice isn't that big of a deal but getting a teacher who knows how to guide the student and teach them everything in said language is (the article shows how the author having a good command of D and knowing said tools taught effectively while he struggled with JS and Lua).
Limiting to top 30 programming languages based on a particular ranking can be biased and misleading. For January 2024 D TIOBE ranking is 21, just outside Top 20 while your top 6 choice of Julia is outside top 30 at rank 33 [1]. D also support scripting and REPL feature as Julia, but D is much faster at them in which faster feedback is very important for new learners.
For proper pedagogical approach we should refer to the experts and educators. There is one paper from Monash University that have come up with major sins of introductory programming languages that are not suitable for new learners including Pascal that you used during your teaching time. I have provided the link to the paper in my other comment.
I would say of your four contenders, you eliminated Julia too quickly, it's perfect.
For one reason: it's a dynamic language with types. It's good to have types in a first language, they're too important to neglect. But with Julia, you just introduce them later.
Also, 1 based indexing is easier on anyone who hasn't already gotten used to 0 based indexing, and it's the only language in your last paragraph where zero isn't false.
But it depends more on why they want to learn than anything else. If they want to make web apps, for some reason, obviously JavaScript, and if they like games, it should be Lua. Data and numerics stuff, AI? Julia obviously ;)
There are various reasons to rule out JS. It's a scripting language for browser engines, it's about as general-purpose as GLSL or ActionScript. Node grabbed it and forced it into a general-purpose suit it wasn't made for, but that's not a good reason to learn it as a first language. It's also simply a poorly designed language.
On the other hand, the reason given for excluding Java is seriously reaching. The JVM isn't "complex" from the student's point of view, and hello world (and other exercises) can be compiled with a simple javac invocation.
I think you tossed VB for the wrong reason. It's definitely a general purpose language but it's mostly limited to one platform so that's handled a few lines lower and it would still have led it to be tossed out. I agree with JS over TS for first learning because of the complete lack of a toolchain but later on you probably want to move to TS. Python agreed on as well, Go requires a lot of other knowledge and is a far more advanced eco system already so I'd have ruled out that one as well.
What happened to C? It's the #5 top language and you never ruled it out but it is missing from the final list? It seems like a reasonable first language with simple operations and not much magic happening behind the scenes.
It's available but not in common use, and where it is used it is used mostly as a portability option (though it is very well possible that is no longer the dominant use, I just haven't seen it used any other way outside of the Microsoft eco-system).
Main deployment platform for back-end workloads using .NET is Linux. There are GUI frameworks which support it (Avalonia and Uno), file and sockets I/O support is first-class. CLI tooling is platform-agnostic, paid and free tools for developing in C# are available under Linux and macOS. With some effort it can be also run on FreeBSD (not mentioning interesting but niche projects like BFlat which can target UEFI directly).
For example, getting the SDK on Fedora is just
sudo dnf install dotnet-sdk-8.0
It is as cross-platform as it gets, far more easier to manage than installing JVM implementation and then dealing with a switcher or just the fact that Java needs Gradle to build projects over trivial dotnet new console; dotnet run/build/publish
In my experience, the only places pushing for C#/.NET in Linux are places that were already C#/.NET before the core started to support it.
It's still fairly popular but that popularity is waning as languages with more modern design principles are gaining momentum without relying on a heavy framework like .NET. This could make it a poorer choice for somebody just learning as there may be fewer opportunities for junior devs by the time they graduate.
Even Microsoft has started transitioning to Rust in some cases. I'd hesitate to recommend a language to somebody getting started if that language is under publicized risk of being replaced by its maintainer.
I would add that a purely OOP language also probably isn't ideal for a first language, though. Being able to start teaching with just functions is quicker to introduce than having to describe objects first.
An OOP centric language is definitely appropriate for a second language. But if we are talking "intro", the faster somebody can type hello world while still having more programming concepts in the file than just the print statement, the better. For that last statement, I'd also exclude Python.
I always recommend talking about goals first then recommending a path.
If they know web dev is their future, JS.
If they know IOT is their future, C.
If they know games, probably still C as C++ is still likely the path for a while.
We are talking first language. Not people who are looking for a job right now. What about that doesn't make sense? These are people who are likely months to years away from getting a job.
> Furthermore, let's remove languages that aren't general purpose; this knocks out SQL, HTML, R, Shell, PHP, SAS, Matlab, Assembly, Visual Basic, and Verilog.
Just a nitpick, but modern PHP is definitely a general-purpose language, and quite a decent one. Assembly is also inherently general-purpose, and might have a much higher learning curve, but its foundational nature also makes it an important step in a layered approach to learning (a la Nand2Tetris).
I'd throw Python out too, as it's just far too slow*, which would set wrong expectations for learners. While itmcaan be sped up by writing everything in C and calling it from Python you've already thrown C out, so that's not an option. The languages remaining are very unfortunate though: JS is infamously the language designed in 14 days, and Go is a Google project, so I wouldn't be surprised if programming in it awakens Deep Ones to feed on your sanity.
Why would execution speed be particularly relevant? Python is slow but that hasn't stopped many useful applications from being written it, plus proper use of libraries written in C (e.g., numpy) again mitigates the issue.
From a learning perspective, a slower language could actually be beneficial in the sense that it's impractical to brute force a solution to a problem in a way that you can get away with in C or similar.
> I'd throw Python out too, as it's just far too slow*, which would set wrong expectations for learners. While itmcaan be sped up by writing everything in C and calling it from Python you've already thrown C out, so that's not an option.
I'm not sure I follow you. Are you saying using e.g. numpy is not okay because it's implemented in C? How does that make any sense? The cpython interpreter itself is implemented in C so everything interpreted by cpython is just as much "in C" as something else like e.g. numpy.
I can see why people think the tool chain may be hard for adults, but if the focus is on children learners, you can get Lua with the batteries included.
As a first language, I would teach python or javascript with java, C#, C, C++ as strong contenders depending on what they study, and possibly R or MATLAB is there is a very specific and good reason to do so
I enjoyed that year and, for the most part, my "students" were easy to teach, and Pascal held up well. They were all programmers already, so I didn't have to go slow through the basics and introducing ideas like recursion (absent in Fortran, COBOL, and assembly language of the period) kept the classes new and interesting to the students.
Unfortunately, standard Pascal isn't really a good choice for a first programming language today, even though modern Pascals have removed many of early Pascal's limitations (packages, batteries included libraries, etc.)
So, how can we decide if a language is a viable first language? Employing the wisdom of crowds, here are the top 30 languages in the 2023 IEEE Spectrum rankings:
1-10: Python, Java, C++, C, Javascript, C#, SQL, Go, TypeScript, HTML.
11-20: R, Shell, PHP, Ruby, SAS, Swift, Dart, Rust, Kotlin, Matlab.
21-30: Scala, Assembly, Perl, Visual Basic, Objective-C, Lua, Fortran, Verilog, Groovy, Julia.
I contend that we should limit our choice of first-languages to some language in the top 30. This rules out many languages that I consider important, but we should stick with a language that is likely to benefit the student more than others as a first-language. That means not teaching Lisp or Racket or Ada or Ocaml or Prolog or even D for that matter as a first language.
To narrow our top 30 down to a handful of alternatives, I'm going to use my own subjective difficulty rating and remove C++ and Rust and Scala from the list because they will be too hard for beginners.
Furthermore, let's remove languages that aren't general purpose; this knocks out SQL, HTML, R, Shell, PHP, SAS, Matlab, Assembly, Visual Basic, and Verilog.
Some languages require more complex build or execution environments; I would remove Java, Dart, Kotlin, and Groovy from our list for this reason.
Finally, there are some languages that are not as easy to use outside of specific hardware or operating systems; I consider these languages C#, Swift and Objective-C to be ruled out.
For good measure, I'm removing Perl from the list (a bit too irregular) and Fortran (not widely used outside of some important areas).
Our condensed list now look like this:
Possible first languages: Python, JavaScript, Go, TypeScript, Ruby, and Julia.
To narrow it down even a bit further we can observe that one should learn JavaScript before learning Typescript. (Is this opinion shared by HN?)
Ruby and Python seem like close cousins with Ruby being a bit prettier and Python being much much more popular.
Julia is a bit specialized and a bit harder than the others so now we are left with just three: Python, JavaScript, and Go.