Profile photo for Sridhar Ramesh

Let me draw an analogy.

Let's suppose there is a programming language called Silent, developed for esoteric reasons by an ascetic order of monks, which is just like any other programming language, except there is no capability in this programming language to command your computer to beep or make noises of any kind. Alas, unfortunately for these monks, the world is full of impure influences, and there are plenty of other languages on the market which can make all kinds of noise. Noisemaker 3000, for instance.

Suppose then I do two things:
A) I implement in Silent a program which processes inputs however it likes, and then finally, after deciding what noises it wants to make in response, outputs a description of the Noisemaker 3000 commands which would produce those noises. Note that this still a perfectly silent program, so far as what the standard Silent interpreter is meant to do with it; it just happens to produce as output a description of a program in another language, which would, if passed to the appropriate interpreter for that other language, make noise.

B) Instead of just running my Silent interpreter on this program, I chain things up so that the results of Silent interpreter are then automatically passed to a Noisemaker 3000 interpreter. I call the whole chained-up setup the SilentPlus interpreter. This becomes so popular a setup that, after a while, people forget there ever was any other Silent interpreter, and just think of SilentPlus as the only way to run Silent code.

The question is akin to asking "How come I'm able to make a Silent program which produces beeps, shrieks, howls, and screams, without violating the monk-enforced quiet nature of Silent programming?".

Strictly speaking, you aren't. You're making a Silent program which produces Noisemaker 3000 code, and then going ahead and using a Noisemaker 3000 interpreter to run that Noisemaker 3000 code.

The example is kind of silly, because there is little advantage in having a programming language that claims to be silent but an interpreter which allows an endrun into making noise. But it is illustrative of how monadic programming works, in the context of the kind of questions I suspect you have. No matter what programming language you start with, with whatever restrictions to make it easier to reason about how it operates, if it's got even a modicum of expressive ability, then it can output code for any other programming language with any other capabilities in the world, even outputting code that's supposed to be able to do things it cannot natively do. Yet, so far as reasoning about programs in your restrictive language goes, you still have all the convenient properties that its restrictions were meant to ensure as well.

[I'll try and clear this answer up a bit, since I fear it's gotten rambling and hard to follow]

View 5 other answers to this question
About · Careers · Privacy · Terms · Contact · Languages · Your Ad Choices · Press ·
© Quora, Inc. 2025