‹ BackHN Continuity

Thread

Rusty thoughts on "Parse, don't validate"

95 points · 47 comments · ingve

  1. victorpudeyev · · focus · HN ↗
    ...I'm so happy that I write in untyped languages so I don't have to deal with any of this.
    1. pyrolistical · · focus · HN ↗
      But you kind of do.

      For a untype language like js array, since it can be empty, you have to either always check the length, the item returned, or have a precondition to know the array is not empty.

      All three of those cases is either code or context you’re holding in your head.

      All that stuff is equivalent to a type system

    2. well_ackshually · · focus · HN ↗
      Congratulations on having to implement your checks at runtime, but stupid, repetitive, boring work is kind of why we invented compilers.
    3. the__alchemist · · focus · HN ↗
      I lamented patterns of what I consider over-use of the type system in Rust (This applies to other languages as well). There is a balance: I prefer this over-use/strict use (e.g. implementing a custom non-empty Vec type) over not using typing at all, but a big margin!

      Balance in all things?

    4. evilduck · · focus · HN ↗
      You absolutely do have to deal with this in your untyped language otherwise you're just letting edge cases and runtime errors happen. The syntax will be different, it will have to happen at runtime instead of compile time, the chosen wording and language to represent the concepts and the work may even vary, but you are not exempt.
    5. bigstrat2003 · · focus · HN ↗
      Everyone has to deal with this. The only question is whether you deal with it in the type system, through lots of checks at runtime, or buggy behavior when the user encounters cases you didn't envision.
    6. abc42 · · focus · HN ↗
      Ignorance is bliss.
    7. bobbylarrybobby · · focus · HN ↗
      Someone has to deal with it, either you or the (strongly typed) language.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.