All Posts

Migrating to Bazel: Part 2
Previously, I focused mostly on getting Python and C++ code to build. This time, I'll talk about adding support for building Gypsum packages. I'll also give a bit more background on the Skylark language and how Bazel deals with extensions.
Tagged: bazel gypsum

Migrating to Bazel: Part 1
Bazel is the open source version of Google's internal build system. Gypsum is a cross-language project, and wanted something that could easily be extended to work with Gypsum itself. Bazel was a natural choice.
Tagged: bazel gypsum

Traits in Gypsum
I'm happy to announce the launch of a major new language feature in Gypsum: traits. Traits are like interfaces in Java. They provide a form of multiple inheritance. When you define a trait, you create a new type and a set of methods that go with it, some of which may be abstract. Classes and other traits that inherit from a trait will inherit those methods.
Tagged: compilers gypsum

Static and dynamic types in pattern matching
Gypsum now supports pattern matching using both static and dynamic type information. In general, pattern matching involves checking at run-time whether a value has a given type. By incorporating static type information about the value being matched, we can perform some checks that wouldn't normally be safe to perform at run-time.
Tagged: compilers gypsum

Machine learning and compiler optimization
Compilers use a heuristic function that predicts whether inlining will be beneficial. This seems like the kind of problem that machine learning was born to solve.
Tagged: compilers machine-learning v8

Futures are better than callbacks
This class was ridiculously large and complicated because of the way it dealt with concurrency. Callbacks are cumbersome for a number of reasons. Futures are better in pretty much every situation I can think of.
Tagged: android concurrency java

CodeSwitch assembly glue for native functions
Last time, I discussed native functions, but I didn't really talk about how CodeSwitch makes the transition from interpreted code to native code. CodeSwitch uses a bit of assembly glue code to load arguments from the interpreter's stack into the right places.
Tagged: codeswitch

CodeSwitch API: native functions
I've added the capability for CodeSwitch to call native functions written in C++. This means that when you write a package, part of it can be written in Gypsum, and part of it in C++. This is useful for implementing new low-level primitives, such as files and sockets.
Tagged: codeswitch gypsum

CodeSwitch API improvements
CodeSwitch is designed to be a library that can be embedded in any application. A good API is crucial. While I can't say that CodeSwitch's C++ API is completely stable yet, I think it's gotten to a pretty usable state.
Tagged: codeswitch gypsum virtual-machines

Existential types in Gypsum
Existential types allow you to express that you have an object with a known class, but you don't know what's inside it. For example, instead of having a list of strings, you have a list of "something". In technical terms, you have an instance of some paraterized class, but you don't know the type arguments. Existential types are similar to wildcard types in Java.
Tagged: gypsum

Arrays in Gypsum
In most languages (like C or Java), arrays are a primitive that stand on their own. You can build other data structures like array lists and hash maps out of them. In Gypsum, array elements can be integrated into any class. The normal class members come first in memory, then the array elements follow immediately.
Tagged: gypsum

Pattern matching in Gypsum
You might think of pattern matching as a switch statement on steroids. You examine a value using several patterns, then execute one an expression based on which of the patterns successfully matched.
Tagged: gypsum

Importing symbols in Gypsum
The import statement is one of several new language features I added to Gypsum this summer. Just like the import statement in Java, it makes definitions from another package available in the scope containing the import statement. Unlike Java, multiple definitions can be imported in the same statement. Definitions can also be renamed.
Tagged: gypsum

Memory management in CodeSwitch
CodeSwitch has its own garbage collected heap, which is used not only for objects allocated by interpreted code, but also for most internal data structures. In this article, I'll describe how the heap is built, how the garbage collector works, and how it tracks pointers to the heap from C++ code.
Tagged: codeswitch garbage-collection gypsum virtual-machines

CodeSwitch bytecode and interpretation
The interpreter is essentially a loop with a big switch-statement. In each iteration, it reads one instruction, switches on the opcode, branches to the appropriate case, then executes some code for that instruction.
Tagged: codeswitch gypsum interpreter virtual-machines

