Hacker News new | ask | show | jobs
by culi 1285 days ago
Tangent, but tbh I really don't see what the future of Python is. I don't understand why we don't just teach JS or TS as a starting language. It has about as much baggage and is about as easy to understand as Python and is the only language with a comparable ecosystem. Plus you also get to learn the language of the web for free. And now that you have stuff like deno that can run typescript without any messy dependencies. You can just make a quick ts file and write your webscraper or proof of concept and run it in the terminal. At least personally, that replaces my primary use-case for Python and I get to take advantage of TS's amazing type system which really comes in handy when dealing with external APIs.

I really don't see a place for Python

  ml --> Julia, C++, R
  dataviz --> R, JS/TS
  beginner-friendly --> JS
  web --> JS
  want a backend framework but wanna choose a language that's easy to hire for --> TS, Ruby
  huge, stable community --> JS/TS
  quick scripts --> Deno
  systems --> Rust, C++, Java, Go
I'd say it still dominates in scripting/webscraping and creating shareable work (e.g. Jupyter), but I'm just pointing out that at this point it's replaceable in those areas
8 comments

> I really don't see a place for Python

I agree. Around 2008, I was drunk on "the zen of Python", considering myself a Pythonista, writing elegant solutions, making unmaintainable one liners etc. But really Lisp was so much better for that power/speed of development. Eventually (for me) go was so much more powerful, easy to maintain etc. with actual industry usage (seemingly instantly) without any loss in productivity.

Python solutions seem no better than maligned JS solutions nowadays - but at least there's TS and efforts to improve it where they can. Indeed, most Python code doesn't seem to be in proper production, but just one of exploratory scripts and pieces strewn about in notebooks. It seems like it could easily lose market share quite quickly.

The moat for JavaScript is web-frontend, otherwise it would not be used (note the current rewriting of most of its tooling into non-JS languages). I would not call it beginner-friendly, stable, or good for quick scripts (does node come with sqlite?). I've yet to see a stable equivalent to django/rails. Javascript's data visualisation comes from it being in the browser, which has severe limitations (e.g. the need for WASM), and it's usually much easier if you don't need to two languages to do analysis (as the JavaScript numerical and data format ecosystem is a mess).

Python's advantage is apart from web-frontend (I have no expectation PyScript will catch on), it is everywhere, even when you don't expect it to be (e.g. Bank Python, VFX, Postgres, build systems, scripting interfaces in apps). Are there better options for specific usecases? Yes, but it's when these usecases intersect that Python wins out.

> I've yet to see a stable equivalent to django/rails

... express? Has better benchmarks than both those frameworks, is probably more commonly used today (more employable), and has the benefit of TypeScript which fixes the biggest issues with both Python and Ruby (lack of a good type system)

> Python's advantage is [...] it is everywhere

Yes, that's my point. That's it's only advantage. But JS is better setup to become the "just use it because everyone knows it" language imo.

Having used express, and being shocked at how bad it is, no, express is nowhere near equivalent django/rails (flask, the go to microframework for Python, is more complete than express).

