News for hackers. Stuff that matters.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by vasilipupkin on Thursday December 21, 2017 @04:14PM (#15982820)
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... by Barrin92 on Thursday December 21, 2017 @04:20PM (#15982867)
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.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by dmitriid on Friday December 22, 2017 @11:23AM (#15988561)
> 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... by Barrin92 on Friday December 22, 2017 @03:40PM (#15990720)
you'll have to expand on this a little for me. I just recently looked at an older Haskell codebase I was working on two years ago, and simply because of a very few straight forward types, nothing special, I could really wrap my head around the code-base a lot easier. Not just because the code tells me in plain text what types occur where, but also because enforcing a strong type system encouraged compositionality and well-formed behaviour in the first place.

If I look at some of the python code I've written, I'll be perfectly honest I often cannot tell you what to make of it any more.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by dmitriid on Friday December 22, 2017 @05:56PM (#15991599)
Types being code depend on people writing them (as is the rest of the code :) ). I guess you’re lucky/smart that your code base is just simple types.

Quite often people construct complex type hierarchies just because they can (or don’t know better). And it’s a pain to wade through and coerce to what you want it to do.

I’m very much on the fence between static and dynamic typing, having used (and probably abused) both. I prefer a “pragmatically” typed language, but I haven’t come up with a proper definition for it yet :)

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by jw- on Thursday December 21, 2017 @07:43PM (#15984327)
I also get the impression that some people view using dynamically typed languages as a badge of honor, taking more expertise to harness the greater 'expressive' power, all whilst juggling the types in your head. Bad programmers can't use them properly, but if you're one of the good ones then you're not held back by rigid types.

I'm one of the dumb ones and just let the computer do the checking for me.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by vorotato on Thursday December 21, 2017 @04:23PM (#15982900)
Disclaimer, I'm a regular horn tooter for F# but imho this is such a perfect case for the language. It has similar line density to python, but with static type inference. Admittedly you will have to be explicit about using mutables, but I'm going to bet that instagram already cares about that.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by nerfhammer on Thursday December 21, 2017 @04:20PM (#15982866)
there's a difference between should be and should have been

maybe it's easier to do this half-measure than rewrite your entire code base

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by vasilipupkin on Thursday December 21, 2017 @04:22PM (#15982889)
I get that part, but for new projects, this perhaps is a hint to do things in Java?
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by newfoundglory on Thursday December 21, 2017 @04:24PM (#15982911)
80% of startups are going to die before their codebase reaches this size. They should probably not be making tech stack choices based on "what if we succeed beyond all likelihood".
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by vasilipupkin on Thursday December 21, 2017 @04:27PM (#15982934)
two things come to mind: maybe those startups would die at a slower rate if their code was comprehensible to begin with ? but leaving that aside, for companies where survival is not an issue then, doesn't this indicate that using a dynamically typed language is not great?
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by panopticon on Thursday December 21, 2017 @05:14PM (#15983336)
I would be interested in seeing the number of startups that fail due to technical debt. My instinct is that most startups fail for business reasons (no clear need, not enough/right sales, poor management, bad pitch, solving the wrong problem, etc).
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by depressedpanda on Thursday December 21, 2017 @07:37PM (#15984291)
Well, in the case of Instagram, this just shows that Python was a great choice.

They went with a dynamically typed language, were successful, the language they chose added an optional type hinting system, and they wrote a tool that would automatically type hint their code in order to reap many of the benefits of a static type system.

I think that the amount of man hours that went into writing the tool is negligible, so it's a net win for Instagram.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by lmm on Friday December 22, 2017 @06:04AM (#15986606)
New projects at large companies often are written in Java. New projects at startups aren't and shouldn't be - doubling future maintenance costs for the sake of a 20% reduction in development time now is a good trade, because 90% of startups fail, the important thing is to validate product/market fit as soon as possible.

(Though really you should just use Scala and get both Java-like safety and Python-like productivity)