frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Advanced Scheme Techniques (2004) [pdf]

https://people.csail.mit.edu//jhbrown/scheme/continuationslides04.pdf
111•mooreds•4mo ago

Comments

s20n•4mo ago
Speaking from personal experience, Scheme looks deceptively simple but it is one of the hardest languages to write a compiler for.

I say this mainly because of 2 things:

1. Hygienic Macros (You practically have a whole another language inside the language)

2. First Class Continuations (There is no good way to achieve this other than doing a CPS transform on the AST)

maplant•4mo ago
CPS transforms are not the only way; if you translate the scheme to bytecode for a virtual machine, the call stack and IP can be reified.

But yes, for a compiler specifically, you need a CPS transformation

bjoli•4mo ago
CPS transformation is a good thing to do anyway, no? Then CPS your CPS and you have delimited continuations.
shawn_w•4mo ago
Go straight for delimited continuations, which give you global ones for free.
bjoli•4mo ago
Oh. I meant not using call/cc, but by doing local CPS transformations. This is the simple way, but has limitations with dynamic uses of reset.

A direct implementation is harder, but probably more useful.

matt_d•4mo ago
As far as compiling continuations goes, sequent calculus (specifically as a compiler IR) is an interesting research direction. See Grokking the Sequent Calculus (Functional Pearl) from ICFP 2024: https://dl.acm.org/doi/abs/10.1145/3674639

"This becomes clearer with an example: When we want to evaluate the expression (2 + 3) ∗ 5, we first have to focus on the subexpression 2 + 3 and evaluate it to its result 5. The remainder of the program, which will run after we have finished the evaluation, can be represented with the evaluation context □ ∗ 5. We cannot bind an evaluation context like □ ∗ 5 to a variable in the lambda calculus, but in the λμ~μ-calculus we can bind such evaluation contexts to covariables. Furthermore, the μ-operator gives direct access to the evaluation context in which the expression is currently evaluated.

Having such direct access to the evaluation context is not always necessary for a programmer who wants to write an application, but it is often important for compiler implementors who write optimizations to make programs run faster. One solution that compiler writers use to represent evaluation contexts in the lambda calculus is called continuation-passing style. In continuation-passing style, an evaluation context like □ ∗ 5 is represented as a function λ x . x ∗ 5. This solution works, but the resulting types which are used to type a program in this style are arguably hard to understand. Being able to easily inspect these types can be very valuable, especially for intermediate representations, where terms tend to look complex. The promise of the λμ~μ-calculus is to provide the expressive power of programs in continuation-passing style without having to deal with the type-acrobatics that are usually associated with it."

A brief summary of the SC-as-a-compiler-IR vs. CPS from one of the authors of the paper: https://types.pl/@davidb/115186178751455630

"In some sense the Sequent Calculus (SC) is quite similar to a CPS based IR. To sum up the benefits of SC over CPS in two concepts, I would say: Symmetry and non-opaque continuations.

Symmetry: A lot of pairs of dual concepts are modelled very naturally and symmetrically in SC: call-by-value and call-by-name, data types and codata types, exception based error handling and Result-type error handling, for example.

Non-Opaque continuations: Instead of continuations in CPS which are just a special kind of function whose internals cannot be inspected (easily), SC introduces consumers whose internal structure can be inspected easily, for example when writing optimization passes."

cwzwarich•4mo ago
There's an OOPSLA paper (referred to from the link starting that thread) from this year with 2 of the same authors that goes into more detail about using it as a compiler IR: https://dl.acm.org/doi/10.1145/3720507
samth•4mo ago
It's not true that you need to use CPS to implemented first-class continuations. There are plenty of slow ways to do it, and even if you want to be fast you can do multiple different things. Dybvig describes a number of options in his thesis: https://www.cs.unc.edu/xcms/wpfiles/dissertations/dybvig.pdf
ashton314•4mo ago
Sam will definitely know more about this than I will, so if he contradicts me, listen to him.

If I am not mistaken, the racket language does not convert to CPS during compilation. Instead, when you want to get the continuation, I think you just get a pointer to the stack frame that you want. All I know for sure is that it uses something called a-normal form, which is kind of like SSA in some ways, and that the continuation is 2x 64/32-bit words depending on your architecture.

samth•4mo ago
The main implementation of Racket today is built on top of Chez Scheme, which uses the techniques described by Dybvig that I linked to.

In the earlier implementation of Racket, indeed it doesn't convert to CPS but does use something like A-normal form. There, continuations are implemented by actually copying the C stack.

