[HN Gopher] The Princeton INTERCAL Compiler's source code
___________________________________________________________________
The Princeton INTERCAL Compiler's source code
Author : surprisetalk
Score : 127 points
Date : 2025-06-02 01:54 UTC (21 hours ago)
(HTM) web link (esoteric.codes)
(TXT) w3m dump (esoteric.codes)
| entrepy123 wrote:
| The INTERCAL satirical language (the original compiler's source
| code of which is announced as recovered in TFA) was covered in a
| couple of episodes [0, 1] of the (highly recommended, if I may
| say) Advent of Computing podcast [2]. [0]
| https://adventofcomputing.libsyn.com/website/episode-78-intercal-
| and-esoterica [1] https://adventofcomputing.libsyn.com/webs
| ite/episode-158-intercal-rides-again-restoring-a-lost-compiler
| [2] https://adventofcomputing.com
| lukasb wrote:
| I always associated INTERCAL with COME FROM but it turns out that
| was "invented" separately (although its first implementation was
| in C-INTERCAL.)
| MangoToupe wrote:
| I thought come-from was an early scheme primitive. It's pretty
| trivial to implement and it's a fun trick.
|
| Edit: i am very wrong. i also had no clue it was meant as a
| joke. I just figured someone had a use case.
| vnorilo wrote:
| The recent C# feature called interceptors [1] pretty much looks
| like comefrom from where I stand. Yet everyone talking about it
| has either been serious, or very good at trolling.
|
| 1: https://khalidabuhakmeh.com/dotnet-8-interceptors
| pjmlp wrote:
| I am completly against them, I think they have re-invented
| Microsoft Fakes, and PostSharp, only badly.
| skissane wrote:
| From your link:
|
| [InterceptsLocation("/Users/khalidabuhakmeh/RiderProjects/Con
| soleApp12/ConsoleApp12/Program.cs", line: 3, character: 3)]
|
| they added a language feature which is sensitive to precise
| line/character offsets in your source code, so the tiniest
| change to the source code invalidates your code...
|
| I'm speechless. Whatever they are aiming to achieve here,
| surely there is a more elegant, less ugly way
| poizan42 wrote:
| You are not supposed to use interceptors in code you write
| yourself. The feature exists for Roslyn Source Generators
| that runs every time you build the code.
| ninkendo wrote:
| I'm still confused though, if you're generating the code
| anyway, why do you need an interceptor? Can't you just
| generate the code to match what you want to redirect to,
| directly inline?
| poizan42 wrote:
| Yes if all the code was generated. The problem is when
| you want to modify the behavior of user-supplied code -
| Roslyn Source Generators are additive so you cannot make
| modifications directly to user-supplied code.
|
| You can read about how they work here: https://github.com
| /dotnet/roslyn/blob/main/docs/features/inc...
|
| Basically they get the files (and ambient metadata) that
| are part of the compilation, filter to the parts it
| depends on, transforms to a in-mem representation of the
| data needed for the code generation, and then finally
| adds new files to the compilation. Since they can only
| add new files they cannot e.g. add code to be executed
| before or after user code is executed like with AOP.
| Interceptors are a solution to that problem.
| ninkendo wrote:
| Interesting, so you're saying generated code can change
| the behavior of user code with no indication this is
| happening from directly reading the user code... that
| sounds pretty horrifying. I guess AOP in general is
| pretty horrifying to me though. Maybe it's useful if you
| restrict its use to very specific things like logging or
| something.
| poizan42 wrote:
| Well yes, hopefully you know what you are doing when you
| reference a source generator. This could ofc. also be
| done with custom msbuild task that modfies the code sent
| to the compiler or the assembly after compilation (like
| Fody), Source Generators just makes the process more
| streamlined and integrates with things like IntelliSense.
| ninkendo wrote:
| > Well yes, hopefully you know what you are doing when
| you reference a source generator
|
| I don't think there's much that's scary about generating
| source code in general. If it's self-contained and you
| have to actually call the generated code to use it, it's
| not really much different than any other code. But the
| idea of having code A change the behavior of code B is
| what's horrifying, regardless of whether code A is
| generated or not. If I'm reading code B I want to be able
| to reason about what I see without having to worry about
| some spooky action at a distance coming from somewhere
| else.
| jayd16 wrote:
| > that sounds pretty horrifying.
|
| Things are constantly doing this. Frameworks use
| reflection or markup or all other kinds of things that
| count as magic if you don't bother to understand what's
| going on.
| anyfoo wrote:
| COBOL has an almost-COME-FROM, its called "ALTER" and it
| changes the destination of a GO TO, but it's "discouraged"
| nowadays.
| skissane wrote:
| Historically, COBOL has had some rather fascinatingly unusual
| features-my favourite is OPEN INPUT REVERSED, which opens
| files for reading backwards-not sure if this was ever in any
| of the COBOL standards, but it exists in IBM mainframe COBOL,
| and many implementations on other platforms have copied it
| from there.
|
| It usually only works for files with fixed length records,
| and reads the records in reverse sequential order, but the
| bits/bytes within the record in forward order. In theory, it
| could be made to work for variable-length record files as
| well, but I'm not aware of any implementation which does.
|
| The original motivation was to support reading magnetic tapes
| backwards, so you could write data to a tape, then read it
| back in without a time-consuming rewind - which was important
| in the early years of computing, when memory and disk sizes
| were so small, magnetic tapes were commonly used for
| temporary storage / work files.
|
| Most tape drives nowadays don't support reading tapes
| backwards, even though there are standard SCSI commands
| defined to do so-but I believe IBM 3592 tape drive series
| still supports this, as do virtual tape servers targeted at
| mainframes. The drive physically reads the bits off the tape
| in reverse order, but then reverses the data before sending
| it to the computer.
|
| I'm not aware of any other language which supports reading
| files backwards, other than COBOL. Well, mainframe assembly
| does, and you can invoke the relevant mainframe IO calls from
| languages such as C-but COBOL is the only language I know of
| which has it as a language feature.
| Sesse__ wrote:
| Many languages have exceptions, which are essentially COME
| FROM.
| Duanemclemore wrote:
| Probably my single favorite podcast episode ever is the Future of
| Coding's episode on INTERCAL [0]. At least I think they tried to
| make it about INTERCAL.
|
| No matter what - a consideration befitting the subject.
|
| [0]https://futureofcoding.org/episodes/064.html
| ghssds wrote:
| They call it an esoteric language but event-driven programming is
| basically based on "COME FROM" structures. Shell also extensively
| uses PLEASE-like fonctionality in the form of SUDO. The syntax of
| INTERCAL is very clean if we compare it to, say, regex.
| anyfoo wrote:
| Not sure about regex. Its syntax is, by definition, _regular_.
| (Okay, most regex engines people use aren't technically fully
| regular languages anymore, but that just makes things more
| convenient.)
| eru wrote:
| > Its syntax is, by definition, regular.
|
| No, not at all. Regexes describe regular languages, but that
| doesn't mean that their own syntax needs to be a regular
| language.
|
| Eg many regexes allow parens, so you can have both 'ab|c' and
| 'a(b|c)'. But if you require your parens to be balanced,
| that's no longer a regular language.
| skissane wrote:
| > But if you require your parens to be balanced, that's no
| longer a regular language
|
| From a certain pedantic perspective, it still is a regular
| language, since there is a finite (implementation
| dependent) upper bound on nesting depth, and balanced
| parens with a finite upper bound of nesting is regular.
|
| OTOH, one can appeal to the linguistic distinction between
| competence and performance, and say that regexes are
| irregular in pure competence, even though all (practically
| usable) languages turn out to be regular once we constrain
| them by performance as well.
| eru wrote:
| > From a certain pedantic perspective, it still is a
| regular language, since there is a finite (implementation
| dependent) upper bound on nesting depth, and balanced
| parens with a finite upper bound of nesting is regular.
|
| That's a silly point, because it makes all languages
| trivially finite, even monsters like C++. (Finity is even
| more of a restriction than being regular.)
| skissane wrote:
| Is it silly? Well, if a person feels drawn to an
| ultrafinist philosophy of mathematics, they may feel it
| is important to emphasise the inherent finitude of all
| creations of inherently finite human minds, formalisms
| such as programming languages included.
| anyfoo wrote:
| You're right!
| eterm wrote:
| > if you require your parens to be balanced, that's no
| longer a regular language.
|
| TIL: https://en.wikipedia.org/wiki/Pumping_lemma_for_regula
| r_lang...
|
| As someone who has only recently learned the formal
| definition of regular language ( Thanks to
| https://www.youtube.com/watch?v=9syvZr-9xwk as mentioned on
| this board recently ), I'm interested in the formal proof
| for this?
|
| It feels intuitively true, but I haven't finished the
| course yet and therefore haven't come across it and can't
| yet reason well about it.
|
| Is the problem then in trying to "encode" whether brackets
| are balanced, that we would need infinite "levels" of how
| many more brackets we've opened rather than closed, (i.e a
| stack) and that violates the finite nature of finite
| automota?
|
| So I've googled it now, and I've found the result is due to
| the "Pumping lemma": https://en.wikipedia.org/wiki/Pumping_
| lemma_for_regular_lang...
| xxmarkuski wrote:
| INTERCAL is presented at the Christmas Lecture in Programming at
| KIT
| breakingcups wrote:
| "[...] to English, where the interpreter was once literally
| another person but is now downgraded to an AI prompt system."
| az09mugen wrote:
| Since there is the source now, does someone know what
| quantity/proportion of "PLEASE" the developer needs to write ?
|
| Because IIRC, if you don't put enough or too much "PLEASE", the
| compiler won't compile.
| moritzwarhier wrote:
| Let's start with: I don't know. Also I can't read this language
| (BASIC variant?) and am browsing from a phone.
|
| But this line at least outputs the error message:
|
| https://github.com/rottytooth/INTERCAL72/blob/f94e0c8eaaf134...
|
| edit: probably _slightly_ complicated :D
|
| but this makes me wonder if it's related to the source
| mutliplying some variable/register value by 3 in the error
| line:
|
| > You will need at least 3 lines of code, with one PLEASE
| statement among them.
|
| (from README)
|
| Just searching "PLEASE" also shows increments and a comparison
| with a number written in hex... so it should be easy to figure
| out the intercal "please" halting problem instance, right? :)
| az09mugen wrote:
| Thank you so much for the time you took answering that
| existential question of mine! (And maybe others)
| moritzwarhier wrote:
| Thanks for your reply: apparently, sometimes questions as
| answers _can_ be helpful :)
| tasty_freeze wrote:
| I'm waiting for the self-hosting version of the compiler before I
| deploy it in my own projects.
___________________________________________________________________
(page generated 2025-06-02 23:01 UTC)