also I just realized that Brazil did NOT make a programming language entirely in Spanish and call it "Si" and that my professor was making a joke about C... god damn it

this post is probably too nieche but I feel like Lemmy is nerdy enough that enough people will get it lol

you are viewing a single comment's thread
view the rest of the comments
[–] 14 points 1 year ago (12 children)

Why would you hate on it? It has its usecases. You won't build an OS in Python, but I'd much rather do data processing in Python than in C

  • source
  • parent
  • hideshow 12 child comments
  • [–] 4 points 1 year ago (5 children)

    Maybe I’ll build an OS in Python just for the fun of it! Haha

  • source
  • parent
  • hideshow 5 child comments
  • [–] 2 points 1 year ago (4 children)

    You just cannot do it, I'm afraid. Python is an interpreted language, and requires de CPython library to be translated into machine code so that it can then be run, but that requires an underlying OS that makes the calls. The closest thing would be micropython, which can be run inside the Linux kernel, but that's about it. The only thing I can think of is using a custom compiler that would generate either C/C++ or assembly code from a Python script, and then compile it using a standard C/C++/assembly compiler.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 1 year ago (5 children)

    I hate on it mainly for its lack of static typing.
    I tried building a HomeAssistant add-on in python, and it was not a good experience. Idk what IDE python devs usually use but VSCode did not provide much assistance.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 4 points 1 year ago (3 children)

    You can in fact statically type in Python. For example, defining variables:

    six: int = 6
    hello_world: str = "Hello World!"
    

    Or defining functions:

    def foo(x: int) -> int:
        return x**2
    

    If you only want to use static Python, you can use the mypy static checker:

    # Install mypy if you don’t have it
    pip install mypy
    
    # Run the checker on the file (e.g., example.py)
    mypy example.py
    
  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 year ago

    What you're describing is type hints, it's syntactic sugar and not used at all by the interpreter.

    For example, this is a "legal" statement:

    foo: int = "bar"

    Your IDE and linter will complain, but the interpreter just chops the hints off when compiling, and it's left with foo = "bar"

  • source
  • parent
  • [–] 1 point 1 year ago (1 child)

    I was using that syntax, but nothing seemed to be checking it. Running an external app to get static checking done isn't great, presumably there are extensions for common IDEs?

    But the poor vscode developer experience went beyond that. I attribute it to dynamic typing because most of my frustration was with the IDE's inability to tell me the type of a given variable, and what functions/properties were accessable on it.

    I hope it'd be better on an IDE made specifically for python, although idk how many extensions I'd have to give up for it, and things like devcontainers.

  • source
  • parent
  • hideshow 1 child comment