Package loading in CodeSwitch
CodeSwitch manages code in chunks called packages. Each package is stored in a separate file. A package has a name, a version, and a list of dependencies (other packages it depends on). Each dependency has a name, a minimum version, and a maximum version (both versions are optional).
Tagged: codeswitch

How CodeSwitch got its name
Code switching is a linguistic term for when a person speaks in one language, then switches to another language mid-sentence. I want programmers to be able to do that with code.
Tagged: codeswitch

Packages in Gypsum and CodeSwitch
Packages are named bundles of related code. They make code easier to understand and distribute. Each package is compiled into a single file, and has a unique name, a version, and a list of dependencies.
Tagged: codeswitch gypsum

Thoughts on automated testing
I'm writing this article to organize my thoughts on the subject of testing so that I can better understand the obstacles which make it more difficult, and hopefully eliminate them in the future.
Tagged: object-oriented testing

Build notifications in Ubuntu
notify-send is a command line tool that posts a custom notification on your desktop. It's handy to run after a build to let you know when to get back to work.
Tagged: linux productivity

Type parameter bounds and variance
Type parameter bounds and variance provide a huge amount of flexibility and precision in the Gypsum type system. They let you handle many cases where you would normally have to fall back to casting and run-time type checking.
Tagged: compilers gypsum

A weird problem in the Scala type system
I've been trying to formalize the type system in Gypsum. There are two operations in particular that I want to put on a sound theoretical foundation.
Tagged: compilers gypsum scala

Gypsum now has type parameters!
Type parameters are also known as generics in other languages. They enable parametric polymorphism, providing abstraction over types for functions and classes.
Tagged: compilers gypsum

Structure of the Gypsum compiler (part 3)
In this article, I discuss closure conversion, class flattening, CodeSwitch bytecode, semantic analysis, and serialization.
Tagged: compilers gypsum

Structure of the Gypsum compiler (part 2)
In this article, I discuss the Gypsum intermediate representation, declaration analysis, inheritance analysis, and type analysis.
Tagged: compilers gypsum

Structure of the Gypsum compiler (part 1)
Gypsum is an experimental language, so the compiler is designed to be very flexible, easy to change and extend. The nice thing about side projects is that you can spend some extra time making sure the code is clean and elegant. You don't have to take on any technical debt to meet deadlines.
Tagged: compilers gypsum

Introducing Gypsum
Gypsum is a new compiled, statically-typed, object-oriented programming language. When the compiler is more complete, it will be functional as well. Its syntax is inspired by Python and Scala.
Tagged: gypsum

Pinky and the god: Avoiding Emacs-induced RSI
A story about creating and open sourcing a minor mode to help prevent "Emacs pinky"
Tagged: emacs

Emacs: Run git-blame on the current line
This function runs git-blame on the current line and prints the short commit id, author, and commit date into the minibuffer.
Tagged: emacs

The Strahler number
I was browsing Wikipedia and came across an article on the Strahler number, which measures the branching of a tree. The number originally came from hydrology and was used to describe systems of rivers and streams.
Tagged: compilers

How to build a parser by hand
Building a hand-written parser is actually not much harder than using a tool. You can easily build something simple, efficient, and flexible, but perhaps not that elegant. I'll show how I built a parser for a simple template language I use to generate HTML for this blog.
Tagged: parsers python web

New and improved blog software
If you're a regular reader, you might notice a few changes around here! I just launched a modernization of my blogging software.
Tagged: python web

Bit rot is real!
A debugging war story about bad memory.
Tagged: debugging

A tour of V8: Garbage Collection
In this article, I reveal the secrets of V8's garbage collector! Tagged pointers, generational collection, incremental marking, and parallel sweeping are demystified!
Tagged: garbage-collection javascript v8 virtual-machines

