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

Definitely the latter. I've seen this discussion a few times before, and it's always the same. Your initial developers are not looking down the road to the million lines of code milestone, they're just trying to make a product that might actually make some money here and now.

I'm sure Instagram was exactly that. They needed to handle images and some guy knew how to do it in Python. They wrote Python code, and then people liked Instagram. They eventually became a billion dollar company with millions of lines of code and no where along the road was there time to say "hey we need to refactor this whole thing". Or if that was said, management laughed and said "we need this feature".

So here is where you end up. The developers need to clean things up but they don't have time to clean it up by using a language, realistically, they probably don't know as well as the Python they wrote the millions of lines of code in.

Re: your last comment, navigating a million lines of any codebase is daunting, and especially more so if you aren't a developer in that language. I'm not sure what exactly "Python" has to do with that, besides that you're not a Python dev.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by imiric on Thursday December 21, 2017 @05:54PM (#15983631)
To add to this, note that type hinting is quite a new feature in Python (introduced in v3.5, released in 2015), and this functionality simply wasn't available before. So any company heavily invested in Python today obviously wants to improve their runtime reliability, without having to rewrite parts of their stack.

Stricter typing goes a long way to achieve this, and gradual typing allows you to upgrade the code base at your own pace, which is great.

Consider this study[0] about TypeScript and Flow, which use the same approach for JavaScript, which found both able to detect ~15% of runtime bugs. So no wonder companies with large Python code bases would be the first to invest in this space.

Personally I feel this is a great addition to the language, and hope type checking becomes a first class citizen too, instead of being delegated to external tools like mypy[1] or pytype[2].

[0]: http://ttendency.cs.ucl.ac.uk/projects/type_study/

[1]: http://mypy-lang.org/

[2]: https://github.com/google/pytype

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by miohtama on Thursday December 21, 2017 @06:45PM (#15983966)
Dropbox is very heavily invested in Python. I am under impression they hired Guido van Rossum to do exactly this, among other things. First 100% statically type the old codebase, then port it to Python 3.

You can statically type Python 2 codebases, but the language does not offer native support for it. Thus, all needs to go to docstrings or comments.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by jw- on Thursday December 21, 2017 @07:11PM (#15984104)
I'd consider those languages optionally typed, rather than gradually typed, as they don't insert run-time type checks. Regardless, I still think it's all interesting and valuable work.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by forgotpassagan on Thursday December 21, 2017 @07:55PM (#15984387)
I can picture these poor souls vividly. Millions of lines of python, flowing like the mightiest of rivers. Nobody really knowing whence it cometh and goeth.

A hero arises, offering a sacred herb to calm the torrent and light the golden path. The hero is elevated, yet they continue to pray

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by btown on Thursday December 21, 2017 @08:57PM (#15984691)
They say there is a holy land called Haskell, but it is only revealed to the truest of believers without the weight of the chaotic-neutral entity “Shareholder” weighing ever so heavily on their shoulders. For those in Shareholder’s clutches, one must forgive their prayer. ‘Tis the best they can do.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by forgotpassagan on Thursday December 21, 2017 @09:01PM (#15984704)
There is something else, in the darkest reaches. It has many incantations, but the non-believers have a singular name. Lisp.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by arbie on Thursday December 21, 2017 @10:02PM (#15984938)
With it's comforting, reassuring warmth, Perl shines on as a luminous sun, lighting the way for youngling languages to learn from. Hushed whispers foretell the sunset, but none truly believe them...
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by vgy7ujm on Friday December 22, 2017 @04:12PM (#15990950)
Back to Perl folks.. The freedom, the happiness !!
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by jsjohnst on Friday December 22, 2017 @12:30AM (#15985463)
> forgotpassagan

They have password managers you know and also spell checkrs too. :P

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by tim333 on Thursday December 21, 2017 @09:39PM (#15984844)
Looking it up, it seems pretty much that:

Kevin Systrom " thought of combining location check-ins and popular social games. He made the prototype of what later became Burbn and pitched it to Baseline Ventures and Andreessen Horowitz at a party. He came up with the idea while on a vacation in Mexico when his girlfriend was unwilling to post her photos because they did not look good enough when taken by the iPhone 4 camera." (Wikipedia)

He used Django because I guess that was an easy way for one guy to do it fairly quickly. The app was Burbn which then pivoted into Instagram.

By the way I kind of surveyed the "what framework should I use" stuff on HN over the last year and Django still seems the most popular, probably followed by Rails and Phoenix.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by IshKebab on Thursday December 21, 2017 @06:22PM (#15983859)
Navigating a large code base that is dynamically typed like Python is far more tedious than something like C++ or C#.

First you can't read what the types passed into and out of functions are. You have to find their usages to work it out. Second, you can't reliable do things like "find usages" or "go to definition" because of the dynamic typing.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by andybak on Friday December 22, 2017 @03:03AM (#15985950)
> Second, you can't reliable do things like "find usages" or "go to definition" because of the dynamic typing.

In my experience PyCharm can do both correctly for the vast majority of cases.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by walrus1066 on Friday December 22, 2017 @05:00AM (#15986384)
Still very limited, for example, if I have:

def some_func(foo):

   foo.run()

   ...
Find usages in the run() method will return dozens of results, the IDE can't help you any more, to find what 'foo' is at runtime.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by andybak on Monday December 25, 2017 @04:05PM (#16005703)
Isn't that basically saying "it fails in the kind of cases that wouldn't even be possible in a statically typed language"?
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by lmm on Friday December 22, 2017 @05:51AM (#15986556)
Indeed; it only fails in the really fiddly cases where you need it the most.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by toast0 on Thursday December 21, 2017 @08:56PM (#15984690)
Most of the c++ and c# code I see lately has so many things declared as auto, it's hard for me to figure things out too.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by tigershark on Friday December 22, 2017 @12:21AM (#15985434)
Are you using notepad to write c#? If you hover on the var you will see the tooltip with the type.
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by toast0 on Friday December 22, 2017 @02:18AM (#15985800)
When I was writing c#, I did use visual studio, but since I'm used to developing in a terminal editor, all these tooltips and things are a little tricky -- sometimes they disappear, and then I can't get them back, etc.

But more often, when I'm looking at c# or c++, it's not code I wrote, it's not code I intend to change, it's code that's interacting with my code (written in another language) that I'm trying to see why it's misbehaving, so I can get the owner to fix it. I could be reading the code on GitHub or some other web view, I might have checked it out, but I have no interest in setting up a (probably new) IDE to look at it as the author would; I dig into too many projects to learn that many tools -- and deal with the upgrade cycle for them.

Sure, it would be useful to hover and get more information, but I'm used to loosely typed languages, so it's not awful. It's just jarring to see that the type information is apparently not important enough to write down the name in c++ or c# anymore.

Re:Open-sourcing MonkeyType – Let your Python code type-hint... by klipt on Thursday December 21, 2017 @10:06PM (#15984958)
Would be nice if IDEs had a key combo to fill in the actual type for "auto"s!
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by maxxxxx on Friday December 22, 2017 @01:05AM (#15985571)
That would be nice!
Re:Open-sourcing MonkeyType – Let your Python code type-hint... by rusk on Thursday December 21, 2017 @05:24PM (#15983402)
I'm not sure what exactly "Python" has to do with that

Well as he said, a statically typed language is better in that kind of situation because it enables a better class of tooling and the typing system enforces certain style constraints, that enables better quality of code analysis en mass.

Python specifically is very lightweight in this regards with little in the way of naming constraints (vs for instance Ruby having different formatting rules for different types)

So yeah, it’s not “just like any other language” - horses for courses