The document discusses creating a new programming language by implementing it on top of the Erlang Virtual Machine (BEAM). It describes the steps to design and implement a language frontend by parsing source code into an abstract syntax tree and generating bytecode. As an example, it outlines how to create a query language called TQL for the Tnesia time-series database by defining a syntax, using Erlang tools for lexical scanning and parsing, and directly evaluating the parsed syntax tree.
Introduction to language creation, highlighting examples of existing languages and reasons to create a new one like implementing new ideas, solving problems, or for fun.
Steps to create a new language including design (identifying problems), frontend implementation (token generation), and backend actions (code generation and execution).
Introduction to Erlang language, its features, and code generation steps from source code to BEAM Bytecode.
Demonstrations of different stages of Erlang code processing through command-line examples from parsing to generating BEAM bytecode.
Introduction of Tnesia, a time-series data storage, the problem with its API, and the concept of creating a query language TQL for better usability.
Detailed processes in implementing TQL including lexical scanning, parsing rules, and evaluating the Abstract Syntax Tree in Erlang.
Invitation for questions or comments regarding the presentation and topics discussed.
Create Your OwnLanguage
How to implement a language on top of
Erlang Virtual Machine (BEAM)
Hamidreza Soleimani
Backend Developer / Architect @ BisPhone
Tehran Linux User Group
August 6, 2015
2.
Why should wecreate
a new language?
Lisp
Javascript
XML
PHP
Python
Haskell
Erlang
Go Ruby
Java
CProlog
Scala
SQL
SQL
Elixir
C++
Rust
Perl
C# Objectiv-CSQL
3.
There are lotsof Languages!
By category:
Programming, Query, Domain Specific, etc
By Paradigm:
Imperative, Declarative (Logic, Functional), Structured (Object
Oriented, Modular), etc
By Implementation:
Compiled, Interpreted, Mixed, etc
By Type System:
Static, Dynamic, Strong, Weak, etc
4.
So why shouldwe create it?
Reason 1: Implementing a new idea
Reason 2: Solving a new problem
Reason 3: Mastering language concepts
Reason 4: Just for fun!
– Holy Wikipedia
Whatis Erlang?
“Erlang is a general-purpose, functional, concurrent,
garbage-collected programming language and
runtime system, with eager evaluation, single
assignment, and dynamic typing. It was originally
designed by Ericsson to support distributed, fault-
tolerant, soft real-time, highly available, non-stop
applications. It supports hot swapping, so that code
can be changed without stopping a system.”
– https://github.com/bisphone/Tnesia
What isTnesia?
“Tnesia is a time-series data storage which lets you
run time-based queries on a large amount of data,
without scanning the whole set of data, and in a
key-value manner. It can be used embedded inside
an Erlang application, or stand-alone with HTTP
interface to outside which talks in a simple query
language called TQL.”