• Henson
    link
    fedilink
    arrow-up
    24
    arrow-down
    1
    ·
    12 hours ago

    I would add its a easy Scripting language. No compilation problem, richer that shell/bash makes it a powerfull choice.

    And a really dont like it.

    • flatbield@beehaw.org
      link
      fedilink
      English
      arrow-up
      6
      ·
      11 hours ago

      It is far more then that. It is a full up programming language.

      I never understand why people think compilation is a barrier. But sure most python is not compiled.

      • Frezik@lemmy.blahaj.zone
        link
        fedilink
        English
        arrow-up
        1
        ·
        6 hours ago

        Python is largely compiled. All the pieces of a compiler are built into how it processes things. Almost nothing works on an interpreter model anymore, where each line is parsed and executed before handling the next. Unix-style shell scripts are one of the very few exceptions. I believe JavaScript also starts being interpreted in the browser in order to start executing immediately, but then a compiled version is swapped into the runtime as soon as it’s ready.

        • flatbield@beehaw.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          6 hours ago

          Depends on what you mean by compiled. Python typically translates to meta code and that is interpreted. True compilation to binary runs about 100x faster. Python is slow though there are faster versions and ways around it.

          • Frezik@lemmy.blahaj.zone
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            5 hours ago

            I mean that there are successive steps to transform the entire code into tokens, the tokens into an AST, and the AST into some intermediary or final form.

            True compilation to binary runs about 100x faster.

            No, it doesn’t. Take a look at any of the number of projects that have attempted to compile Java to native code over the years. You’d be lucky to see any substantive gain at all. They sometimes have a use for packaging everything up in a single distributed binary, but you don’t do it for speed.

            Things like C and Rust are fast because the language semantics can be compiled in a fast way.

            • flatbield@beehaw.org
              link
              fedilink
              English
              arrow-up
              1
              ·
              edit-2
              5 hours ago

              We will have to disagree on that. This is all problem spectific, but I have found C code integrated via ctypes, cffi, or by a C extension is over 100x Python alone. Interestingly Python, Numba, and Numpy together which is a more pythonic solution can get to those speeds too.

              All of the other approaches I have tried are much slower: Nuitka, Cython, Numpy alone, PyPy, etc.

              To get best speeds one has to compile for your specific architecture and enable things like vectorization, auto parallel, and fast math. Most default builds including libraries do not do that.

              • Frezik@lemmy.blahaj.zone
                link
                fedilink
                English
                arrow-up
                1
                ·
                edit-2
                4 hours ago

                This is all problem spectific, but I have found C code integrated via ctypes, cffi, or by a C extension is over 100x Python alone. Interestingly Python, Numba, and Numpy together which is a more pythonic solution can get to those speeds too.

                Of course you did. Those are changing the semantics of the language. For example, things like Numpy store arrays more like how C does it than Python. That makes all the difference, not merely compiling to native code.

                • flatbield@beehaw.org
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  3 hours ago

                  You can get about 10x by compiling Python using PyPy. So compiling is not nothing. Using Numpy alone is about 5x which surprised me. There is a lot of missleading stuff out there about how to make Python fast. Lot of people say CPython is pretty fast or that using a binary library like numpy is fast. No CPython is very slow and libraries are not always that fast.

                  Edit: Another compiler is Numba which is more specialized. It can get 30x on some code without numpy. Again compiling can help.

      • Eager Eagle@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        11 hours ago

        If compilation takes more than a few single-digit seconds, IME, it breaks the development flow when you’re working on small fixes.

        • namingthingsiseasy@programming.devOP
          link
          fedilink
          arrow-up
          2
          ·
          11 hours ago

          Having worked on large C++ projects, the solution to this issue is using a good IDE with an LSP. But it is quite a regrettable situation because setting up an LSP can be a difficult, and they also tend to break quite easily. Understanding how to make an LSP work is an important productivity skill in those kinds of positions.

    • namingthingsiseasy@programming.devOP
      link
      fedilink
      arrow-up
      2
      ·
      11 hours ago

      Yeah, you can use it both for full applications (web or desktop) as well as simple scripts. The flow of getting from something simple to a full blown application is pretty smooth and natural - better than just starting out in Java or C++ and taking at least an hour before you get anything that runs.