Hacker News new | ask | show | jobs
by thaumaturgy 1269 days ago
I've been recommending Python to the occasional aspirational young programmer. Is it already passé? What would you recommend instead for a starter language? Looking for beginner-friendliness, widespread use, and longevity.

edit: to be clear, I hope this won't devolve into a language flamewar. I'm sincerely interested in other devs' opinions, and hoping that either Python is still a good recommendation (which seems to be the consensus so far) or that there's a better alternative.

9 comments

No, it isn't passe, this developer just has some personal gripes with it that can range from understandable to "you'd complain if we did it any other way" with regard to their question about why type annotations were implemented the way they were.
If you want "beginner-friendliness, widespread use, and longevity" then Python remains a fantastic choice.
I hate a lot of things about python because I've been using it for almost 20 years, and I know its innards, its history and its trajectory. I want to love Nim or Julia or Typescript, but they just aren't doing it for me. But you can't hate a language as deeply as I do without loving it as long as I have. I don't think this article, or my own opinions, are representative of the community.
Python is the number one language in the world right now. Exactly the opposite of passe.
I have, for the life of me, never understood the 'beginner friendly' argument for python.

Java, PHP or JavaScript for 'widespread use and longevity'. None of these are going anywhere, and I think you'd find more resources for beginners to advanced users for those 3. Yes, of course there's others - everyone has their faves. And Python will continue to kick around as well, but I've just never understood the 'beginner friendly' bit.

Java the language used to be so simple that it needed significant library usage to accomplish anything at all. It aimed for ‘safe C with classes’ and succeeded… in the enterprise where management was making technical decisions. After feeling the heat from C# it managed to catch up, mostly, to modern realities. Not a good beginner language, despite the simplicity.

PHP was not designed at all. It took a decade to make it more than a template processor. The biggest, by far, selling point was ease of deployment: ftp and done. Good if you want to display something in a browser. Learning programming, not so much.

Javascript is starting to become a sane language with ES6. It’s an accident of history that became an industry standard due to sheer power of will of browser companies. Tooling complexity in its ecosystem rivals, if not exceeds, that of C++. Recommending js s as a language to learn programming on has been until last couple of years irresponsible.

Python was designed to be beginner friendly, it was the next iteration of other beginner-friendly languages that had some academic research done about, you guessed it, beginner friendliness. It is not an accident it’s recommended for newbies! Due to that and a decade of 1) numpy for biological computing 2) django/flask for web services it’s ubiquitous in two very loosely connected domains, giving birth to jupyter and tensor libraries, and here we are. Turns out a batteries-included standard library makes packaging not a priority for too long.

I would guess the main reason it gets recommended to beginners is because it's the most prominent language with the most minimalist syntax, so you can read it more closely to a written language.

Also, being interpreted, you don't need much (or really any other than the interpreter itself) tooling to start playing around with it. This is true, of course, for lots of other languages.

I think also the fact that people do use it for real solutions makes it more appealing to recommend than a "toy" language like Logo or BASIC. (Mentally, I see BASIC as separate than VB. And yes, I am sure some people will comment that real solutions are built in BASIC, but I am sure these days Python dwarfs those in count by a factor of 100, at least.)

In my experience PowerShell fits well as a toe-dipping language.

It allows to solve the menial tasks someone with no programmng experience usually needs to solve, can interact with HTTP/REST-like APIs, sometimes has the modules for a popular solutions, is object oriented, lax on the indentation *smirk*.

> In my experience PowerShell fits well as a toe-dipping language.

Ugh. Sorry, I've not really got anything constructive (destructive?) to say in support of that other than (a) in practical terms it isn't a transferrable skill beyond Windows, (b) the Naming-Conventions-OfThings is both awful and verbose, and (c) I've never had a use case where more than a handful (at most) of my fellow devs would be happy to work with it in the future.

YMMV and I appreciate this is very much a personal opinion.

a) thats only for modules designed to interact with Windows features. Sure, Get-ADComputer doesn't work on Linux, but... by default Python doesn't work with a ton of things which are available through the wast library of Python modules. Same deal with PS, you can't interact with Snipe-it or Netbox by deaful... but there are modules for that.[0]

Basics works everywhere. In my personal experience I often found myself in a situation where I'm spending a lot of time wrestling with *nix shell (especially finding workarounds for the differences between Debian/Ubuntu and RH/CentOS/Rocky) instead of spending 5 minutes on PS script which would would everywhere, just supply the distro specific paths.

b) not a problem in the real life. Come on, you don't sprn you time writing the paths, you just TAB them - same thing with PS, except it works on cmdlet names AND their parameters, out of the box, on any platform. Ubuntu has it now by default (for some supported things), RH-like - not.

c) well they probably had a more familiar to them tool on their hands already

YMMV, of course, but the thing is what you are being constructive here, with explicitly stating things you don't kno2 or understand.

[0] and there are Py modules for that too, but they are not the part of the default install too

I appreciate the response; as I say, YMMV. I did feel a little misunderstood at the end of that response, though, so I'll clarify.

> explicitly stating things you don't kno2 or understand

I've done Windows development since 3.1 (and .Net since 2001) so in that time I've written a lot of PowerShell. I'm not offering uninformed second-hand opinions.

