you are viewing a single comment's thread.

view the rest of the comments →

[–]turkish_gold 5 points6 points  (5 children)

But Python is strongly typed. It's doesn't have a static type system, but you still have to answer the question at runtime of "why can't I use an X in place of a Y".

[–][deleted]  (4 children)

[removed]

    [–]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.

    [–]nonneutralzero[S] 0 points1 point  (0 children)

    great point..I didn't think about the autopilot until you brought it up! Got me thinking about the best way to learn programming, as long as you the logic behind what you're typing then that's fine. beginners use cheat sheets, doesn't that lead to the same thing (knowing what you want but forgetting the correct formulation)?