1. 17
  1.  

  2. 12

    If you want to check out a practical gradually-typed language, I’ve been using Typed Racket.

    It’s very convenient to use untyped code early-on when the design of the program is unclear(or when porting code from a different language), and to switch individual modules to typed code later to reduce bugs.

    1. 4

      Another great gradually typed language is Perl6. It has a Cool type, a value that is simultaneously a string and a number, which I think is pretty… cool!

      1. 1

        Basically how every string / number in perl5 work{s|ed}?

        1. 2

          Based on reading https://docs.perl6.org/type/Cool, kinda? Although it also looks to me as if this is at once broader than what Perl 5 does (e.g. 123.substr(1, 2), or how Array is also a Cool type) and also a bit more formal, typing-wise, since each of those invocations makes clear that it needs a Cool in its Numeric or String form, for example.

          1. 1

            That makes sense that it changed. perl5 is not so.. structured. But this stuff worked:

            "4" + "6.2"
            $q=42; print "foo$q"
            print "foo" + $q
            

            It makes things like numeric fields in HTML forms very easy (if $form["age"] <= 16), but the subtle bugs you get…

            Anyway. That was perl5. The perl6 solution seems to make things much more explicit.

      2. 4

        stanza is another interesting language that is designed from the start to be gradually typed.

        1. 2

          Typed Racket is indeed an awesome example. I believe TypeScript would also qualify very well here (as might Flow; I’m not as familiar with it). This also reminds me of Dylan of yore, too: https://en.wikipedia.org/wiki/Dylan_(programming_language)

          1. 1

            Is this the same thing? I had the same thought and I wasn’t sure if it was.

            1. 4

              Yes, Typed Racket is gradual typing, but for example, the current version of Typed Clojure is not. The premise is that gradual typing must support being used by dynamic typing, to simplify a little bit.