For (a) I'd argue that the lack of adoption outside Windows makes it de-facto not really a transferrable skill, even though it does run elsewhere. For (b) so what if it is easy to autocomplete? It doesn't make it any less ugly/verbose. For (c) yes, that was exactly my point. Stuff needs to be maintainable, and if fellow devs have other more familiar tooling then using that tooling is usually more appropriate.

If PowerShell is for you, great. I don't feel the need to convince you otherwise; in your situation maybe it is. But sometimes a difference of opinion is just that - a difference of opinion, and not ignorance of the subject matter.

> lack of adoption outside Windows makes it de-facto not really a transferrable skill

If you want to only write/use PS - then probably, but... if this is yours environment - you chose the tools, if it's not - the overall concepts and workflow doesn't differs too much, especially for Python.

I had an unpleasant experience of rewriting a Python 2 script to Python 3. At some point I just said "fuck it" and rewrote it, from scratch, on Linux, with .NET SNMP library - and I got a working script in an hour, compared to 3 days of headache with a known good Py2 script which I only needed to adapt to Py3.

The difference was in the quirks of Python (especially on strong typing and indentation), not in the program flow.

Later I finished rewriting it in Py3 but the overall experience of writing in Python left a sour taste.

A person who would start with PS could easily adapt to Python (or honestly any other language) if he would understand how the things work - and PS allows, IMNSHO, that in a quick and easy way.

But if someone just copy-paste the code from SE - does it matters if that happens in Python or PS?

> so what if it is easy to autocomplete? It doesn't make it any less ugly/verbose

LOL, "I need a PL what is easy for a beginner, so I would NOT recommend an explicitly verbose language for that!"?

a) easiness of autocomplete allows the discoverability of the options. Just a simple Ctrl+Space offers all the options of a cmdlet (conveniently listing them with the precedence used by the author, leaving all the automatic shit added by cmdletbinding() at the end) and this alone helps tremendously with writing. I don't keep all the things, options and parameters in my head (and I don't want to) and a beginner doesn't know them in the first place.

Most of the time I just write something and see if the are means to do what I want through the autocompletion of parameters and cmdlets. If I don't see the appropriate things or they don't work as I expect them to work - only then I consult with manual. If in your opinion nobody should write a single LOC without a couple of hours in the docs...

b) I often hear about how the verboseness of PS as bad thing, but... honestly, IMO, it doesn't matter, it's not THAT verbose as Java, it's not full of obscure and senseless abbreviations and names (especially compared to Linux CLI) and if you compare the actual similar code.. it's not that big difference in LOC and line length. Oh, and you don't reinvent the wheel each time you need to have a working help and argument parsing *smirk*.

c) are we still on the "PL for a beginner" topic? For a carpenter microscope is just a very bad hammer.

> difference of opinion

Let's get back to "PL for a beginner". Between Python and PS the latter would win just because it has a better IDE/autocomplete and has automagik on a lot of things what would drive a beginner mad in Python (oh god, just calling an external binary and capturing it's output...)

PS, as an anecdata: I have a friend who can write some Java, for util level things. I've seen his PS code - he treats PS as a full fledged PL (which again - isn't a bad thing, just not the best way to spend your time writing PS scripts). I doubt he wrote anything in Python, but of what I saw in his PS code means he would have no problems (well, except strong typing and indentation, LOL) writing something in Python.

Some good points (though I remain unconvinced about PS personally).

The only thing I'd note is that unfortunately by not mentioning it in my earlier reply I left you thinking I was suggesting Python over PowerShell, which makes sense given the way others were discussing the topic.

On this, however, I agree with you in that I too would not automatically suggest Python as the best learning language. I'd actually plump for Go scripting or C# (single file), but on the understanding that it's for learning business domain or web programming. For the true beginner I don't really have a strong opinion so maybe PS could work.

Anyway, thanks for the detailed response :)

Python is syntactically simple but that doesn't necessarily make it a good choice for beginners. I've seen students spend hours wrestling the interpreter over whitespace issues.
I tend towards recommending python just because of that. I used to be a TA in an intro to programming course, and it's unbelievable the mess complete beginners can make when indentation isn't enforced, like in {} delimited languages.
Maybe they shouldn't be using Notepad.
err, they were using IDLE.
Then they should have spent some minutes reading documentation on how to use their tooling,

https://docs.python.org/3/library/idle.html#automatic-indent...

The docs you linked say that IDLE can help with indentation, not reindent code for you. This might surprise you, but students don't necessarily know how to preserve indentation or reindent code as they cut/paste around.
> See also the indent/dedent region commands on the Format menu.

So not even you are reading the documentation?

And if IDLE is not good enough for students, Komodo IDE exists for 20 years, VS and VSCode also do a quite good job, PyCharm, as do Emacs and vim.

It isn't as if the alternative JavaScript and Go code is being written without adequate tooling.

Python is quite alright as the new BASIC, keep recomending it.
It is not horrible for doing basic things or light weight things.

And after they learn those and have few fights. They might be ready to research what to choose for next project.

Python is a good choice for many large projects, as well. Typing has helped a lot when it comes to managing large codebases in Python that would have been a pain to manage using something like Python 2.