RSC for Lisp Developers

https://news.ycombinator.com/rss Hits: 7
Summary

Okay, so I don’t actually know LISP, so this is gonna be a tough one. If I misunderstand something, please help me understand it. But from what I know, one of the big ideas of LISP is that code is data, and data is code. I mean, that’s kind of generally true, but in LISP it’s both culturally and syntactically emphasized. For example, let’s take this piece of code in LISP: (+ 2 2) This gives us 4. But let’s put a quote before it: '(+ 2 2) Suddenly, the result is… (+ 2 2). Uh, what do I do with that? Well, that’s a piece of LISP code. “Quoting” a piece of LISP code means “don’t actually evaluate it, just give me the code itself”. Of course, I could evaluate it later: (eval '(+ 2 2)) This gives me 4 again. That’s what I mean by “code is data” being very much in the LISP culture. The language has a first-class primitive for “don’t execute this part”. That’s quoting. Now consider web apps. A web server is a program whose job is to generate another program. A server generates the client program (written in HTML and JavaScript) and serves it to the client computer. Generating and sending code sounds an awful lot like quoting. In JavaScript, we don’t have quoting. I can’t put a ' before a function and say “now I want to treat this as data rather than code”. Well, I could wrap it into a string literal, but there would be no syntax highlighting and it would kind of lose too much syntatic power. You really don’t want to be coding inside string literals. We can’t “quote” individual code blocks in JavaScript without losing many benefits of the language. However, what if we could “quote”… an entire module? 'use client' export function onClick() { alert('Hi.'); } This means that whoever imports onClick from the backend code won’t get an actual onClick function—instead, they’ll get '/js/chunk123.js#onClick' or something like that identifying how to load this module. It gives you code-as-data. Eventually this code will make it to the client (as a <script>) and be evaluated there. Th...

First seen: 2025-06-01 12:31

Last seen: 2025-06-01 18:32