this post was submitted on 02 Nov 2024
268 points (98.2% liked)

Python

6677 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 62 points 3 months ago (1 children)

Ok after reading the article this is bullshit. It's only because they are counting JavaScript and Typescript separately.

[–] [email protected] 22 points 3 months ago (1 children)

Typescript being that popular is great news onto itself.

[–] [email protected] 5 points 3 months ago (2 children)

We have different concept about what great news is.

Compiling to an interpreted high level language is crazy. I just refuse to believe we haven't got a better solution to yet.

[–] [email protected] 5 points 3 months ago

As someone who works with typescript daily, you're not wrong. It's an extremely overcomplicated glorified linter that tries and mostly succeeds in catching basic type errors. But it also provides false confidence when you concoct something that shows no errors but doesn't behave how you expect.

[–] [email protected] 2 points 3 months ago

Don't worry, they're planning JS0 and JSSugar (IIRC) so you're forced to compile anyway :D

[–] [email protected] 25 points 3 months ago* (last edited 3 months ago) (3 children)

Thank god, Javascript is a mess.

I’ll still plug Scala for having the beauty of Python, the ecosystem of Java, the correctness of Rust, the concurrency of Go, and the power of Lisp.

[–] [email protected] 64 points 3 months ago (13 children)

I code both typescript and python professionally, and python is almost as much of a mess, just a different kind of mess. The package manager ecosystem is all over the place, nobody is agreeing on a build system, and the type system is still unable to represent fairly simple concepts when it comes to function typing. Also tons of libraries just ignore types altogether. I love it, but as a competitor to JavaScript in the messiness department it's not a good horse.

[–] legion02 15 points 3 months ago* (last edited 3 months ago) (1 children)

They ignore types all together because typing is optional in python.

[–] [email protected] 13 points 3 months ago (4 children)

All documentation is optional and ignored at runtime, that doesn't mean you shouldn't do it. If your library doesn't have type hints I'm just not gonna use it, I don't have the time to figure out what you accept or return.

load more comments (4 replies)
[–] eager_eagle 3 points 3 months ago (2 children)

types are always ignored at runtime, they're only useful when developing

[–] [email protected] 6 points 3 months ago (2 children)

Yeah, they're useful when developing, which is why it's so frustrating when libraries don't implement types. I'm developing and I'm trying to use a tool that supposedly fits a use case I have, but the tool didn't come with instructions so it's practically useless to me. I could open the tool up and look at its guts to figure it out but are you kidding me no, I'm not going back to the stone age for your tool.

[–] eager_eagle 3 points 3 months ago* (last edited 3 months ago)

basically sums up the opencv experience in Python.

great lib, very mediocre Python wrapper.

load more comments (1 replies)
load more comments (1 replies)
load more comments (11 replies)
[–] [email protected] 2 points 3 months ago (3 children)

Typescript is far nicer than Python though. Well I will give Python one point: arbitrary precision integers was absolutely the right decision. Dealing with u64s in Typescript is a right pain.

