Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really don't understand these lines of argument, because they seem to me to be almost entirely backwards.

> I find dynamic typing ... acts as a forcing function to writing simple code; simple to read and simple to comprehend.

I find the opposite true. Many super-dynamic patterns are hard to type correctly. Good type systems tend to encourage simpler patters so you get simpler types.

> The argument that it helps inexperienced developers approach the codebase is, IMO, a poor one as it tends to incentivize an iteration loop that lacks understanding and is simply trying to make all the red go away.

Making the red go away is important because the red indicates a problem! This is a lot easier than other ways of discovering the error. Why would you want to discover the error later?

> I also don't like autocomplete, so take that as you will.

This is why I'm with commenters who say they don't trust people who are against static typing... I'm extremely suspect of computer programmers who don't want computers to help them program.



> Making the red go away is important because the red indicates a problem! This is a lot easier than other ways of discovering the error. Why would you want to discover the error later?

I don't think that's what the parent to your comment is arguing. They are arguing that "making the red go away" isn't the goal, rather that correctness is, and that it's easy to conflate the too when you focus too much on the "red" part, and don't pay attention to the "correct" part.

Worded another way, the mantra of "if it compiles it works" can lead to a dangerous false sense of security if you don't understand the limitations of your type system and what parts of your program is may or may not cover completely.


> the mantra of "if it compiles it works"

Very few people have this mantra, much less without qualification. That's more of a ML or Haskell kind of point of view, and even then it's known to not be a guarantee. A type Int -> Int -> Int isn't going to enforce that you implement multiplication correctly, instead of add or just 0.

"I refactored, fixed type errors, and it just worked!" is a thing I see a lot, but from people who just experienced it, because it happens a lot. It's a good thing.


I have this all the time at work.

We have large python codebase, all sorts of linters and checks.

Still have developers do something like:

    # we have a list of things
    # but we only need one
    try:
        a_thing = things[0]
    except IndexError:
        pass
    assert isinstance(a_thing, Thing)
Sure maybe it's a junior thing. But it still happens, and the typing doesn't save us. I don't know how to tell juniors to stop doing this


While discussing code review, howabout shooting whoever wrote that comment.

Why is there an assert? Python case a cast function if you really wanted to force the typechecker to see a_thing as Thing but (and I'm sure this is the point you are making) you are likely hiding a prolem.


In code review, explain what can go wrong and offer suggestions for how to write it such that it doesn't have those problems?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: