3 ms·
I think load and dangerous_load is a wonderful paradigm for API design. It is, but I think it ignores the reality of API design. Who would ever start with dang
by untog 14y ago
I think load and dangerous_load is a wonderful paradigm for API design.
It is, but I think it ignores the reality of API design. Who would ever start with dangerous_load? If you knew it was dangerous, you'd probably fix it. No, you start with load(), then find out it's dangerous afterwards. The fix will be a breaking change, so you make safe_load().
"You should replace load()!", I hear you cry. But that removes backwards compatibility. And people don't update legacy software. So then old software becomes vulnerable to who knows how many other security problems because of it's obsolescence.
- vog 14y ago> ... ignores the reality of API design. Who would ever start with dangerous_load? When I wrote the Texcaller library, which simplifies compiling (La)TeX code, I disabled dangerous features such as "write18" from the very beginning. I you don't take basic elements such as "secure/unsecure" variants into account, you're no really doing API design. You then just have a historically grown API, which is not necessarily bad in itself, but doesn't qualify to be called API design. > But that removes backwards compatibility. And people don't update legacy software. So then old software becomes vulnerable to who knows how many other security problems because of it's obsolescence. In that case, at least only old hard-to-update legacy software is affected, and not all the other (good, mostly well-written) software that is written today and in the future. Of course, don't forget to increase the major version number, as for every API change that breaks backward compatibility.
- untog 14y agodoesn't qualify to be called API design. True. I should have said the reality of the difficulty of API design. In that case, at least only old hard-to-update legacy software is affected, and not all the other (good, mostly well-written) software that is written today and in the future. I like the sentiment, but I can't agree with it. In an ideal world all critical systems would always be kept up the date, but that doesn't happen. Has Python 3 usage overtaken 2.x yet?
- ufo 14y ago> Who would ever start with dangerous_load? Haskellers. This is why you get lovely long and alarming names like `unsafePerformIO`
- rpearl 14y agoWhich, since it explicitly breaks type safety (you can write coerce :: a -> b with it), is an appropriate name for that function.
- mercurial 14y agoOn the other hand, for serialization/deserialization of a data type from format X to Haskell, you would not need a "dangerous_load" function, since the code would be pure.