But apart from that it's difficult to see a single point on which Python is clearly better than Typescript:

  • Static typing. Pyright is great but it's entirely optional and rarely used. Typescript obviously wins here.
  • Tooling. Deno is fantastic but even if we regress to Node/NPM it's still a million miles better than the absolute dog shit pile of vomit that is Pip & venv. Sorry Python but admit your flaws. uv is a shining beacon of light here but I have little hope that the upstream Python devs will recognise that they need to immediately ditch pip in favour of officially endorsing uv. No. They'll keep it on the sidelines until the uv devs run out of hope and money and give up.
  • Performance. Well I don't need to say more.
  • Language sanity. They're pretty on par here I think - both so-so. JavaScript has big warts (the whole prototype system was clearly a dumb idea) but you can easily avoid them, especially with ESLint. But Python has equally but warts that Pylint will tell you about, e.g. having to tediously specify the encoding for every file access.
  • Libraries & ecosystem. Again I would say there's no much in it. You'd obviously be insane to use Python for anything web related (unless it's for Django which is admittedly decent). On the other hand Python clearly dominates in AI, at least if you don't care about actually deploying anything.
[–] eager_eagle 7 points 3 months ago* (last edited 3 months ago)

I write mostly Python for 5 years and uv is indeed the best thing that happened to the Python landscape during this period.

I disagree that typescript is far nicer; even syntax-wise, type annotated Python seems much easier to read, write, and refactor; but I'll give that Python needs to ditch pip and "requirements.txt" for good.

[–] [email protected] 6 points 3 months ago (1 children)

Language sanity. They’re pretty on par here I think

[1] + [2]
"12"

A sane language, you say.

const foo = 'hello' 
const bar = { foo: 'world'}
console.log(bar)
// { "foo": "world" }

the absolute dog shit pile of vomit that is Pip & venv

I've worked professionally in python for several years and I don't think it's ever caused a serious problem. Everything's in docker so you don't even use venv.

[–] [email protected] 6 points 3 months ago (1 children)

A sane language, you say.

Yes:

Operator '+' cannot be applied to types 'number[]' and 'number[]'.

We're talking about Typescript here. Also I did say that it has some big warts, but you can mostly avoid them with ESLint (and Typescript of course).

Let's not pretend Python doesn't have similar warts:

>>> x = -5
>>> y = -5
>>> x is y
True
>>> x = -6
>>> y = -6
>>> x is y
False
>>> x = -6; y = -6; x is y
True
>>> isinstance(False, int)
True
>>> [f() for f in [lambda: i for i in range(10)]]
[9, 9, 9, 9, 9, 9, 9, 9, 9, 9]

There's a whole very long list here. Don't get be wrong, Python does a decent job of not being crazy. But so does Typescript+ESLint.

I’ve worked professionally in python for several years and I don’t think it’s ever caused a serious problem. Everything’s in docker so you don’t even use venv.

"It's so bad I have resorted to using Docker whenever I use Python."

[–] [email protected] 2 points 3 months ago (1 children)

Why would you use the is operator like that?

The lambda thing is from late binding, which I've had come up at work once. https://docs.python-guide.org/writing/gotchas/#late-binding-closures.

“It’s so bad I have resorted to using Docker whenever I use Python.”

Do you not use containers when you deploy ? Everywhere I've worked in the past like 10 years has moved to containers.

Also this is the same energy as "JavaScript is so bad you've resorted to using a whole other language: Typescript"

To your point, typescript does solve a lot of problems. But the language it's built on top of it is extremely warty. Maybe we agree on that.

[–] [email protected] 2 points 3 months ago (1 children)

Why would you use the is operator like that?

Why would you add two arrays like that?

Do you not use containers when you deploy

No because I am not using Python to make a web app. That's not the only thing people write you know...

JavaScript is so bad you’ve resorted to using a whole other language: Typescript

Well yeah. Typescript isn't really a new language. It's just type annotations for JavaScript (except for enums; long story). But yes JavaScript is pretty bad without Typescript.

But Typescript isn't a cop-out like Docker is.

But the language it’s built on top of it is extremely warty. Maybe we agree on that.

Yeah definitely. You need to ban the warts but Typescript & ESLint do a pretty good job of that.

I mean I would still much rather write Dart or Rust but if I had to pick between Typescript and Python there's absolutely no way I'd pick Python (unless it was for AI).

[–] [email protected] 2 points 3 months ago (1 children)

Why would you add two arrays like that? Because I want to combine two lists.

The is operator is for identity, not equality. Your example is just using it weirdly in a way that most people wouldn't do.

No because I am not using Python to make a web app. That’s not the only thing people write you know… Most of what I've worked on has been webapps or services that support them :shrug:

Typescript and Python there’s absolutely no way I’d pick Python (unless it was for AI).

Agree to disagree then. We could argue all day but I think it's mostly opinion about what warts and tradeoffs are worth it, and you don't seem like you have no idea what you're talking about. Sometimes I meet junior developers who have only ever used javascript, and it's like (to borrow another contentious nerd topic) like meeting someone who's only ever played D&D talking about game design.

load more comments (1 replies)
[–] [email protected] 3 points 3 months ago* (last edited 3 months ago) (1 children)

What is so bad about virtual environments? I found them to be really nice and useful when I developed in Python over about 5-ish years. It was really nice being able to have separate clean environments for installing libraries and executing things.

Granted, I only used Python as a solo developer, so if there are shortcomings that emerge when working with other developers, then I would not be aware of them....

Edit: also, performance is a bit more of a subtle topic. For numerical logic, Python actually is (probably) much better than a lot of its competitors thanks to numpy and numexpr. For conditional logic, I would agree that it's not the best, but when you consider developer velocity, it's a clearly worthwhile tradeoff since frameworks like Django are so popular.

[–] [email protected] 4 points 3 months ago (1 children)

What is so bad about virtual environments?

They're a solution to a self-inflicted problem. They're only "really nice and useful" if you accept that having your projects stomp all over each others' libraries and environments is normal.

If projects were self-contained from the outset then you wouldn't need an additional tool to make them so.

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 19 points 3 months ago (6 children)

Were just waiting on WASM to be able to access the DOM APIs directly, and then all languages will be first class citizens on the web, and then RIP JavaScript.

[–] [email protected] 4 points 3 months ago

Is that even a stated goal? I swear we've been waiting for that to exist for the better part of a decade. It would solve so many issues and comes up in every discussion about Javascript, yet the powers that be seem to have zero interest in pushing this forward.

[–] [email protected] 3 points 3 months ago

Delphi will be back, baby.

[–] [email protected] 2 points 3 months ago (1 children)

That would be quite an amazing era to live in ahaha ! We can the start the work as a community to match the JavaScript Ecosystem by providing high quality primitives for developers. For that to happen developer UX has to improve though :) but I think WASM definitely has some future.

