Python's type system explained: Static vs dynamic typing | Guido van Rossum and Lex Fridman

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 67

  • @LexClips
    @LexClips  2 года назад

    Full podcast episode: ruclips.net/video/-DVyjdw4t9I/видео.html
    Lex Fridman podcast channel: ruclips.net/user/lexfridman
    Guest bio: Guido van Rossum is the creator of Python programming language.

  • @avasam06
    @avasam06 Год назад +10

    My go tos are:
    - Mypy/pyright for static type checking
    - Pydantic for dynamic type validation
    - mypyc for compilation optimization using type hints

    • @bartalor
      @bartalor 9 месяцев назад

      also typeguard for validation of non pydantic.BaseModel entities

  • @bunpasi
    @bunpasi 2 года назад +42

    I come from C++ as well and have to say that the type hinting is a big help. Writing the code base I'm making right now would've been a nightmare without it.

    • @misterwafflezzz
      @misterwafflezzz 2 года назад +12

      IDE suggestions also improve greatly when you define parameters types of a function

    • @bunpasi
      @bunpasi 2 года назад +5

      @@misterwafflezzz Indeed. I'll never write a library without them anymore.

    • @AlexRodriguez-gb9ez
      @AlexRodriguez-gb9ez Год назад +1

      You could also sometimes develop your application while its still running (like have a part of your program run in the Jupyter lab reactive notebooks).

    • @ansismaleckis1296
      @ansismaleckis1296 Год назад

      or you could just stick with cpp😂

    • @bunpasi
      @bunpasi Год назад +1

      @@ansismaleckis1296 If I could, I would 😅

  • @andreipiv
    @andreipiv 2 года назад +41

    There's cases where dynamic typing is more advantageous - certain applications, or just something simple to bang out.
    In any real sizable codebase, the dynamic typing of a whole language is a huge drawback and developers spend tonnes of time dealing with it, unless it's specific to that implementation (meta programming)

    • @spaceowl5957
      @spaceowl5957 2 года назад

      ObjC has pretty dynamic typing and it works great for large codebases

    • @AlexRodriguez-gb9ez
      @AlexRodriguez-gb9ez Год назад

      Yeah, developing apps while they are still running could help with many types of errors and working with APIs, another thing is keyword arguments. Static analysis like type inference and dynamic analysis could also help with code discovery.

  • @xinaesthetic
    @xinaesthetic Год назад +8

    Pyrite is often referred to as “fool’s gold”, and I sense a slightly self-deprecating or ironic aspect in the choice to reference it. So I reckon there’s an extra level of wordplay going on in the naming of Pyright that acknowledges it’ll never perfectly allow you to have both total flexibility and correctness.

    • @OneDivineShot
      @OneDivineShot Год назад

      This is a very interesting statement and thank you for sharing.

    • @xinaesthetic
      @xinaesthetic Год назад

      @@OneDivineShot the insight comes somewhat second hand from one of my university lecturers years ago, referring to another project of a similar name. In that case, it was to do with embedding code (SuperCollider IIRC) in a visual dataflow environment (Max/MSP).

  • @rustamazimov8497
    @rustamazimov8497 2 года назад +34

    Lex Freeman look like and act like T-1000 Terminator Robot.

    • @floooobzdagget3734
      @floooobzdagget3734 2 года назад +12

      This sentence looks like it was typed by a T-1000 Terminator Robot.

    • @nishchaychauhan8814
      @nishchaychauhan8814 Год назад +1

      Seriously. He sounds so sedated almost programmed like a robot!

  • @echobucket
    @echobucket 2 года назад +5

    I just wish we didn't have TWO tools.. there's both mypy and pyright/pylance... and the errors you get from each one can be different.

    • @avasam06
      @avasam06 Год назад +1

      I'm really glad we do. Because they've both been elevating each other a lot.

  • @john.dvollins6284
    @john.dvollins6284 2 года назад +9

    Thank you so very much LEX😎🙏⭐

  • @TheMcl0ud
    @TheMcl0ud 2 года назад +9

    Pydantic - a great package using annotations

    • @dingding4898
      @dingding4898 Год назад

      It uses annotation to check it's variable types as well?

    • @biskitpagla
      @biskitpagla Год назад

      @@dingding4898 Yup. You can use Pydantic for all kinds of validation. But it's nothing like a real type system if that's what you're looking for.

    • @tranthanhbao9978
      @tranthanhbao9978 Год назад

      @@dingding4898 not really ! Pydantic is more about parsing than validating , and parsing is alway better.

  • @KoRNeRd
    @KoRNeRd Год назад +2

    Why are they not discussing cython?

  • @indibarsarkar3936
    @indibarsarkar3936 Год назад

    But fixing the max size of the variable using some extra syntax for writing some programmes might help. The interpreter would know the size of the variable thus it could be performing special optimizations accordingly.

  • @hung-tienhuang3640
    @hung-tienhuang3640 2 года назад +3

    I only switched to python until I figure out there is type hint. During pre type hint era, I would literally be ap frustrated whenever I see type error. I would just think fuck me, I have been coding cpp for so long and you're telling me I don't know the basic about data type!?

  • @echoexplore4190
    @echoexplore4190 2 дня назад

    mypy for typechecking, pyright for lsp

  • @runners4tme
    @runners4tme Год назад +1

    Pydantic can do it if I am not mistaken

  • @laughingvampire7555
    @laughingvampire7555 Год назад

    less than & greater than are not angular brackets

  • @echobucket
    @echobucket 2 года назад +4

    Python compiles itself into python byte code.. so we could totally have the python "interpreter" check our types at compile time and not suffer a performance penalty....

  • @khbhibjhbl
    @khbhibjhbl 2 года назад +5

    The linguistic of a processor has come so far from the model of the analytical engine to the computer scientist that creating a way to change data within the computer rather than keeping the physical concept of the ENIAC alive. Ada Lovelace and Charles Babagge would be happy. Regardless, I am still learning but wouldn't the architect notify the team that is caparmentalized in th regard of the static checker or is the static checker a purchasable tool utilized for the testing. (Architecture) Prerequisites, requirements, construction, testing.

    • @Gruuvin1
      @Gruuvin1 2 года назад +4

      wut?

    • @ea_naseer
      @ea_naseer 2 года назад

      @@Gruuvin1 They're drunk

    • @SplitWasTaken
      @SplitWasTaken Год назад

      Are you right in the head?

    • @khbhibjhbl
      @khbhibjhbl Год назад

      @@SplitWasTaken what do you mean?

    • @khbhibjhbl
      @khbhibjhbl Год назад

      @@SplitWasTaken I'm still learning but a static checker is used for analyst of the program before compiling to alert developers in order to save time and money.

  • @dave_di
    @dave_di Год назад +21

    Only men of culture watch technical interviews with Guido van Rossum. The rest will watch Joe Rogan.

    • @emiliod90
      @emiliod90 Год назад +2

      😂😂❤

    • @bigpickles
      @bigpickles Год назад +14

      Nonsense. We watch both.

    • @BrandtHambrick
      @BrandtHambrick Год назад +4

      What's wrong with both?

    • @biskitpagla
      @biskitpagla Год назад

      This lack of overlap probably has more to do with being failed by the US's education policies than being men of culture or whatever that means.

    • @heroe1486
      @heroe1486 Год назад

      ​​@@biskitpagla There is probably a big overlap, don't think all devs only consume formal stuff, I even classify myself as one, using Arch, i3, being constantly in the terminal etc and don't mind watching some of his videos for fun, the guy also had multiple people considered as elite in their (non bs) field as guests

  • @shvsagar
    @shvsagar 2 года назад +2

    Love from Nepal

  • @tripletth
    @tripletth 2 года назад +12

    My disappointment was immeasurable when I found out that Python type hints are not actually enforced by the interpreter, and my day was ruined.

    • @echobucket
      @echobucket 2 года назад +2

      I know, I wish we at least had an option.. like `python --type-check` or something

    • @isodoubIet
      @isodoubIet 2 года назад +2

      That fact alone makes them worse than useless IMO.

    • @jjtt
      @jjtt 2 года назад +2

      @@isodoubIetit's not that bad, you just use a separate program to enforce them, python doesn't have a separate compilation step, so you'd be typechecking your whole program each time you run it

    • @fgaze1234
      @fgaze1234 Год назад

      @@isodoubIet Why?

    • @isodoubIet
      @isodoubIet Год назад +1

      @@fgaze1234 Because in that case they can lie. They're comments, for all intents and purposes, but unlike comments they _seem_ like they mean something and offer a kind of security that really does not exist.

  • @andrewburger8808
    @andrewburger8808 2 года назад +6

    Rust

  • @augusto256
    @augusto256 Год назад +1

    Strictly typed languages are only useful in data scheme based programs. That is, programs that somehow are compromised to real information and have to preserve it's integrity. In most cases, Strictly typed languages are not necessary since the data tends to be raw computational resources.