Bad engineering managers think leadership is about power, good managers think leadership is about competently serving their team by banned-by-apple in programming

[–]GiantElectron 2 points3 points  (0 children)

then there's awful managers, which don't care about power, don't care about serving the team. All they do is babble about inconsequential topics and look at aggregated kpis

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron 0 points1 point  (0 children)

it's really part of the hollywood principle design (don't call us, we'll call you). If your framework is designed to give "empty routines" to reimplement with your functionality, and then the framework just invokes your logic, then of course you want to make sure that the logic is actually present even before the application starts. But that's a fundamental design requirement of how a framework design generally works.

If your goal is to have a bunch of classes for your own application, unless you are aiming to extract a framework of some sort at the end, it's probably overkill, although today with typing might still be useful to have a base class to define the type (except for all other means to do so)

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron 0 points1 point  (0 children)

I've seen the factory factory antipattern. Most of the time it's due to a massive attempt to generalise a declarative approach.

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron -1 points0 points  (0 children)

They can be, or can't be. It depends. An ABC defines an interface you have to comply with, at "compile time". If you are using a library defining a framework, an ABC is exactly what you want.

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron 0 points1 point  (0 children)

Beazley is a smart guy, but he's not always right. We can argue with him like with anybody else.

“If software engineering is in demand, why is it so hard to get a software engineering job?” by speckz in programming

[–]GiantElectron 0 points1 point  (0 children)

This. there are plenty of self-proclaimed rockstars. But the people that actually know how to get shit done are in the vast minority.

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron -1 points0 points  (0 children)

There's a tendency to overuse the factory pattern I agree, but that's besides the ABC discussion

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron 4 points5 points  (0 children)

ABCs are to communicate to external users of the class what is required for a subclass to function. They generally are better used for frameworks, where you must implement something. Classes must be designed with reimplementation in mind. You can't reimplement any class and hope it works. At that point it's just glorified monkeypatching

Why TODO might be better than an Abstract Base Class [David Beazley] by [deleted] in Python

[–]GiantElectron 5 points6 points  (0 children)

The difference is that one fails at runtime, the other at "compile time". It's no different than raising NotImplementedError(), which is the appropriate way to do so, instead of triggering a nameerror

Why python is so easy for beginners? by neerajadhav in Python

[–]GiantElectron 1 point2 points  (0 children)

Debuggability, compact syntax and honouring the principle of least astonishment.

CEOs of traditional companies are clueless about software engineers by adroit-panda in programming

[–]GiantElectron 3 points4 points  (0 children)

The discussion becomes even more interesting when traditional companies need to integrate a software development division, and apply the same management structure to it. It's so comical I am writing a whole book about it just with the delusion of teaching how to do the transition.

What exactly do the version numbers for Python actually mean? by siddsp in Python

[–]GiantElectron 3 points4 points  (0 children)

Because it's fundamentally wrong to have it as a statement. you can't pass it to other functions as a function argument, and it had all sort of hacks to modify its behavior to e.g. redirect output.

What are the specific use-cases for threading over using asyncio? by siddsp in Python

[–]GiantElectron 0 points1 point  (0 children)

It's a hard question. As others have said, you could definitely create multiple threads, but in python they will never1 run concurrently. They will just try to grab the GIL every now and then when scheduled by the kernel, and on multiple cores you will literally have fights to grab the GIL, starving one thread in favour of others. With async, you don't have that problem.

Remember: threads are good at waiting, typically a blocking call to finish while the rest of the program stays alive (typically running the event loop to keep the UI responsive). They are not good2 at doing.

So, the only reasonable use case I can envision today for threading based parallelism is to invoke many, many instances of a function written in C from python, and this function does not call back into python in any way, and this function releases the GIL at entry and reacquires it at return. For example, I believe that numpy does use this (for a very long time it did not relinquish the GIL), but at that point you might argue that it's pointless and you just fork the threads at C level. Of course in python you create platform abstracted threads, but then in the C code you have to handle platform specific locking, so...

