Articles tagged "compilers"

Export data, the secret of Go's fast builds
Each compiled Go package contains export data, a binary description of its exported definitions. When the compiler handles an import, it can quickly scan export data to learn about the imported package's definitions. This is much faster than parsing and type-checking sources for imported packages, so building large programs is very fast.

How Python parses white space
One of the most distinct and remarkable things about Python's syntax is its use of white space. Python uses white space for two things: newlines are used to terminate logical lines, and changes in indentation are used to delimit blocks. Both of these behaviors are somewhat contextual.

Lambdas in Gypsum
I've finally added a feature to Gypsum that I've wanted for a long time: lambdas. They're useful for defining short, compact functions that can be passed to other functions as callbacks. They're especially important for functional programming (map, filter, reduce, and friends).

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.

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.

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.

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.

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.

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.

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

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

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.

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.

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.

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.

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.

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.

Currying and why we don't pass arguments as tuples

Type inference and generics post-mortem

Type inference

Limitations on generics

Type tagging format

Fixpoint type inference

Method resolution