TypeScript has two major issues (which it shares with Python's type annotations): it has to interact with untyped code (so what you think it fine is not, especially when key libraries are not written in TypeScript), and it tends to increase barriers to modifying the code (unlike more functional languages, whose type system tends to be both complete and have less footguns).

As to JavaScript being more commonly used and known, that's dependent on where you're working (especially when it can be sandboxed off so that the majority of users don't need to deal with it, see plotly dash and R-shiny). I suspect having seen multiple examples of systems where JavaScript was used where it was entirely the wrong tool (and where for various reasons Python was the correct one, partially due to the difference in the library ecosystems), we'll see a slow retreat over time of JavaScript to its core areas (being front-end and server-side rendering of the front-end), as more people find that having two languages is a better choice, and rewrite/replace existing JavaScript services.

The key advantage of Python is that it's good enough at many things and that there is a giant infrastructure of libraries and a huge community (and thus tutorials, howtos, stackoverflow answers etc.).

You mention Julia/C++/R for ML. My counterargument would be that things like fast.ai exist, use Python and make the whole topic approachable. I also find it a bit hard to belive many people that don't come from a stats/other academic field background would readily pick R over Python for anything ML related. I personally never thought JS was very beginner friendly because setup was traditionally clunky. That has thankfully changed a lot.

You mention many things that are better in theory but in practice I need to get work done now. I'd probably rather write quick scripts in Python (or bash) than Deno for example.

It's probably also easier to hire for Python than Ruby at least I'm not convinced Ruby has a giant edge. Huge, stable community is also exactly what Python has.

Python also has mindshare in many niches for example in security many things are quickly scripted in Python (notoriously Python 2 in some cases). Go and Ruby are also used for a lot of tooling there.

At the end of the day, if someone from a non-programming background asks me what language to learn, I still recommend Python (because usually they either want to pivot into ML somehow or want to get some quick scripting done to automate something or want to scrape some data). If I were to teach my child, I'd probably pick what I consider the most fun and completely ignore employability (Elixir) and if I were to build a CS program from sratch I'd have to think long and hard. I might end on Rust or Go but JS would be in the running (depends if there's a big focus on embedded/osdev etc.).

At the end of the day, "pick whatever language gets the job done" is still the best recommendation in my opinion :)

> The key advantage of Python is that it's good enough at many things and that there is a giant infrastructure of libraries and a huge community

Right that's exactly my point. But once that's gone there's not really anything left for it. JS is also good enough at everything and probably has a larger community and more stability given it's the language of the web. Def not there in terms of ML yet, but it can get there

> I'd probably rather write quick scripts in Python

Because you're used to it.

> It's probably also easier to hire for Python than Ruby

If we're talking backend, an even easier thing to higher for than both of them is JS/TS

> Python also has mindshare in many niches for example in security many things are quickly scripted in Python

Yup. Again, this is the momentum of its community, but not anything inherent to it

> "pick whatever language gets the job done"

I don't disagree that that language isn't usually Python today. I'm just saying all of its success is due to the community and ecosystem so I don't see any guarantee that this will still be the case many years from now

> I also find it a bit hard to belive many people that don't come from a stats/other academic field background would readily pick R over Python for anything ML related

I agree with this, but actually suspect that it's a good thing. People without some experience of stats probably shouldn't be using ML, and if R use helps to identify these people, I'm all for it.

That being said, basically every company has standardised on Python, some for good reasons and others because of the PR Python has gotten through DL stuff.

JS suffers way too much from a lack of a good comprehensive standard library and builtins. It doesn't even have list comprehensions!

I get thinking Python and JS are "kind of the same", but there are so many details that Python gets right and JS kinda falls apart on. Python's pervasive dunder methods means that you can look at objects in a REPL and get a good representation (try looking at any non-trivial Javascript object and it's a major pain). You can define equality. Operations _don't_ stringify by default (so dictionaries work like you think they should). And Python has blocking methods, which means that you can write code in a straightforward way.

There are a lot of things playing in JS's favor but especially as packaging stories get better it's hard to discount Python's ease of use relative to Javascript IMO. And all of this is kind of ignoring the fact that most people are _actually_ talking about Typescript when they talk about JS nowadays, because writing "raw" JS is so error prone that it would be very difficult to actually get serious work done in it without an extra lint phase (I say this as a huge TS proponent)

> It doesn't even have list comprehensions!

JS actually did used to have list comprehension but it was deprecated because nobody used it. There's no need imo. .map, .filter, .reduce, and other array methods achieve the same thing with a nicer syntax imo

Also JS has undoubtedly one of the nicest anonymous function syntax with arrow functions. Something I constantly find myself missing when I'm in a python file.

> And Python has blocking methods

What does this mean? Isn't JS blocking by default? Both languages have async support that you don't have to use...

> it's hard to discount Python's ease of use relative to Javascript

Hmm I guess we just have different experiences with this. I can open up a quick text file anywhere on my computer, save it as a .ts file, import whatever library I want, use TS if I want it, etc and then just run it in the CLI with `deno run test_run.ts`

Feels pretty easy to me. And then you have _anything_ related to UI. Maybe it's just me but I never quite felt comfortable with GUI libraries in Python. With JS I can just make an HTML file and open it up in any browser and I have access to the most cross-platform UI API in the world: the WWW

> "raw" JS is so error prone that it would be very difficult to actually get serious work done in it

If you're trying to get "serious" work done you probably shouldn't be using either of these languages. Or if you are, you'd definitely have some linter set up for either one. Also, Python's typehints are nice, but it can't compare to TS. And if you don't wanna go all in on TS, you could always stick with JSDoc comments which get you 90% of the way there for small projects and have really great support in any modern IDE.

> What does this mean? Isn't JS blocking by default? Both languages have async support that you don't have to use...

To be clear on this, because JS APIs prioritize non-blocking mechanism to the expense of everything else (related to it the original sin of how JS interacts with a browser IMO), everything has to become async, even though in practice a lot of this stuff is happening sequentially anyways.

See this example Playwright test [0]. awaits everywhere. Because of how await works as well (Rust got this one right with postfix await), suddenly fluent APIs become awkward. You no longer have foo.bar().baz() but (await foo.bar()).baz(). (await getResources()).map(f) is not beautiful in my eyes.

And the core thing is that almost no code actually relies on concurrency in practice! So much of this is a consequence of the problem of JS not having good yielding semantics, and its interaction with the DOM in general.

Is this the biggest issue in the world? I guess not, but I very much dislike the aesthetics of this fore smaller chunks of code. I would really like a model with implicit awaiting in ~all the places that it exists currently.

I do agree that JS's anonymous function syntax is nice, and I miss it dearly in Python. Though here as well, I think Python comes up on top with all of its argument/keyword argument strategies. I get the options dictionary pattern, but dislike it.

And UI stuff is of course ... well it's easier in Javascript (though it requires its own infrastructure). There's no ways around that.

Loads of serious work is done in both language, I just think that JS is missing a lot of table stakes features given that there's so much attention to it.

[0]: https://playwright.dev/docs/writing-tests#the-example-test

Except that you can use python in most of the use case you mention

  ml --> Python
  dataviz --> Python
  beginner-friendly --> Python
  web --> JS
  want a backend framework but wanna choose a language that's easy to hire for --> Python
  huge, stable community --> Python
  quick scripts --> Python
  high level system --> Python
  low level systems --> Rust, C/C++
Yeah sorry if I wasn't clear. That was my point. These are all the areas where Python is currently used, but there are better options for all of them now
I think the point of Python is that it covers so many of your use cases:

Beginner friendly -> Python

Then use for ml, dataviz, huge community, quick scripts, backend

Your migration doesn’t do that and I’d argue that JS isn’t as good as Python for a lot of those use cases anyway.

You're calling the community that makes a new framework every nanosecond “stable”?
More stable than python that's for sure. You could just go with react or node (depending on your use case) , pick a build tool, and be set for half a decade. That's absolutely not the case with Python, and I'm not just talking about the breaking changes that happen in some releases. You also don't get a mess of venv, conda environments, incompatible packages, having to use docker to deploy your app, etc. I use Python a lot, and I like it, but Javascript is much more stable as a platform for quite a lot of what python is generally used for.
JS is more tightly bound as the "language of the web" than Python is bound as "the language of data science".

That's all I'm saying really. I would bet more money that JS is here 15 years from now than that Python is

I think WASM will upend some of this.
Hopefully, but I doubt it'll do so any time soon. Even if it does, JS will still have momentum because of the lack of tooling and setup needed to use it. It's still gonna be in every "intro to web dev" tutorial ever for many more years to come
> I don't understand why we don't just teach JS or TS as a starting language.

IMO the main problem is pedagogical. JS is a vast sea of conveniences that contradict conventional programming practices. This is also the reason I hesitate to recommend R as a starting language, for all that it's the de facto language of statistical analysis. Both languages are hard to teach in a coherent way, because both have lots of gotchas and exceptions that aren't bad, per se, but in the aggregate impede understanding of fundamentals.

Just yesterday I was working with someone on fundamentals in R, distinguishing between literals, variables, and functions. He got the idea, and then we got to model specification (`lm(y ~ x)`) and I had to shrug and say, those "identifiers" are different. I shudder to think of trying to teach types with a beginning student in JS.