News for hackers. Stuff that matters.
Re:Strict APIs vs. Forgiving APIs by dicroce on Wednesday October 28, 2020 @11:53AM (#24920232)
If I had to choose I'd say prefer strict... But reading this made me wonder: what if you could be strict during development but switch to forgiving for deployment?
Re:Strict APIs vs. Forgiving APIs by avianlyric on Wednesday October 28, 2020 @01:32PM (#24921646)
> what if you could be strict during development but switch to forgiving for deployment?

That sounds like a debugging nightmare, where your production system is subtlety different in behaviour to your dev system.

Also how do you know that the forgiving behaviour is correct in production? Maybe it prevents a couple of scary error messages, but it could just as equally allow incorrect inputs to be processed and stored, creating a data cleanup nightmare later.

Re:Strict APIs vs. Forgiving APIs by Vinnl on Wednesday October 28, 2020 @12:44PM (#24920950)
That sounds like the modern JavaScript toolchain. During development, run a linter to make sure you're not using error-prone or outdated functionality, run a type checker to make sure you're passing sane data around, but when running in the browser, don't blow up in the user's face.
Re:Strict APIs vs. Forgiving APIs by 4thwaywastrel on Thursday October 29, 2020 @12:09AM (#24927099)
This is what we do, but we warn rather than just swallow it. I find it the best of both.
Re:Strict APIs vs. Forgiving APIs by gpderetta on Wednesday October 28, 2020 @01:35PM (#24921691)
that's the idea behind assert in C/C++.