News for hackers. Stuff that matters.
Re:Why your F# evangelism isn't working by topkai22 on Wednesday May 31, 2023 @01:00AM (#36134635)
A major problem with doing data transformation in statically typed languages is that its easy to introduce issues during serialization and deserialization. If you have an object

  [{
    name:”ex obj”
    value:”a sample value”
    extraProperty:”I’m important”
  }]
And the code

  class myDTO{
    string name;
    string value;
  }

  var myObjs= DerserializeFromFile<myDTO>(filepath)
  SerializeToFile(myObjs, filePath2)
  
filepath2 would end up with without the extraProperty field.

You can also write code like

  function PrintFullname(person) {
    WriteLine(person.FirstName + “ “ + person.LastName)
  }
And it will just work so long as the object has those properties. In a statically typed language, you’d have to have a version for each object type or be sure to have a thoughtful common interface between them, which is hard.

All that bring said, I generally prefer type safe static languages because that type system has saved my bacon on numerous occasions (it’s great at telling me I just changed something I use elsewhere).

Re:Why your F# evangelism isn't working by epgui on Wednesday May 31, 2023 @01:34AM (#36134830)
I think whether your comment is essentially true or not depends on the language and technology.
Re:Why your F# evangelism isn't working by somenameforme on Wednesday May 31, 2023 @02:02AM (#36135023)
"Most" (I mean "all", but meh - I'm sure there's some obscure exception somewhere) parsers will have the ability to swap between a strict DTO interpretation of some data, and the raw underlying data which is generally going to be something like a map of maps that resolves to strings at the leaf nodes. Both have their uses. The same can also be done easily enough by hand as well, if necessary.
Re:Why your F# evangelism isn't working by pharmakom on Wednesday May 31, 2023 @03:18AM (#36135448)
No, it's not.

You can write code in a statically typed language that treats the data as strings. The domain modelling is optional, just choose a level that you need:

1. String 2. JSON 3. MyDTO

If you do choose 3, then you can avoid serde errors using property based testing

Re:Why your F# evangelism isn't working by FrustratedMonky on Wednesday May 31, 2023 @09:24AM (#36138094)
Even with a Dynamic Type, it becomes real static type at some point when running, so why wait for the crash to happen at runtime?