Lean: Formalizing Mathematics as Code

2025-07-31
Lean: Formalizing Mathematics as Code

Lean is a programming language primarily used by mathematicians to formalize mathematics. It allows mathematicians to treat mathematics as code, breaking it into structures, theorems, and proofs, and sharing them on GitHub. The article uses a simple example, proving 2=2, to introduce Lean's syntax and basic concepts like tactics. It demonstrates how tactics are used to prove or disprove mathematical statements. A fictional axiom, '2=3', illustrates how a faulty axiom can lead to proving anything, highlighting the importance of formal verification. The article concludes by mentioning the ongoing Lean formalization of Fermat's Last Theorem as a testament to Lean's power.

Read more
Development

Quoting in JavaScript: Inspired by Lisp for Modular Front-End Development

2025-06-01
Quoting in JavaScript: Inspired by Lisp for Modular Front-End Development

This article explores how the "code is data" concept from Lisp can improve modularity in JavaScript for web app development. The author points out JavaScript's lack of Lisp's quoting mechanism, preventing direct manipulation of code snippets as data. However, by mimicking quoting—sending client-side module identifiers instead of the actual code to the client—delayed execution and modular composition are achieved. This allows backend programs to compose server-side and client-side behaviors, ensuring all server-side logic completes within a single request/response cycle and enabling progressive streaming, thus improving efficiency and maintainability of web applications.

Read more
Development

Progressive JSON: Streaming Data Like a Progressive JPEG

2025-06-01
Progressive JSON: Streaming Data Like a Progressive JPEG

This article explores progressive JSON, a method to improve JSON data transfer efficiency. Traditional JSON requires waiting for the entire data load before parsing, unlike progressive JSON, which resembles progressive JPEGs by first transmitting the data framework and then progressively filling in details. The article compares depth-first and breadth-first data streaming, noting that React Server Components (RSC) utilize a breadth-first approach combined with Suspense components to achieve progressive UI loading, enhancing user experience.

Read more

Zero-Cost Static Blog with React Server Components

2025-05-08
Zero-Cost Static Blog with React Server Components

This blog post details how to deploy a completely static blog using Next.js's static site generation capabilities and React Server Components (RSC) on Cloudflare's free static hosting plan, costing exactly zero. The author explains the concept of 'hybrid' frameworks, capable of both server-side rendering and static site generation. By running RSC code during the build process and saving its output, a fully static deployment is achieved, eliminating server costs. A code example shows data being read from the local filesystem during the build, generating static pages. This demonstrates that 'static' is essentially a 'server' running ahead of time, with the code logic remaining the same, only the timing changes.

Read more
Development

Astro vs. React Server Components: A Tale of Two High-Performance Architectures

2025-05-07
Astro vs. React Server Components: A Tale of Two High-Performance Architectures

This article compares Astro and React Server Components (RSC), two approaches to building high-performance websites. Astro uses Astro Components (server-side) and Client Islands (client-side), with data flowing unidirectionally. Astro Components handle preprocessing, while Client Islands manage interactivity. RSC uses Server Components and Client Components, conceptually similar but both are React components differentiated by the `'use client'` directive. RSC offers greater flexibility, allowing component sharing between server and client, but has a steeper learning curve. Astro is easier to learn but might encounter limitations in large-scale applications due to its HTML-first output and inter-component interaction constraints. The choice depends on project needs and team expertise.

Read more
Development

React Server Components: Untangling Frontend Data Fetching

2025-04-15

This article explores how React Server Components solve the complexities of frontend data fetching. Traditional REST APIs struggle to keep up with evolving UI needs, leading to either data redundancy or insufficient data. The author proposes a BFF (Backend for Frontend) approach, introducing the ViewModel concept to the backend, allowing the server to directly return the specific data each component requires. By decomposing ViewModel functions into smaller units and leveraging JSX, a tight coupling between components and data loading logic is achieved, resulting in an efficient and maintainable frontend architecture. This method is similar in spirit to Async XHP, seamlessly integrating data fetching and UI rendering, but avoids the limitations of traditional XHP in highly interactive applications.

Read more
Development Data Fetching

React Server Components: A Philosophical Dive into Tags vs. Function Calls

2025-04-09

This article explores the fundamental differences between tags and function calls, starting from the context of React Server Components. The author uses the analogy of architectural blueprints and cooking recipes to illustrate the declarative nature of tags versus the imperative nature of function calls. The discussion delves into remote procedure calls and asynchronous programming, culminating in a theoretical framework for splitting computations across multiple machines. Tags represent potential function calls spanning time and space, and by differentiating between Components and Primitives, the author addresses how different functions depend on computation order. This leads to an efficient method for program segmentation.

Read more
Development Server Components