News for hackers. Stuff that matters.
Re:A Plea for Lean Software (1995) [pdf] by yodsanklai on Wednesday August 05, 2020 @08:58AM (#24060286)
> How was this tested? Was there a control group?

I agree this deserves some study. But...

> when you have to do something you don't have yet any clue about the type system is just in the way

Even if you don't have any clue, you usually know the types of your functions and data structures.

I mostly write Python and OCaml code. Each langage has its use cases, but I rarely feel the OCaml type system is in my way. When it's in my way, it's because my code is incorrect in an obvious way.

Re:A Plea for Lean Software (1995) [pdf] by Jetrel on Wednesday August 05, 2020 @10:57PM (#24067737)
Yeah, this pretty much echoes my experience working with type-safe languages.

In the case of my anecdote here, I'm mostly talking about typescript, but I've worked with a bunch of other ones in a non-web context.

Every single time, without fail, when I get a "snag" from the type-system, it's complaining about something real. Sometimes it's a trifling bug, like a typo, but ... even there it's usually pretty nice to have the type system immediately jump on it and report it, without me having to deploy the thing and run it and only then find out that something is wrong.

But the other class of bugs - that's where it's solid gold. It'll often catch really sneaky bugs, bugs related to "nullability", where some object I'm blindly using isn't guaranteed to stay allocated during the use case I expect it to be useable in, and holy smokes are those a lifesaver. Having had to deal with those bugs from the opposite direction, they're an unleaded nightmare to try to fix without the type system pinning down exactly the culprit that would be causing it. Every time I see one, I immediately think "wow, this would have been a 5-10 hour nightmare if I had to fix this because of some production bug". I've been in the office till 10pm, and ... I never want to do that again if I can avoid it.

Re:A Plea for Lean Software (1995) [pdf] by kummappp on Wednesday August 05, 2020 @09:18AM (#24060439)
Yeah, the type system helps in that, but for a unit testable product you need factory methods, which produce some valid and invalid cases. If you write simple tests for those it is a type checker on it's own and the type checker is just overhead. If I could choose my next project from two similar implementations where the other would be type checked and the other unit tested with basic datatype factors (at least) I would choose the unit tested one.

I would use typed API's though, because it saves documentation reading time and makes the editor autocomplete to work like magic.

Re:A Plea for Lean Software (1995) [pdf] by wtetzner on Wednesday August 05, 2020 @01:54PM (#24063560)
> If you write simple tests for those it is a type checker on it's own and the type checker is just overhead.

This is not true. Unit tests cannot replace a type system, just like a type system cannot replace unit tests.

You need a unit tests because a type system cannot check for all possible types of correctness.

However, unit tests can only check for the presence of bugs; they cannot prove their absence. On the other hand, a type system can prove that certain classes of errors cannot exist in the program.