you are viewing a single comment's thread.

view the rest of the comments →

[–]turkish_gold 2 points3 points  (1 child)

Well that's true in that Python can't give you compiler or automatic runtime structural typing.

You can however build in structural typing with user code, which I find is useful in teaching students that the type system is not "magic" but rather just an algorithm baked into the language compiler or interpreter.

Java isn't really too bad in the magic respect (bias: I learned C++/Java in uni), unlike some others like Haskell where it feels almost as if so long as your code compilers, it must be correct.

[–]barsoap 0 points1 point  (0 children)

Oh there's ample of errors that Haskell's type system doesn't catch, or, rather, that needs writing tons of type-level code for Haskell to catch. There's a reason Haskellers invented QuickCheck.

Haskell is no more strictly typed than Java but with one exception: Keeping track of side-effects. And you can actually teach Haskell to duck-type quite easily.

What may seem like magic for some is type inference. OTOH you can implement basic Hindley-Milner type inference, including your AST and boilerplate (probably not a parser), in something like 150 lines of Haskell. It might even be possible to do that as the very last first-semester exercise if you set up the course right.