Python Decorators Considered Harmful (www.youtube.com)
from rimu@piefed.social to python@programming.dev on 08 May 2025 23:39
https://piefed.social/post/735344

Python decorators look like a great way to add functionality—until they break your type safety, hide function requirements, and turn debugging into a nightmare. This video shows you why decorators can be dangerous, the biggest pitfalls to watch out for, and when you should actually use them.

#python

threaded - newest

jimmux@programming.dev on 09 May 2025 02:23 next collapse

I can live with decorators in Python (and JavaScript while we’re at it) because they’re kind of in the spirit of the language. You have a big bag of tools and are trusted to use them responsibly.

I’ve only had problems when annotations in Java are used to do similar things. At some point you have to admit that all the bypassing of language features means you picked the wrong language, and maybe you don’t want rigorous OO purity after all.

m_f@discuss.online on 09 May 2025 03:28 next collapse

“Considered Harmful” Essays Considered Harmful

Because “considered harmful” essays are, by their nature, so incendiary, they are counter-productive both in terms of encouraging open and intelligent debate, and in gathering support for the view they promote.

At any rate, they don’t have to break type safety anymore with PEP 612

lukalix98@programming.dev on 09 May 2025 10:44 collapse

I feel like Bertrand Russel trying to figure out whether the essay you posted is actually harmful then…

Artyom@lemm.ee on 09 May 2025 03:50 collapse

Sometimes people get excited to write fancy code, when they should actually be excited to write simpler code.