A tour of V8: Crankshaft, the optimizing compiler
Crankshaft is V8's optimizing compiler. Once unoptimized code has been running for a while, V8 identifies hot functions and recompiles them with Crankshaft, greatly improving performance.
Tagged: javascript optimization v8 virtual-machines

A tour of V8: object representation
JavaScript allows developers to define objects in a very flexible way. This article looks at the clever optimizations V8 uses to make accessing JavaScript objects as fast as objects in class-based languages.
Tagged: javascript v8 virtual-machines

New Android app: Snowflakes live wallpaper
Today, I launched my first Android app. It's a live wallpaper which renders falling snowflakes using OpenGL ES 2.0.
Tagged: 3d android opengl

A tour of V8: full compiler
An overview of the high level structure of the V8 JavaScript Virtual Machine, with details on the full compiler and inline caches.
Tagged: javascript optimization v8 virtual-machines

Water simulation demo in WebGL
A fully interactive water simulation demo in WebGL and GLSL using a custom built framework.
Tagged: 3d webgl

Interviewing from the other side of the table
Being the interviewer rather than the interviewee is still new to me. I've come to the conclusion that interviewing potential engineers is a technical skill that needs to be learned and refined like any other.

A tale of two benchmarks
Good benchmarks are extremely useful tools for software developers. They tell you the weaknesses of your hardware and software, so you know what to optimize. Customers also care about them a lot, and higher benchmark scores mean more sales.
Tagged: benchmarks javascript

Polymorphic Inline Caches explained
Polymorphic inline caches are a way to optimize function calls in dynamic languages
Tagged: optimization virtual-machines

How to use Emacs like GNU Screen
Tagged: emacs

A brief explanation of Scala 2.8 collections
Tagged: scala

A simple interpreter from scratch in Python (part 4)
We will build the last component of the interpreter, the evaluator, by modelling the program environment and by coding how each statement and expression should be executed.
Tagged: compilers imp python

A simple interpreter from scratch in Python (part 3)
We create an abstract syntax tree for our toy language and write a parser using our parser combinator library.
Tagged: compilers imp parsers python

A simple interpreter from scratch in Python (part 2)
In this article, we will write a small parser combinator library. The combinator library is language agnostic, so you could use it to write a parser for any language.
Tagged: compilers imp parsers python

A simple interpreter from scratch in Python (part 1)
In the first part in this series, we build the lexer, the first component of an interpreter for our toy language, IMP.
Tagged: compilers imp python

Emacs etags: a quick introduction
Emacs etags lets you quickly locate a definition by its name anywhere in your code base.
Tagged: emacs

Parsing key=value pairs in bash
Here's a neat text processing trick for Bash. Let's say you have a text file in which you want to replace several words with new words. The words and their replacements are supplied to you as key=value pairs. How can you parse the pairs?
Tagged: bash

Water simulation in GLSL
A quick demo of reflective water with waves using GLSL in OpenGL
Tagged: 3d opengl

Trapping floating point exceptions in Linux
Tagged: linux

Convenient updates for immutable objects in Scala
Tagged: scala

Parallelization: Harder than it looks
Tagged: c++ optimization parallelization

Tutorial: Reverse debugging with GDB 7
Tagged: gdb linux

Processing large files in Scala
Assorted tips for quickly processing very large files in Scala programs
Tagged: scala

Midrange computers are amazingly cheap

Scala's IDE support is terrible

Tutorial: Function Interposition in Linux
Tagged: debugging linux

Demise of the BBS

Keeping a developer diary

How to use HTTP cookies in Python
Tagged: python web

Currying and why we don't pass arguments as tuples
Tagged: compilers fenris functional-programming

Method resolution
Tagged: compilers fenris

New Blogging System with Python/MySQL
Tagged: python web

Fixpoint type inference
Tagged: compilers fenris

Type tagging format
Tagged: compilers fenris

Limitations on generics
Tagged: compilers fenris

Type inference
Tagged: compilers fenris

Type inference and generics post-mortem
Tagged: compilers fenris