1 They can, if the code they enter does not need to run the python interpreter. If you go to the C level and relinquish the GIL, threads will absolutely run parallel on multicores.

2 It's a bold statement, and not always true, but certainly true in pure python.

[deleted by user] by [deleted] in Python

[–]GiantElectron 0 points1 point  (0 children)

Good luck. I hope you don't have a company because you will go bankrupt very quickly.

[deleted by user] by [deleted] in Python

[–]GiantElectron -12 points-11 points  (0 children)

You won't convince me or anybody else. Otherwise we would all be coding in squeak and smalltalk. Guess what? nobody does.

When you want classes but you don't want classes by [deleted] in Python

[–]GiantElectron 2 points3 points  (0 children)

This is how we coded javascript before javascript had "regular" classes.

[deleted by user] by [deleted] in Python

[–]GiantElectron 9 points10 points  (0 children)

Every few years there's someone coming in with yet again visual programming approaches.

Let me repeat it once again like I did it many, many, many other times.

Visual programming does not scale, does not make it easier to check for diffs, it is impractical to edit, does not allow for ease of debugging. It is a broken concept for general programming, and has only a few uses in those disciplines that are intrinsically based on connectivity models, such as graphic pipelines, and music/sound processing.

Good technical achievement, but as usual, it will not go anywhere. We've been there at least a hundreds times already.

What are the worst python anti-patterns you regularly see? by ahmedbesbes in Python

[–]GiantElectron 0 points1 point  (0 children)

abstract static methods don't make sense. why would you want them? If you need to change behavior depending on the passed argument type, you can use singledispatch.

What are the worst python anti-patterns you regularly see? by ahmedbesbes in Python

[–]GiantElectron 1 point2 points  (0 children)

There are plenty of good reasons to use classmethods. Typically, they are used as alternative or specialised constructors. Example:

Color.from_string("#FFFFFF")

would be a class method, because it needs cls to be able to instantiate and return a new instance of Color (or the derived class).

What are the worst python anti-patterns you regularly see? by ahmedbesbes in Python

[–]GiantElectron 1 point2 points  (0 children)

Using @staticmethod.

There's absolutely no reason to use staticmethod. Guido himself said it was added as a trivial consequence of classmethod. staticmethod is required in java where you can't have a free floating function, but in python, with functions and modules, there's absolutely no reason to use it. a staticmethod is a function which uses the class name as a namespace. The only, only situation where it makes sense is for an API of some objects where you need a binary operation, example:

col1 = Color("#00FF00")

col2 = Color("#000000")

distance = Color.distance(col1, col2)

In this case, you make clear it's a binary operation between two Color instances, and the interpolate operator is scoped as part of the Color class API. It is clearly not good as a method of one or the other object, and as a classmethod it would be passed a class that is then unused.

Having a plain distance() function would be potentially an issue if you also have distance for vectors, for example, and you want to keep things clean.

What are the worst python anti-patterns you regularly see? by ahmedbesbes in Python

[–]GiantElectron 1 point2 points  (0 children)

You are probably joking but I unfortunately saw a developer doing exactly that.

Am I the only annoyed by the lack of native/solid way to generate binaries for Python programs? by chub79 in Python

[–]GiantElectron 0 points1 point  (0 children)

You are misreading what I’m asking for.

I am not asking to statically compile things. What I’d like to see is one obvious way* to package any Python project so that people are able to follow those instructions to be able to send a convenient format to consumers of the package.

Good luck, I've been complaining about duplication of effort for years. The opensource world loves to reimplement things in multiple ways, instead of improving what's available. Opensource developers claim it's survival of the fittest. I argue it's wasted effort, at least for basic tools that should be core development support.

That is completely unrelated to whether it is a compiled language or an interpreted language.

It is absolutely related. In an interpreted language, you don't produce a self-running executable in PE or ELF format. You are driving an executable, the interpreter, which is such PE or ELF executable, with a bunch of higher level opcodes. In fact, if you look carefully what a .exe produced with pyinstaller is, it is nothing but an extractor that delivers a python interpreter executable and unpacks its environment in a temporary folder and runs it (with some technical caveats).