swatson741•4mo ago
Very true but the other side of this is first class continuations are no worse than compiling try-catch semantics, and hygienic macros are still just macros so the complexity is kept simple (sort of. maybe simple isn't always so simple).

The other thing that makes languages like scheme difficult to compile are those closures. In fact, the book, the implementation of functional programming languages, Jones (1987) didn't do it at all! No closure conversion at all. They just compiled to a letrec in the g-machine.

kazinator•4mo ago
Use someone else's implementation of the macro stuff and focus on the compiler.
twoodfin•4mo ago
This is part two of a seminar series:

https://people.csail.mit.edu//jhbrown/scheme/

shawn_w•4mo ago
Bug: The `list-iter` function presented assumes that an empty list is false. While that's the case in Common Lisp, it isn't in Scheme (and hasn't been in a very long time; iirc in early versions it was optional behavior).
jhbrown•4mo ago
Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)
mooreds•4mo ago
FYI, all the links in your bio 404.
shawn_w•4mo ago
Don't feel compelled to rush into giving it again that soon just because it got shared on HN.
bjoli•4mo ago
You should all have a look at Oleg Kiselyov's speech about continuations at Dan Friedman's 60th birthday. That is some next level shit.
pjmlp•4mo ago
Thanks for the heads up.

Tiny C Compiler

https://bellard.org/tcc/
52•guerrilla•1h ago•20 comments

You Are Here

https://brooker.co.za/blog/2026/02/07/you-are-here.html
37•mltvc•1h ago•34 comments

SectorC: A C Compiler in 512 bytes

https://xorvoid.com/sectorc.html
148•valyala•5h ago•25 comments

The F Word

http://muratbuffalo.blogspot.com/2026/02/friction.html
77•zdw•3d ago•31 comments

Speed up responses with fast mode

https://code.claude.com/docs/en/fast-mode
82•surprisetalk•5h ago•89 comments

LLMs as the new high level language

https://federicopereiro.com/llm-high/
21•swah•4d ago•13 comments

Software factories and the agentic moment

https://factory.strongdm.ai/
119•mellosouls•8h ago•232 comments

Hoot: Scheme on WebAssembly

https://www.spritely.institute/hoot/
157•AlexeyBrin•11h ago•28 comments

OpenCiv3: Open-source, cross-platform reimagining of Civilization III

https://openciv3.org/
864•klaussilveira•1d ago•264 comments

Stories from 25 Years of Software Development

https://susam.net/twenty-five-years-of-computing.html
113•vinhnx•8h ago•14 comments

GitBlack: Tracing America's Foundation

https://gitblack.vercel.app/
17•martialg•50m ago•3 comments

FDA intends to take action against non-FDA-approved GLP-1 drugs

https://www.fda.gov/news-events/press-announcements/fda-intends-take-action-against-non-fda-appro...
29•randycupertino•58m ago•29 comments

Show HN: A luma dependent chroma compression algorithm (image compression)

https://www.bitsnbites.eu/a-spatial-domain-variable-block-size-luma-dependent-chroma-compression-...
21•mbitsnbites•3d ago•1 comments

Al Lowe on model trains, funny deaths and working with Disney

https://spillhistorie.no/2026/02/06/interview-with-sierra-veteran-al-lowe/
73•thelok•7h ago•13 comments

First Proof

https://arxiv.org/abs/2602.05192
75•samasblack•7h ago•57 comments

Brookhaven Lab's RHIC concludes 25-year run with final collisions

https://www.hpcwire.com/off-the-wire/brookhaven-labs-rhic-concludes-25-year-run-with-final-collis...
36•gnufx•4h ago•40 comments

Vocal Guide – belt sing without killing yourself

https://jesperordrup.github.io/vocal-guide/
253•jesperordrup•15h ago•82 comments

I write games in C (yes, C) (2016)

https://jonathanwhiting.com/writing/blog/games_in_c/
156•valyala•5h ago•136 comments

Start all of your commands with a comma (2009)

https://rhodesmill.org/brandon/2009/commands-with-comma/
533•theblazehen•3d ago•197 comments

Show HN: I saw this cool navigation reveal, so I made a simple HTML+CSS version

https://github.com/Momciloo/fun-with-clip-path
38•momciloo•5h ago•5 comments

Reinforcement Learning from Human Feedback

https://rlhfbook.com/
98•onurkanbkrc•10h ago•5 comments

Selection rather than prediction

https://voratiq.com/blog/selection-rather-than-prediction/
19•languid-photic•3d ago•5 comments

Italy Railways Sabotaged

https://www.bbc.co.uk/news/articles/czr4rx04xjpo
71•vedantnair•1h ago•55 comments

The AI boom is causing shortages everywhere else

https://www.washingtonpost.com/technology/2026/02/07/ai-spending-economy-shortages/
212•1vuio0pswjnm7•12h ago•323 comments

72M Points of Interest

https://tech.marksblogg.com/overture-places-pois.html
42•marklit•5d ago•6 comments

A Fresh Look at IBM 3270 Information Display System

https://www.rs-online.com/designspark/a-fresh-look-at-ibm-3270-information-display-system
52•rbanffy•4d ago•14 comments

Unseen Footage of Atari Battlezone Arcade Cabinet Production

https://arcadeblogger.com/2026/02/02/unseen-footage-of-atari-battlezone-cabinet-production/
129•videotopia•4d ago•40 comments

Coding agents have replaced every framework I used

https://blog.alaindichiappari.dev/p/software-engineering-is-back
273•alainrk•10h ago•452 comments

France's homegrown open source online office suite

https://github.com/suitenumerique
649•nar001•9h ago•284 comments

Microsoft account bugs locked me out of Notepad – Are thin clients ruining PCs?

https://www.windowscentral.com/microsoft/windows-11/windows-locked-me-out-of-notepad-is-the-thin-...
51•josephcsible•3h ago•67 comments