Simon Peyton Jones
π€ SpeakerAppearances Over Time
Podcast Appearances
But I want them to do that in a provably secure way.
So you can know that these programs don't interact rather than just say, I've done my best.
Oh, well, it can be very tiresome and inconvenient, right?
So you're somewhere deep in the, you know, a subroutine of a subroutine of a subroutine of a software stack, and you want to reach out and, I don't know, grab the time of day.
Oh, dear.
That's a side effect.
But we're in a pure functional language.
And indeed, there's a good reason because everybody else in Ohio in the stack is assuming that if I call this function apply to seven, it will give me the same answer if I call it again apply to seven.
But if it could interrogate the time of day, suddenly it might give a different answer.
Right.
So this as simple a thing as I was asking for the time of day invalidates a whole set of assumptions.
And so it's not by default allowed at all.
And that can be inconvenient because all you say, look, guys, all I want to do is get hold of the time of day.
Don't give me grief.
And so every functional programming language, including Haskell, provides you with a little trapdoor.
Haskell's is called unsafe perform I.O.
And it says, trust me, I'm going to do something that has side effects, but you can pretend there weren't any.
All right.
So, and it's called, it is literally spelt U-N-S-A-F-E perform IO, the long name that has unsafe in the title so that you, the programmer, are taking on the obligation to make sure that what you're doing is okay.
Whereas in imperative language, everything you do could be unsafe perform IO-ish.