Console? good, GUI? good, game dev? use Godot engine with its similar language Gdscript, but what else? Ive been seeing AI, Data Science stuff, but whats the point if ita slow?

  • Solemarc@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 minutes ago

    People who say “Python is slow” are generally wrong, yes, the language is slower then C in basically everything and it also almost always doesn’t matter.

    The bottleneck in a console app is not your applications ability to process, it’s your ability to read and type, you will have the same experience in any language.

    The same is true with GUI apps, python GUI apps are generally just bindings to toolkits written in other languages like pyqt is a python wrapper around a C++ toolkit.

    In actual gamedev, something like Pygame is using SDL which is a C library.

    YouTube is a python web app.

    Yes, python is slow, and generally it doesn’t matter, if it’s slow then it’s usually a PEBCAK problem. Python is primarily used as an easy to write language that is gluing together more complicated things written in faster languages.

    Like bash, but readable by humans!

  • Chais@sh.itjust.works
    link
    fedilink
    arrow-up
    6
    ·
    2 hours ago

    Assuming this is a genuine question and not just trolling.
    Python’s main feature, IMO, is that it’s easy to pick up. You don’t need to remember to put a semicolon after nearly every line, so you don’t need to remember which lines don’t need it. Basically you only need to remember to put a colon before an indented block.
    Thanks to significant whitespace even bad code will be moderately legible.
    Control flow and loops are basically written in plain English: for i in range (17): as opposed to e.g. for (int i=0; i<17; i++) {.
    This all reduces the mental load and thus leaves you with more capacity to focus on the task you’re trying to solve.
    It’s a great language to give to your mathematicians, data scientists and other people with rudimentary programming knowledge at best.

    As for the performance: interpreted languages are inherently slower than compiled ones. You don’t get a speed boost from first asking a separate program to translate the next line of code into a machine readable format before executing it. Just like you don’t get a speed boost from executing all your cod in a virtual machine. Looking at you, Java.
    But you don’t use python for the compute-heavy tasks. You use it for the plumbing in between and outsource the computation to a native library with python bindings, like NumPy, Pandas, PyTorch, etc. Horses for courses.

  • FishFace@piefed.social
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    45 minutes ago

    It’s fast enough. People talking about modern CPUs have missed the point that python has been a staple language for gui and web apps for like 20 years.

  • Michal@programming.dev
    link
    fedilink
    arrow-up
    5
    ·
    3 hours ago

    By the time you finish your C script, compile it and run, Python developer will already have finished. Speed is relative.

  • hendrik@palaver.p3x.de
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    4 hours ago

    What’s the point of anything? I have all these Electron apps on my devices which require Gigabytes of memory, Discord took a substantial amount of RAM my old laptop had. There’s Android apps which are hundreds and hundreds of megabytes and all they do is call some REST APIs. Lemmy’s protocol is terribly inefficient. And back in the day in the 90s an entire office suite fit on a bunch of floppy disks. And a 0.025 GHz CPU was all it took to run it… The internet was so much more efficient, you do your online banking, chat, read the news (without a lot of images) with 0.1% of today’s internet connections.

  • LurkingLuddite@piefed.social
    link
    fedilink
    English
    arrow-up
    9
    ·
    edit-2
    7 hours ago

    When used for much of the fancier stuff, like AI, it’s not running in python. Python is just setting up all the other stuff and making the calls to shove the models onto the GPU and configure and blah blah… You’re just writing the program that uses the ML libraries that make other types of programming do the real work, like CUDA or the other one I forgot the name of, or even Vulkan, or what have you.

    So while Python is slow, things written in it do not have to be slow.

    Similar to Godot’s language. It’s terribly inefficient, but it’s meant mostly to respond to human time scale events, not to have complex computation-heavy systems written up in it. And similar to Python with AI tools and whatnot, Godot’s graphics side is still running hot and fast in the GPU with dx/vulcan even while the language the UI and game logic is written in is inefficient.

    • CarlLandry357@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      5 hours ago

      “Similar to Godot’s language. It’s terribly inefficient”

      Don’t know what you mean, but Godot app is only around 3mb, and it’s not as bloated as Python, though it has some high level layers or somthing too, and not as direct as C++.

      • insomniac_lemon@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        4 hours ago

        They mean scripting, GDscript is also interpreted (and probably also not often parallelized) so it’s also not blazing fast (though I guess typing helps).

        Though Godot has many options for languages (including bindings), so compiled is an option (you don’t have to go all in on one language either, so something like a generator or multiplayer code etc needing more performance can use a more capable language).

  • terabyterex@lemmy.world
    link
    fedilink
    arrow-up
    21
    ·
    9 hours ago

    define slow.

    my life has been in C style languages but even i kniw python us a great general purpose language. are you going to use it for high frequency trading? no but most things dont need that speed.

    yes its used a lot in ai but also for a ton of linuc scripting. i dont think anyone uses perl anymore.

    so in what way was it slow when you used it? what micro seconds were you lookong for?

    • ryokimball@infosec.pub
      link
      fedilink
      arrow-up
      3
      ·
      9 hours ago

      I started off with programming languages that compiled into binaries. I knew dos and bash well enough but wanted the convenience of scripting, just type in run, no compiling needed. I also wanted it to be cross-platform.

      I chose Perl. TBH I loved it, but I kept hearing about all the cool things that would come as soon as Perl 6 was released, so I started waiting, and waiting, and waiting…

      The XKCD comic, import antigravity, is literally what convinced me to try python finally. Haven’t really looked back, even 13 years later when Perl 6 was finally released

    • atzanteol@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      7 hours ago

      Python is slow enough to notice in fairly normal usage. Just doing lookups into a dict with thousands of entries, for example, will lead you to researching how to sort and index it.

      Python’s great as an interface to C which gives it the illusion of performing well.

      • FishFace@piefed.social
        link
        fedilink
        English
        arrow-up
        2
        ·
        47 minutes ago

        Yeah, want to take a bet on how long a single lookup in a dict with 5,000 entries takes on my machine?

        How to sort and index it

        It’s a hash table. Can you explain why “sorting and indexing” would improve performance?

        You’re talking out your arse.

    • insomniac_lemon@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      8 hours ago

      This probably depends on what CPU someone has, someone with a higher-end CPU (higher-IPC/higher clockspeed) probably will have a better experience.

      On older/lower-end CPUs it is more common to see when something is single-threaded especially when it’s also interpreted. Particularly any type of generator/loader, filter, renderer, live audio. Which to be clear, is from a user perspective.

      • CarlLandry357@lemmy.worldOP
        link
        fedilink
        arrow-up
        1
        ·
        7 hours ago

        I think with newer CPUs Python’s current speed will be less of a problem but if your intention is game dev I think this is not enough.

    • CarlLandry357@lemmy.worldOP
      link
      fedilink
      arrow-up
      2
      arrow-down
      2
      ·
      8 hours ago

      I wrote a console tictactoe game with primitive AI opponent using both Python and C++ and python takes more time in the background process before making a move than in C++.

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        7 hours ago

        Yeah, computationally intensive stuff is going to be slow when implemented in Python. You will find lots of data science libraries for Python that do computationally intensive stuff, but they’re then generally implemented in C/C++ or Rust, with only a thin API layer written in Python.

  • driving_crooner@lemmy.eco.br
    link
    fedilink
    arrow-up
    10
    arrow-down
    1
    ·
    9 hours ago

    I bought my house migrating days long Excel processes into minutes python script. They could be seconds C++ programs? For sure. But they would be unmaintainable and would take way too much time to write.

  • rumschlumpel@feddit.org
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    9 hours ago

    Depending on the project, development speed is often critical. Lots of data science stuff is really ad hoc and doesn’t get reused much, just some math, biology etc. graduates doing number crunching on specific datasets. Sure the script might take a day to execute, but if it’s only actually getting used a single or double digit number of times, it doesn’t make sense to break out more low level languages.

    With commercial projects, it’s often an issue of whether the higher hardware requirements of a project done in a scripting language are offset by the longer development time and higher wages for sufficiently competent programmers to do it in more low-level languages. This does have environment implications, but commercial projects don’t typically give a damn about socialized costs (despite the lip service that many had adopted for a while).

    AI seems mental, though, unless Python is just some glue for calling functions or libraries that are implemented in lower-level languages, which is definitely also a thing.

    • tal@lemmy.today
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      8 hours ago

      AI seems mental, though, unless Python is just some glue for calling functions or libraries that are implemented in lower-level languages, which is definitely also a thing.

      Most of the work is done by parallel compute hardware on most systems, not the CPU running Python.

    • CarlLandry357@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      8 hours ago

      As a beginner, these AI frameworks are written and C++ and you can do it there, but nobody does it and all the books out there or video courses are specifically for Python.

  • FiniteBanjo@feddit.online
    link
    fedilink
    English
    arrow-up
    5
    ·
    9 hours ago

    The NSA has a Github page and I was really surprised to see they use a heck of a lot of Python. This was before the Trump admin.

  • arthropod_shift@programming.dev
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    9 hours ago

    Slow depends on the use case. If your main bottlenecks are in code that people have written highly optimized lower-level libraries for, it could be slower to roll your own implementation or use a less mature library in a different language. And in some cases it might not matter if you take 1 ms or 100 ms to do something.

    It works the other way too, and you have to weigh the pros and cons of your specific case when you choose a language. What level of abstraction do you want to work at, how stable do you need the toolchain to be, how familiar you are with the language, what’s supported in the language, how easy is it to do what you want, what’s the norm in the domain you’re working in, etc.