Live data from Hacker News

Open-sourcing MonkeyType – Let your Python code type-hint itself

engineering.instagram.com

201–210 of 237 posts

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#201

Earlier quoted context omitted.

C++ makes this possible via templates. Generally the size is moved to a template argument, which allows the compiler to check this at compile time (of course, this restricts you to statically sized matrices).

Good to know. I was apparently unaware how powerful templates were.

Don't feel too bad, almost everyone is. And almost all of the people who are aware of how "powerful" they are tend to equate "hellish complexity" with "expressive power" and are not people you want to work with.

There are a few shining exceptions, but not many.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#202
post #170

Earlier quoted context omitted.

Ok, then the business men among us should learn their lesson, that agility matters. The software developers among us should also learn their lesson: don't build large-scale software in dynamic programming languages unless you can afford to spend time later adding a static type system on top.

I'd think the business men at Instagram have been very happy with the agility of development, that got them to a $2.8 billion revenue p/a company. More than enough to cover the engineering effort to help improve the maintainability of the code.

Considering the company that bought them runs on PHP, perhaps we should all ditch Python altogether.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#203
> With MonkeyType’s help, we’ve already annotated over a third of the functions in our codebase, and we’re already seeing type-checking catch many bugs that would have otherwise likely shipped to production

Are most of their code not yet in production ? Or why do they produce more bugs now with static types, then before with dynamic types !? This sounds a lot like homeopathy, that can both detect and cure diseases with placebo.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#204
post #168

Earlier quoted context omitted.

Most people would expect software to crash, hang, be slow or somehow leak their personal information. That's normal behaviour for the products of the software industry. For a long time there have been efforts to ensure at least a degree of quality and robustness through processes, practices and verification tools. One such tool is a type system which allows encoding requirements and expectations that will be automati…

> This tool is the proof that Python has significant problems at scale, which is something the Python community has denied for a long time. They're still doing it in this thread, but the lesson looks pretty clear to me: if you plan on building large scale, don't use Python. Or PHP while we're at it (see Facebook). Yeah, absolutely, don't do this! These are two examples of successful companies that did it and look at…

How do you identify the inflection point and then execute when it hits? There are conservative choices that would scale all the way through, but many startups would avoid them due to the hit on "velocity" (which is itself a very fuzzy topic.)

It seems that this same pattern plays out with many tools, and not just languages. When you've built something and you now have a team, processes, etc. built up it becomes difficult to see the forest for the trees, or to make the hard decisions because it might involve replacing people.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#205
post #168

Earlier quoted context omitted.

Most people would expect software to crash, hang, be slow or somehow leak their personal information. That's normal behaviour for the products of the software industry. For a long time there have been efforts to ensure at least a degree of quality and robustness through processes, practices and verification tools. One such tool is a type system which allows encoding requirements and expectations that will be automati…

> This tool is the proof that Python has significant problems at scale, which is something the Python community has denied for a long time. They're still doing it in this thread, but the lesson looks pretty clear to me: if you plan on building large scale, don't use Python. Or PHP while we're at it (see Facebook). Yeah, absolutely, don't do this! These are two examples of successful companies that did it and look at…

HN has a favorite pastime: dismissing tech that has demonstrated incredible utility because it’s lacks some kind of ideological purity they demand.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#206
post #171
post #169

Earlier quoted context omitted.

> This tool is the proof that Python has significant problems at scale... This does not prove your point. Annotating a large dynamically-typed codebase with type information is a large amount of work, regardless of the language. This tool makes that easier.

I'm bemused by your reply and curious to know why you think Dropbox and Instagram are working on static type analysers for their large Python code bases. Instagram at least gave us a hint: "we’re keen to make our code easier for new developers to read and understand, as well as more amenable to static analysis that shrinks the domain of possible bugs". It seems to me it's so difficult to manage such a code base, that…

Yes it does and it doesn't matter, because an argument can be made that there wouldn't be a Dropbox or an Instagram if they started out in a statically typed language back then.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#207
post #80
post #58

Earlier quoted context omitted.

We're getting into a world where languages finally have type systems that dont suck for fast development. This wasn't the case until very recently. And many of the current options only became realistically viable in the last few years (or months!). We still have to work with the world as it exists. Not as it should be or will be. And even with the crop of modern languages, its often still faster to start with less op…

What are you talking about? Haskell is 30 years old.

Yeah. And you need 20 language extensions to sit at the top of your every file to do anything useful with it.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#208

Earlier quoted context omitted.

I literally just had this exact thought independently of you. I mean if you need to do something like this, doesn't that mean you should be writing code in a statically typed language?

There's still a good deal of people who think of static typing as 'limiting', and dynamic typic as 'human'. Matsumoto said as much during (iirc) last years Ruby conf. I think the reverse is true. Static typing is liberating for humans because it tames complexity. Because I'm not a machine I cannot possibly keep track of fuzzy programs that arise from dynamic typing.

> Static typing is liberating for humans because it tames complexity.

It doesn't, though. Not with the currently existing type systems and implementations.

- Without type inference you end up righting multi-tier type declarations everywhere.

- With overly powerful type systems you need something close to a PhD in math to create proper types and then figure them out half a year later when you've already forgotten most of what you did

- Union and intersection types which are extremely valuable are missing from a lot of statically typed languages

And because I'm not a machine I often cannot figure out what a yet another two-hundred multiline error message wants of me. Often I'm happy to just throw an `if (x && x.field){}` and be done with it.

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#209
This looks wonderful :) I'd love to try it out at some point.

One thing that I think could really improve the documentation is a few examples! One of my favorite things about the Python docs and the community is the wealth of examples. From looking at the docs, I couldn't find the main thing I wanted to see - what would MoneyType's annotations look like if I used it?

Re: Open-sourcing MonkeyType – Let your Python code type-hint itself

#210

Earlier quoted context omitted.

C++ makes this possible via templates. Generally the size is moved to a template argument, which allows the compiler to check this at compile time (of course, this restricts you to statically sized matrices).

Good to know. I was apparently unaware how powerful templates were.

https://stackoverflow.com/a/22645853
Post reply on HN