However to contrast my previous thoughts, I find it pretty sad that people want to move away from JS when we got thing like Bun & Demo 2.0 hitting their prime!

We got benchmarks, cross-runtime stdlib, better registeries, type safety, enough performance, extendability (with runtime plugins & API). I think were approchaing a TS/JS paradigm that's pretty impressive I must admit.

[–] [email protected] 3 points 3 months ago* (last edited 3 months ago)

Deno looks interesting.

But Bun choosing Zig makes me think their priorities are not my priorities. As of now, you choose Zig (a not-yet-stable language) because you want to learn Zig and make a neat side-project. Those are not my priorities. Zig offers no unique advantages other than neat new syntax.

Deno chose Rust, which, like Zig, is new, but Rust has reached 1.0 and offers a unique advantage with its safety features. I'm not saying anything about the greatness of Rust here, only that Rust does offer unique advantages, and Rust could be chosen because of general priorities.

Bun chose Zig and then worked backwards and formed their priorities around Zig. Deno formed their priorities and their priorities lead them to Rust.

That's how I feel anyway.

load more comments (3 replies)
[–] [email protected] 16 points 3 months ago* (last edited 3 months ago)

Also some projects are using web assembly to make frontend python frameworks such as this one https://github.com/kkinder/puepy

Edit: wrong project

[–] [email protected] 15 points 3 months ago

sorry js fans, but python is what an interpreted highlevel language should be

[–] [email protected] 12 points 3 months ago (1 children)
[–] [email protected] 7 points 3 months ago

Yeah I really would love to use Python instead on JavaScript natively for the same use case.

[–] [email protected] 6 points 3 months ago (2 children)

Every time I open a js file from some project I have to tweak to use on my website, I get a brain aneurysm. that shit should never have been invented. python in the browser is the dream we are not allowed to have.

ps: I am just a hobbyist ! so take it lightly.

[–] LANIK2000 11 points 3 months ago (3 children)

Idk, my only experience with python is that any app written in it doesn't fucking work, throwing some esoteric error that has nothing to do with the error at hand and then me needing to look up what unholy specific version I need and manually setting up an environment for it. I dread the day when I'll want to try some random project and yet again the only way to run it will be some shady ass python script.

JS is pure crack and has no right being the backbone of the web, but python is borderline unusable in my experience.

[–] [email protected] 3 points 3 months ago

I avoid anything written in Python. It's not the language at fault it's the ease of entry so you get a lot of low quality software.

load more comments (2 replies)
[–] [email protected] 7 points 3 months ago (2 children)

Somebody should write a python to javascript transpiler for the web...

(please don't actually do that)

[–] [email protected] 12 points 3 months ago (4 children)

There's a Python WASM runtime, if you really want to run python in a browser for some reason...

https://github.com/wasmerio/wasmer-python

[–] [email protected] 3 points 3 months ago

Ooh, neat. There's also puepy, which was linked further down in this thread. It's really cool to see more WASM projects pop up.

load more comments (3 replies)
[–] [email protected] 5 points 3 months ago (2 children)

Python’s major pro is its simple, straightforward syntax, which excels at data handling. This has made it popular with novices of all shades […]

For first-timer coders, Python is easier to learn, understand, and adapt than many low-level programming languages […]

Is python being easy to learn actually true? I can see it being easier than low-level programming. But there's other alternatives like C# and Java that certainly seem much better and easier to me. Especially when you consider the ecosystem around only writing code.

Plus, the Python language is a steadfast feature in the desktop Linux software landscape. It’s preinstalled on most Linux distributions, boasts extensive library support, and can be used to fashion very cool (as well as very basic) Qt, GTK, and other toolkit UIs.

It's certainly available, and more readily available on Linux. The whole v2 v3 mess was lackluster. But I guess preinstalled is convenient, and more accessible than installable Java or whatever.

I've never seen JavaScript or Python popularity as evidence or correlating with actual qualities. More with a self-promoting usage. Python was being used in science, then in AI, then AI became popular. To me, it seems like a natural propagation consequence more than simplicity or features over other frameworks and languages.

[–] coriza 5 points 3 months ago* (last edited 3 months ago)

Is python being easy to learn actually true?

In my experience teaching C to non computer science students It should be. They struggle a lot with variable type and the strict syntax in general, tokenization , etc, but specially ; and {}. They are more visual so I think the forced identification of python helps and they can see to which block a line of code belongs and also it is easy to think one line one statement. When they forgot a semi-colon it is hard to explain that it became one logical line with the next one.

load more comments (1 replies)
[–] [email protected] 3 points 3 months ago

eeew (/s)

I have a dislike for both of them. Well, for JavaScript mainly the server-side part. I'm fine with it on web scripting, where it's the only native one.

[–] VantaBrandon 3 points 3 months ago

Snakes, why did it have to be snakes?

load more comments
view more: next ›