News for hackers. Stuff that matters.
Re:Measuring Polymorphism in Python Programs [pdf] by btilly on Tuesday June 14, 2016 @03:45PM (#11904759)
The article's spin is that since so little of the program uses complex features, we don't really need those features in our language. However this conclusion is not justified. The right question is how much more work it would take to write the program without those features.

The real use of this kind of work is studying how to best optimize dynamic programs. The conclusion is that a Python JIT optimizer can assume the first data type you see is likely to be what you'll always see, add a small sanity check for that case then goes down a fast path. This will correctly optimize 98% of the code. And there is nothing good to be done with the remaining 2%.

This is a concrete data point. JIT optimizers for other dynamic languages (particularly JavaScript) have discovered and taken advantage of similar things.

Re:Measuring Polymorphism in Python Programs [pdf] by LyndsySimon on Tuesday June 14, 2016 @04:51PM (#11905220)
I agree.

If I understand the article, a similar assertion would be: "Because multiple inheritance is used so infrequently, the onus is on the designers to show that the complexity is worthwhile"

That's obviously not true, though - these things add complexity to a codebase and are best avoided until the benefits they provide outweigh the increased cognitive load necessary to deal with them when something breaks.

I would intuit that if the more complex features of a language get very little use, then that's the sign of a more mature and thoughtful developer community that emphasizes readability and simplicity.

Re:Measuring Polymorphism in Python Programs [pdf] by brianwawok on Tuesday June 14, 2016 @03:53PM (#11904822)
Or maybe not.. what about mypy?

http://mypy-lang.org/

If 98% of the code has very basic types (i.e. function takes a Integer and returns a Decimal)... we could encode that in type hints with something like mypy, and get many of the type checking that statically typed languages get, without a crazy type system.

Hey I will take a 98% statically type checked language over 0%... if in so many cases I clearly know the types of stuff, let's put that info in there and detect and code time. So much of the standard library could use this to be cleaner.

Re:Measuring Polymorphism in Python Programs [pdf] by btilly on Tuesday June 14, 2016 @04:06PM (#11904926)
That would be an interesting tool.

Run a program while it is instrumented. The tool figures out what every type seems to be. Then goes back through the program and tries to prove that those types are correct.

It could then automatically annotate large chunks of code in a way that lets them run faster and will produce a warning if an unexpected type makes its way in in a future iteration. (An unexpected type, of course, being either a bug or a likely candidate for something that might expose latent bugs.)

Re:Measuring Polymorphism in Python Programs [pdf] by scott_s on Tuesday June 14, 2016 @04:58PM (#11905253)
I think you will be interested in this submission from a few months ago: Just-In-Time Static Type Checking for Dynamic Languages, https://news.ycombinator.com/item?id=11528375
Re:Measuring Polymorphism in Python Programs [pdf] by jerf on Tuesday June 14, 2016 @04:15PM (#11904985)
That's basically how most JIT compilers work. But it would be nice to be able to get the annotations back out of the JIT. Anyone know of a JIT that lets you do that? (In any language, since now I'm just academically interested.) It that would be darned useful when one "inherits" a large, dynamically-typed code base... it would greatly increase freedom to refactor if you were more sure that such and such a function really does only ever get a number, despite all the code you see for handling objects and strings, for instance.
Re:Measuring Polymorphism in Python Programs [pdf] by webwarrior on Tuesday June 14, 2016 @05:32PM (#11905483)
In Pharo (modern Smalltalk implementation) you can get some info from VM and JIT.

Someone is already working on type inference using VM caches.

See http://forum.world.st/parameters-of-the-virtual-machine-td48...

Re:Measuring Polymorphism in Python Programs [pdf] by brianwawok on Tuesday June 14, 2016 @04:50PM (#11905211)
Re:Measuring Polymorphism in Python Programs [pdf] by trentnelson on Tuesday June 14, 2016 @11:29PM (#11907028)
That's pretty close to what I'm currently playing around with.