Skip to content

Instantly share code, notes, and snippets.

View osa1's full-sized avatar

Ömer Sinan Ağacan osa1

View GitHub Profile
@pizlonator
pizlonator / pizlossafull.md
Last active November 20, 2025 00:00
How I implement SSA form

This document explains how I would implement an SSA-based compiler if I was writing one today.

This document is intentionally opinionated. It just tells you how I would do it. This document is intended for anyone who has read about SSA and understands the concept, but is confused about how exactly to put it into practice. If you're that person, then I'm here to show you a way to do it that works well for me. If you're looking for a review of other ways to do it, I recommend this post.

My approach works well when implementing the compiler in any language that easily permits cyclic mutable data structures. I know from experience that it'll work great in C++, C#, or Java. The memory management of this approach is simple (and I'll explain it), so you won't have to stress about use after frees.

I like my approach because it leads to an ergonomic API by minimizing the amount of special cases you have to worry about. Most of the compiler is analyses and transformations ov

Note to readers: This document is an early draft of a model for memory-safe references that I've been working on for the last ~2 years. While I think it is quite promising, the design is unfinished. The "regions" that I present in this document have not been given a formal semantics, and I have not explained where they originate from. My goal is merely to convince you that the design is promising, and that if seen to completion, it would advance the frontier of zero-cost memory safety.

Update March 2025: I am working on a newer version of this proposal, that aims to simplify the model substantially. When I have finished that proposal, I will put a link here.

Update August 2025: Verdagon has written an awesome blog post that explains this proposal at a high level. I recommend you check it out!

Abstract

In this document, I present a novel model for memory-safe references that aims to significantly improve upon the Rust-inspired model that Mojo c

@pervognsen
pervognsen / shift_dfa.md
Last active November 8, 2025 18:12
Shift-based DFAs

A traditional table-based DFA implementation looks like this:

uint8_t table[NUM_STATES][256]

uint8_t run(const uint8_t *start, const uint8_t *end, uint8_t state) {
    for (const uint8_t *s = start; s != end; s++)
        state = table[state][*s];
    return state;
}
@ltratt
ltratt / highlight_words_in_vim.vim
Created July 21, 2020 07:58
Highlight words in Vim
" Highlight Word, initial version from:
" https://gist.github.com/emilyst/9243544#file-vimrc-L142
"
" This mini-plugin provides a few mappings for highlighting words temporarily.
"
" Sometimes you're looking at a hairy piece of code and would like a certain
" word or two to stand out temporarily. You can search for it, but that only
" gives you one color of highlighting. Now you can use <leader>N where N is
" a number from 1-6 to highlight the current word in a specific color.
"
@edsko
edsko / Collect.hs
Last active September 10, 2018 15:15
Applicative-only, spaceleak-free version of 'WriterT'
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
import Data.Functor.Identity
import Data.Monoid
anonymous
anonymous / trie.rs
Created August 14, 2017 20:02
use std::fmt::Debug;
use std::fs::File;
use std::io::{BufWriter, Result};
use std::io::prelude::*;
use std::path::Path;
/// A generic case-insensitive Trie map permitting only alphabetical string keys.
pub struct Trie<T> {
values: Vec<T>,
/// An array of twenty-six optional tries, corresponding to each letter of the alphabet.
@rosghub
rosghub / dotfiles
Created May 20, 2017 01:12
Manjaro i3 Hi-DPI config
#
# Configuration files for Manjaro i3 on Lenovo Yoga 2 pro
# to scale properly on HiDPI (3200x1800)
#
#####################################################
~/.profile #
#####################################################
# UI element scaling, icons
export GDK_SCALE=2
@osa1
osa1 / gist:f3585ddab933d15d62d370f8dc4bb91b
Last active February 5, 2019 11:04
vim configure params
# vim
./configure --with-features=huge \
--enable-gui=qt \
--prefix=/home/omer \
--enable-pythoninterp \
--enable-python3interp \
--enable-rubyinterp \
--enable-perlinterp \
--with-python-config-dir=/usr/lib64/python2.7/config \
--with-python3-config-dir=/usr/lib64/python3.4/config-3.4m/
@mrb
mrb / abstint.md
Last active October 4, 2020 18:45
"Programs that eat programs" Works cited/bibliography
@chrisdone
chrisdone / typing.md
Last active August 14, 2025 17:50
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology