Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Good thing about python is, that everything is an object, yet nothing really is, so you can just slam your face on the keyboard when in doubt
-
ltlian21886y@ganjaman My coworkers and I were talking about our previous language experiences the other day and someone commented that they had mostly used JS, PHP, and python, and didn't have much experience with OOP. Someone commented that "python has classes and objects though, doesn't it?"
Cue a room full of devs pulling air through their teeth and murmuring "well SORT OF~" and "I GUESS, but-".
I remember trying to emulate a switchcase using a dict where the values were functions because you can just assign them as objects. I ended up with beautiful snippets such as fncs[fnc_arg](param_arg) which may or may not return, and may or may not accept an input parameter, which may or may not be defined, which it is likely but not guaranteed to tolerate. -
VaderNT16176y@ltlian
> Someone commented that "python has classes and objects though, doesn't it?"
Just an aside, you don't need classes for OOP. JavaScript being a popular example. So with JS and Python in the list, mentioned cowoker missed *two* chances for OOP. Which is actually kind of remarkable... 😉
> Cue a room full of devs pulling air through their teeth and murmuring "well SORT OF~" and "I GUESS, but-".
I don't understand. The answer is "yes". Why the urge to hem and haw? -
@VaderNT because the answer is not a clear yes (at least in pythons case, ionno bout js), and even the docs confirm it
-
VaderNT16176y@ganjaman I disagree. Based on what Wikipedia has to say on "class"[1] and "object"[2], the answer is a definitive "yes". Wikipedia even mentions Python. Heck, the article about Python[3] says "Python (...) supports multiple programming paradigms, including (...) object-oriented (...) programming".
> even the docs confirm it
What do the docs say and where?
[1]: https://en.wikipedia.org/wiki/...
[2]: https://en.wikipedia.org/wiki/...
[3]: https://en.wikipedia.org/wiki/... -
I know this is controversial but just a question.
Why would any company use Python? Python isn't that sort of a programming language. Its not made for serious company use. It's a easy, slow language made for learning programming.
I know that there are companies that do use Python (https://www.python.org/about/quotes) but why? There are so many better options.
Its basically just a excuse for hiring less experienced people for software related jobs.
It of course depends really much on the purpose of the program but I would say that c for example is good alternative for Python. And the people that works in the company most likely know C because they have studied CS (dumb assumption). And whats the point of having people that know how to use more effective programming language use super low level languages like python?
And if its a company that does web only then why does it even use Python from begin with when there is stuff like php and javascript. -
@HampusMa I am a Cloud Engineer/DevOps Engineer/whatever-the-latest-buzzword-is. We use Python because the vast majority of our code is for AWS Lambda functions for cloud automation tasks. Python has a very nice library for interacting with AWS resources (in fact, the AWS CLI itself is written in Python).
-
@EmberQuill i understand but there is actually a cpp runtime for it too (https://aws.amazon.com/blogs/...).
I know that it can be easier with Python but more complex programming languages can give oppertunity to better solutions. -
@HampusMa If I ever run into something I can't do in Python, I'll give it a try, but I haven't yet. That was also just released 6 months ago, long after I started working with AWS.
What would be the benefits of using C++ for Lambda? -
@HampusMa Python because it's more cost efficient to have rapid development with lower grade developers. Oh and it's actually fun to code in Python.
-
@EmberQuill @PaszaVonPomiot
Python is up to about 400 times slower than C++ and with the exception of a single case, Python is more of a memory hog. When it comes to source size though, Python wins flat out.
There are multiple reason for this:
• Python is interpreted, while C++ is compiled
• Python has no primitives, everything including the builtin types (int, float, etc.) are objects
• A Python list can hold objects of different type, so each entry has to store additional data about its type. These all severely hinder both runtime and memory consumption.
But Python can still be useful though. A lot of software doesn't require much time or memory even with the 100 time slowness factor. And as you said, PaszaVonPomiotDevelopment, cost is where Python wins with the simple and concise style. This improvement on development cost often outweighs the cost of additional cpu and memory resources. When it doesn't, however, then C++ wins. -
@HampusMa the thing about AWS Lambda functions is that most of that doesn't matter. Resource usage and time is low anyway because Lambdas usually have a small footprint already. Python is also just plain easy to use and is great for rapid development. Everyone on my team either already knew or quickly learned Python, while only a couple of us know C++ all that well. The performance boost we'd get from switching to C++ would be negligible at the scale we work with, and we'd all have to learn or re-learn how to use it. As it's an interpreted language, we can easily hop into the Python console to test things interactively. Also has built-in garbage collection.
If we were working on embedded systems, or very old hardware, or if we cared about shaving off a few milliseconds from the run time (almost all of our code involves making calls to web APIs and you can't really speed that up much), then we'd certainly look at other languages. -
Python's classes don't have a visibility, eg private / protected. You can "work around that"… but it's one of the things that bugs me.
Otherwise...
The speed thing is an annoying point of discussion.
If speed was the goal, AWS would have been a red flag right from the beginning.
Even C++ isn't per se fast.
If you want fast fast fast fast, you'll have to twist your mind a bit further and start diving into the ""fun"" of X86 intrinsics, threading, utilizing the GPU and the bunch of libraries which are necessary (OpenMP eg).
A programming language itself is not the deciding factor anymore for speed, and speed has become a very delicate matter.
If you need maximum speed, it will cost you. Since the knowledge isn't cheap.
Related Rants
When I was starting with Python at work I was very confused about identifying what is function, class, module, object instance, etc. just by name so I asked my colleague with PHP background to follow PEP8 and use meaningful names for objects. He's like okay and the next day I find this:
class vv(models.Model):
rant
python