MessiahAndrw/Designing A Language

From OSDev Wiki
Jump to: navigation, search

This page is really a bunch of thoughts on designing programming languages.

Why would you want to design a language? Because it's fun. Perhaps you want to write your OS in your own language, or perhaps you just want to make your own scripting language.

In this section I'm not going to talk about the actual language itself and not get into compiler development.

Hopefully, by being interested in designing your own programming language, you have an idea of what kind of language you want to design. If not, figure it out now. Take the best of what you love from languages, and take out the bits you don't like, and make it your own.


Pick a Paradigm

When you start designing your language, you need to come up with what sort of programming paradigms[/url you want to build your language around.

Do you want an event driven language? Do you want it a functional language where no function has side effects? Do you want a flow-based language where you define components and how data flows between them? Do you want it to be object oriented? Do you want it to be contract driven, or something completely different like time driven?

It is true that if a language is Turing complete you can support virtually any paradigm, even if not easily. But, you can make working with particular paradigms much easier by having first-class support for them in your programming language, or even design your language around them. For example - languages built around the class-based object-oriented paradigm tend to support classes as a high-level feature.

A large factor that determines what paradigms you will follow will largely depend on the intended usage of your language. Do you want it to be a general purpose language, that someone can write end-user applications in (like C, C#, Java)? Or do you want it domain specific?

Domain-specific languages are languages built for a specific purpose. Here are some examples of domain-specific languages:

  • DOS batch files use job control language which basically allows you to call a batch of programs, with limited support to piping one program's output to another program's input, and limited flow control.
  • GLSL is a shading language for controlling the GPU. GLSL programs are short and sweet, with a focus on throughput and manipulating pixels, vertices, and other graphical elements in parallel.
  • The Wolfram Language is a language built for math, simulation, and visualization.
  • SQL is a relational database language.

There are languages that look very difficult to how one usually imagines a programming language, for example:

  • XML is a markup language for representing structured documents.
  • LaTeX is another markup language for typesetting and document preparation.

The rest of this article will focus on general purpose programming languages.

Type System

In general purpose languages, you typically have variables which store values, references to objects, among other things. How you assign types to variables is referred to as the type system. There are two major kinds of type systems - static typing and dynamic typing.

Static typing refers to a type system where types are assigned at compile-time, and the programmer can easily determine what types are assigned to what variables. For example, if a variable has the type 'int' or 'string', you have a pretty good idea of what it is and how it is stored in memory, and that variable has a consistent type throughout its life.

Dynamic typing refers to a type system where types are not explicitly defined, and in many cases, the same variable may have different types at different times.

Memory Safety

Dynamic Evaluation



Backus–Naur Form
Personal tools