Live data from Hacker News

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

engineering.instagram.com

11–20 of 237 posts

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

#12

This sounds similar to Dropbox's PyAnnotate -- Guido van Rossum writes about it here: http://mypy-lang.blogspot.co.uk/2017/11/dropbox-releases-pya... Would be interesting to see how MonkeyType and PyAnnotate compare.

I'd also like to hear more about this -- both the feature set and the development process. It's interesting that two large engineering organizations responsible for some of the most popular applications on the planet spent hundreds of engineering hours building almost the same exact tool at around the exact same time.

I'd also like to know how much quicker or better it could have been completed if it had been done out in the open.

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

#13
Reading this as someone who writes mostly in statically typed languages, the whole exercise seems odd.

Having so much dynamically typed code to maintain that you need to run production code using a separate tool just to figure out the types sounds just wrong. Why not use a statically typed language for such a large code-base? Is this done by purpose, or did they end up with a million lines of Python code and are looking for ways to make the maintenance easier?

And before I get down-voted to hell - I completely understand using Python for many things. It a good technical choice for many different problems, but navigating a million lines of Python seems just daunting to me (although maybe I'm just not experienced enough with Python).

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

#14

Reading this as someone who writes mostly in statically typed languages, the whole exercise seems odd. Having so much dynamically typed code to maintain that you need to run production code using a separate tool just to figure out the types sounds just wrong. Why not use a statically typed language for such a large code-base? Is this done by purpose, or did they end up with a million lines of Python code and are look…

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?

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

#15
post #10

Yet another hacky solution to address one of the biggest Python’s flaws. Why not switch to Java instead?

Because the product would never have been released given the same constraints on developer time x count x qualifications

Maybe for the good of us all, maybe in that case they SHOULD have used Java ;)

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

#16

Reading this as someone who writes mostly in statically typed languages, the whole exercise seems odd. Having so much dynamically typed code to maintain that you need to run production code using a separate tool just to figure out the types sounds just wrong. Why not use a statically typed language for such a large code-base? Is this done by purpose, or did they end up with a million lines of Python code and are look…

It's rarely easy to re-implement large or complex codebases in a new language. That kind of major effort requires significant signoffs from leadership and a large effort.

This tool? This tool takes an existing set of codebases and makes them safer. No major boiling of oceans required.

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

#17

Yet another hacky solution to address one of the biggest Python’s flaws. Why not switch to Java instead?

I was going to address the "why" by explaining actually why (Refactoring time required, impact difference, other negative tradeoffs, active devs on the projects / hiring requirements, benefit to the global python community, ...).

But it looks like this is a troll account, so flag & move on.

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

#18
Its interesting, this is a similar learning Clojure came around with, that the types weren't really useful unless everything is typed. Though Typed Racket's solution was to promote types to runtime validation at those borders between things with types and things without.

I do find it intriguing though, that adding back types manually is so hard and slow. Is it slower when done retroactively? Or is it just as slow when done at the same time, but we don't realize its overhead?

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

#19
post #9

Earlier quoted context omitted.

If lots of successful projects use what you consider the “worst” technology, perhaps the problem is with your perception rather than the technology?

Those people believe that the right choice is assembly unless you can write directly in hex /s

Nonsense. Octal, not hex.

(Not totally a joke. My mother wrote in octal before she got an assembler.)

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

#20

Reading this as someone who writes mostly in statically typed languages, the whole exercise seems odd. Having so much dynamically typed code to maintain that you need to run production code using a separate tool just to figure out the types sounds just wrong. Why not use a statically typed language for such a large code-base? Is this done by purpose, or did they end up with a million lines of Python code and are look…

Didn't Facebook do this for PHP (Hack) and Microsoft with JavaScript (TypeScript)?

From a technical aspect, I do find these projects cool. I wonder if its more efficient for large companies to initially develop using dynamic languages then transition them with these optionally typed languages.

Post reply on HN