Technical Blog

Functional Languages Need Not Be Slow

20 Dec 2023
Programming-Languages

Somewhere in my adolescence I got stuck with the notion that functional languages were slow while languages like C were fast. Now, a good C programmer can eke more performance out of their code than probably anyone else, but the cost you pay to keep your code correct goes exponential as you get closer and closer to the machine. Functional languages abstract a lot away from the machine. Higher languages in general abstract away the machine and make code easier to maintain. ...

Towards Fearless Macros

13 Nov 2023
Featured
Programming-Languages, Macros

Macros are tricky beasts. Most languages—if they have macros at all—usually include a huge “here there be dragons” warning to warn curious would-be macro programmers of the dangers that lurk ahead. What is it about macros that makes them so dangerous and unwieldy? That’s difficult to answer in general: there are many different macro systems with varying degrees of ease-of-use. Moreover, making macros easy to use safely is an open area of research—most languages that have macros don’t have features necessary to implement macros safely. ...

Why Don't More Languages Have a call/cc Operator?

30 Oct 2023
Programming-Languages, Computer-Science

Something I’ve wondered about for a little while: why don’t more languages have a call/cc operator? Having first-class continuations in your programming language gives your programmers a powerful construct. So why do only a handful of languages have it? The short answer is: it’s tricky to implement efficiently. One way to get call/cc is to convert your code into continuation-passing style. Then, call/cc simply takes the continuation in that representation and binds it to a variable. ...

Deriving Recursion from First Principles

2 Oct 2023
Computer-Science, Programming-Languages, Racket

Or: Approaching the Y Combinator These are some of my class notes. Learning to derive the Y Combinator from first principles is something I’ve always wanted to do. This isn’t quite the Y Combinator, but it’s very close and it still gets you recursion without relying on recursive structures to begin with. In the beginning, we write a recursive function to compute the length of a list: (let* ([len (λ (lst) (if (null? ...

My Commitment to Intellectual Integrity

23 Sep 2023
Meta, Academics

I got a strange email the other day. Here it is, with parts redacted: Hi there, My name is G—, I am the main editor at —————. While browsing your site, I noticed you have an amazing article from this page: Link to an extremely old post of mine My team actually just published a comprehensive article on “Semi-related title” which I think your visitors would truly appreciate and add value to your awesome article. ...

Implementing Type Systems as Macros

14 Aug 2023
Featured
Computer-Science, Programming-Languages, Macros, Type-Checking

There’s a neat paper Type Systems as Macros by Chang, Knauth, and Greenman [1] that describes how to implement a typed language using an untyped host language and macro expansion. The paper is neat, but I found the code hard to follow—the paper uses a compact notation that’s convenient for print, but not so much for reproducing on one’s own. This post is my attempt to implement and explain in more accessible terms what’s presented in the paper. ...

Reflections one year into a PhD program

5 Aug 2023
Computer-Science, Education, Career, School, Personal

I started my PhD program about a year ago. In my first year I have: Taken 4 “normal” 3-credit-hour classes Participated in 3 seminars Switched advisors Attended 2 conferences (PLDI @ FCRC, JuliaCon) Presented my work at JuliaCon It’s been a lot of work, and there’s been a lot of stress. I’m in a much better place now than when I started, and over all I’m happy where I’m at and where I’m headed. ...

Warp Factor Refactoring in Emacs

1 Jun 2023
Emacs, Programming, Tools

Here’s a nifty Emacs workflow for doing a project-wide search-and-replace on steroids. While I do use refactor tools that come with language servers,1 sometimes those aren’t enough. Consider the case where you not only need to change the name of a function, but also e.g. need to swap the order of two of its arguments. Or you’ve broken one function out into two that need to be chained together. Whatever—there are plenty of ways where the IDE won’t be able to do everything that you need. ...

Writing Racket Macros: define-syntax and phases

19 May 2023
Tutorials
Computer-Science, Macros, Racket

There are a bunch of different ways of writing a macro in Racket. There are also some tricky things around phases to keep in mind. This is to help me keep them all straight. 3+1 ways to make a macro # This form: (define-syntax-rule (foo args ...) (use args ...)) is equivalent to: (define-syntax foo (syntax-rules () ([foo args ...] (use args ...)))) Which, is in turn equivalent to: (define-syntax foo (λ (stx) (syntax-case stx () [(gensymed-foo args . ...

Meta: Update should fix RSS feeds

13 May 2023
Meta

I recently made an update to how I build my blog. I like writing my posts with Org-mode because it provides a richer markup language than Markdown. Plus, more Emacs = more good. Hugo has support for Org files, but there was a problem with the RSS feed generation: all of my posts written in Org got truncated at some point. I don’t know if the fault lies with Hugo itself or with some problem in the theme I use—whatever it was, I don’t have the time right now to debug that and submit a good bug report or a fix. ...

Mastodon