10

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):

Comments
  • 8
    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
  • 4
    @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.
  • 0
    @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?
  • 0
    @VaderNT because the answer is not a clear yes (at least in pythons case, ionno bout js), and even the docs confirm it
  • 0
    @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/...
  • 1
    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.
  • 1
    @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).
  • 0
    @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.
  • 0
    @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?
  • 0
    @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.
  • 0
    @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.
  • 0
    @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.
  • 0
    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.
Add Comment