Why is Python the ideal language for beginners to learn?
Let's look at the main reasons:
• It's more accessible for a beginner, allowing you to focus on programming concepts and not language detail. Too many give up coding early on–Python makes this less likely
• It's very powerful–which means you can write any program you'll need and it scales well as you deal with more complex programs and larger data sets
• It's very broad–it has applications in very many fields and not just a narrow scope. It also has libraries for very many fields!
• As it's very popular, it has a large user-base which is very helpful, so you'll find a lot of resources (not just mine!) and a lot of help from the community
• It's a language that's still improving and progressing rapidly. Latest speed improvements is just one example
--
The main thing you're learning is programming, and not a programming language. The language itself is "just" a tool, but you don't want the tool to get in the way of learning, as would happen with some other languages.
Once you become proficient in programming in one language, it's easier to switch to/learn other languages
So my advice is, yes, start with Python and stick with it until you feel you're very proficient. If and when you need other languages, they'll be easier to learn then…
@s_gruppetta I agreed perfectly. 🤗 #Python is phantasic for making the first steps.
But I would not stick "too long" to #Python.
IMHO switching to a full typed language (#Java, #CSharp, ...) gets too painful.
+ Lists with all specialities like #ListComprehension #Slicing is cool but not that easy available in other languages.
+ When I teach object orientation including inheritance and polymorphism, I would never use Python rather than C# or Java or whatever.
@CodingKurzgeschichten It depends a lot who the audience is–for an increasing number of use-cases for programming (not just software development), Python is the only language they will even need…
…and beginners can definitely learn about OOP and functional and other paradigms in Python - in fact being a multi-paradigm language should have been another of those bullet points!
@s_gruppetta I strongly agree, and actively learning #python. But I'm reserved about it being an easily accessible language for beginners. From personal experience, #julialang and especially Matlab seems to be much easier. But not sure if Matlab can be called as a real programming language; heard someone calling it advanced calculator 😀
@MahmutRuzi We need to be careful with the distinctions between "easy language to code in" and "easy language to learn coding".
The easiest language to code in is the one you're used to using most. After over a decade of using MATLAB, when I first switched to Python I found MATLAB easier–I had been using it for 15 years, Python only 15 day! But now there's on doubt that I find Python easier.
In terms of easiest to learn, the three languages you mention are similar as they're all very high level languages (as opposed to Java or C++, say). But of the 3, Python is the one with the deepest and broadest footprint and with the largest community (and is free, of course)
@MahmutRuzi The reality is that MATLAB is mostly still around because many academics (mostly) have decades of scripts they rely on and get their students to learn MATLAB and create more scripts the lab relies on…
Python can do whatever MATLAB can do, often better and faster and much less expensive, plus Python can do a lot more (think outside the scientific fields, especially)
Plus you get a lot more support from the community in Python. So I would expect the trend away from MATLAB towards Python to carry on in the academic community, too, despite resistance from those who don't want to switch because of the library of scripts they have!
I can't see any benefit of MATLAB over Python, personally!
@s_gruppetta yes, I learned Matlab at college at a professor's request for a coursework. Then used it for other things and stuck to it. Finally switched to #python after student license expired and don't want to pay. Glad I did.
@MahmutRuzi Same with me. I joined a research group for my PhD which used MATLAB, so I learnt to code using MATLAB
When I set up my own research group years later, I had tons of MATLAB scripts so I got my students to learn and use MATLAB too…
When a colleague suggested using this up and coming language called Python (this was c.2005), I remember thinking, nah, can't be bothered to re-write all this library in another language.
And after all, licenses weren't a problem as grant funders paid for them!!
@s_gruppetta These are all compelling arguments. I agree, and use Python in my no-prerequisite first-year seminar.
One counterpoint I'll make is that Python's error messages can be more cryptic than, say, Java's. I've had students use the wrong kind of brackets with a list comprehension and get something like this:
(x**2 for x in range(10))[3]
<input>:1: SyntaxWarning: 'generator' object is not subscriptable; perhaps you missed a comma?
<input>:1: SyntaxWarning: 'generator' object is not subscriptable; perhaps you missed a comma?
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
TypeError: 'generator' object is not subscriptable
@peterdrake True, although have you seen the latest improvements in error messages (in 3.10 and 3.11), the Python core team is doing some great work on that (as well as speed)
@peterdrake although this one is clearly **not** fixed in 3.10, or 3.11! Maybe in 3.12?! - Having said that, the missing comma only comes out in the one-liner version, and not if the generator is assigned to a variable name
But yes, error messages are not Python's strongest feature!
@peterdrake in fact, this is what comes out in 3.11 when running that line in a script:
`(x**2 for x in range(10))[3]`
`Traceback (most recent call last):`
`File` `"/Users/stephengruppetta/PycharmProjects/Testing/test.py", line 1, in <module>`
`(x**2 for x in range(10))[3]`
`~~~~~~~~~~~~~~~~~~~~~~~~~^^^`
`TypeError: 'generator' object is not subscriptable`
@peterdrake PS: That needs 3.11
@s_gruppetta Ah, that is more helpful. I mean, you still need to know what a generator object is, but at least it points to the location of the problem.
@s_gruppetta I have to deliver lots of different kinds of code for different products but, for anything complex, I usually work out the algorithm in #Python to I can focus on the big picture. Once it's working, I rewrite an (sometimes) optimize for the actual target language (e.g. JavaScript).
Anyway, same reasoning, different use case!