News for hackers. Stuff that matters.
Re:The Ergonomics of Type Checking (2016) by tedmiston on Saturday October 28, 2017 @06:11PM (#15576935)
> I often wish I worked in a language where I could start dynamic and end statically... I can imagine writing the core of an algorithm and then gradually tightening the conditions as it comes into focus. More than a tool, this would be a practice: progressive type elaboration.

Bingo. I love this idea. I haven't tried it yet myself, but I think mypy [1] from Dropbox makes this a reality today in the Python world.

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

Re:The Ergonomics of Type Checking (2016) by ACow_Adonis on Saturday October 28, 2017 @07:15PM (#15577182)
I believe it's called Common Lisp, specifically SBCL :)

Live the dream :P

Re:The Ergonomics of Type Checking (2016) by sitkack on Saturday October 28, 2017 @11:32PM (#15577847)
Came here to mention MyPy and optional typing, the preferable term Gradual Typing means something distinctly different.

http://mypy-lang.org/about.html

Dropbox employs the creator of MyPy but it isn't a creation of dropbox.

Type Systems as Macros http://www.ccs.neu.edu/home/stchang/pubs/ckg-popl2017.pdf

Pluggable Type Systems http://bracha.org/pluggableTypesPosition.pdf

Propositions as Types http://homepages.inf.ed.ac.uk/wadler/papers/propositions-as-...

https://www.youtube.com/watch?v=IOiZatlZtGU

Re:The Ergonomics of Type Checking (2016) by tedmiston on Sunday October 29, 2017 @09:57AM (#15579312)
> Came here to mention MyPy and optional typing, the preferable term Gradual Typing means something distinctly different.

Are you sure that gradual typing is different than what Mypy supports?

The Wikipedia page for gradual typing cites mypy as an example.

https://en.wikipedia.org/wiki/Gradual_typing

The Mypy docstrings specifically state:

> Mypy has a powerful type system with features such as type inference, gradual typing, generics and union types.

https://github.com/python/mypy/blob/272d0c4c50918a36b57e7c0c...

The section on gradual typing in PEP 483 seems consistent with this as well.

https://www.python.org/dev/peps/pep-0483/#summary-of-gradual...

Re:The Ergonomics of Type Checking (2016) by sitkack on Sunday October 29, 2017 @04:19PM (#15581187)
Do they really insert extra dynamic checks?

Is Sound Gradual Typing Dead? https://news.ycombinator.com/item?id=11041272

http://prl.ccs.neu.edu/gtp/research.html

It was my understanding that MyPy was purely compile time with no runtime checks. But I could be wrong. Gradual Typing as implemented in the original paper would lead to much much slower code. The weight of a static language bolted onto a dynamic runtime for the worst of both possible worlds. Sufficiently abstract Python code is almost un-typable.

I think eventually we will get there, where one can explore a program in a dynamic language and ship a correctly statically typed one. Types are only the beginning.

Re:The Ergonomics of Type Checking (2016) by tedmiston on Sunday October 29, 2017 @05:21PM (#15581470)
I believe you're right that Mypy only offers compile time type checking, but not runtime.

It looks like there are some active projects for runtime type checking in Python and while I don't believe Mypy is related to any of them, enforce [1] looks to also use the same standard type hinting syntax from PEP 484.

[1]: https://github.com/RussBaz/enforce

Re:The Ergonomics of Type Checking (2016) by mercer on Sunday October 29, 2017 @08:43AM (#15579089)
General question for those more experienced than I am with statically typed languages: would Clojure's 'spec' or Elixir's 'dialyzer', or perhaps TypeScript, fit the bill? If not, what's the downside between these what appear to me 'gradually typed' languages/approaches?

To provide some context: my first experience with static (or rather explicit?) typing was TypeScript, and I really liked what I saw.

Re:The Ergonomics of Type Checking (2016) by newen on Sunday October 29, 2017 @02:34AM (#15578219)
That's how I write in Julia. Start with an algorithm with no types and eventually introduce type contraints everywhere, and even adding new types.
Re:The Ergonomics of Type Checking (2016) by tylerjwilk00 on Saturday October 28, 2017 @06:33PM (#15577022)
I know it's not a favorite lang around here but this is exactly what modern php is.
Re:The Ergonomics of Type Checking (2016) by kod on Saturday October 28, 2017 @11:48PM (#15577877)
How exactly does modern php (not Hack or another vm) let you "start dynamic and end statically"?

declare(strict_types=1);

is checking and throwing type errors at runtime, not compile time.