SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Create Your Own Language
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
Why should we create
a new language?
Lisp
Javascript
XML
PHP
Python
Haskell
Erlang
Go Ruby
Java
CProlog
Scala
SQL
SQL
Elixir
C++
Rust
Perl
C# Objectiv-CSQL
There are lots of 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
So why should we create it?
Reason 1: Implementing a new idea
Reason 2: Solving a new problem
Reason 3: Mastering language concepts
Reason 4: Just for fun!
How can we create
a new language?
1. Designing
1.1. Identifying the problem
1.2. Planning the target platform/machine
1.3. Determining language category, paradigm, types, etc
2. Implementing Frontend
2.1. Lexical Scanning (Token Generating)

(example: lex, flex, leex, etc)
2.2. Syntax & Semantics Parsing (AST Generating)

(example: yacc, bison, yecc)
2.3. Preprocessing
2.4. Lint Analyzing
2.5. Generating Intermediate Language

(example: GCC IR, LLVM IR, BEAM Bytecode, Java Bytecode)
3. Implementing Backend
3.1. Analyzing Intermediate Language
3.2. Optimizing
3.3. Generating Machine Code
3.4. Evaluating and Executing
Lets look inside Erlang
compiler
– Holy Wikipedia
What is 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.”
Code Generation Steps
Erlang Source Code
Parse Transformed & Preprocessed Code (erlc -P)
Source Transformed Code (erlc -E)
Abstract Syntax Tree (erlc +dabstr)
Expanded Abstract Syntax Tree (erlc +dexp)
Core Erlang (erlc +to_core)
Assembler Code (erlc -S)
BEAM Bytecode (erlc)
Source Code
$ vim test.erl
Parse Transformed Code
$ erlc -P test.erl
Source Transformed Code
$ erlc -E test.erl
AST Code
$ erlc +dabstr test.erl
Expanded AST Code
$ erlc +dexp test.erl
Core Erlang Code
$ erlc +to_core test.erl
Assembler Code
$ erlc -S test.erl
BEAM Byte Code
$ erlc test.erl
Lets create a query language
for Tnesia
– https://github.com/bisphone/Tnesia
What is Tnesia?
“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.”
The Problem
It seems that its Erlang API looks strange to non-Erlang developer!
The Solution
Create a Query Language (TQL) that can be used over HTTP.
TQL Concepts
Syntax Types
Lexical Scanning
Using leex which is a Erlang lexer
Definitions Rules
Parsing
Non-terminals Terminals Rules
Using yecc which is an Erlang parser generator
Root-symbol
Evaluating
Evaluating AST in Erlang without any intermediate code generation
Question || Comment
- https://hamidreza-s.github.com

Weitere ähnliche Inhalte

Was ist angesagt?

An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...Claudio Capobianco
 
マーク&スイープ勉強会
マーク&スイープ勉強会マーク&スイープ勉強会
マーク&スイープ勉強会7shi
 
5 - Advanced SVE.pdf
5 - Advanced SVE.pdf5 - Advanced SVE.pdf
5 - Advanced SVE.pdfJunZhao68
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovZeroTurnaround
 
Deep drive into rust programming language
Deep drive into rust programming languageDeep drive into rust programming language
Deep drive into rust programming languageVigneshwer Dhinakaran
 
Rundown of Async/Await in Rust
Rundown of Async/Await in RustRundown of Async/Await in Rust
Rundown of Async/Await in RustKnoldus Inc.
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Wpfと非同期
Wpfと非同期Wpfと非同期
Wpfと非同期yone64
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiCysinfo Cyber Security Community
 

Was ist angesagt? (20)

Refactoring point of Kotlin application
Refactoring point of Kotlin applicationRefactoring point of Kotlin application
Refactoring point of Kotlin application
 
An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...
 
Perl Programming - 01 Basic Perl
Perl Programming - 01 Basic PerlPerl Programming - 01 Basic Perl
Perl Programming - 01 Basic Perl
 
マーク&スイープ勉強会
マーク&スイープ勉強会マーク&スイープ勉強会
マーク&スイープ勉強会
 
Why rust?
Why rust?Why rust?
Why rust?
 
5 - Advanced SVE.pdf
5 - Advanced SVE.pdf5 - Advanced SVE.pdf
5 - Advanced SVE.pdf
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir Ivanov
 
Linux Internals - Interview essentials 2.0
Linux Internals - Interview essentials 2.0Linux Internals - Interview essentials 2.0
Linux Internals - Interview essentials 2.0
 
淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道 淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道
 
Deep drive into rust programming language
Deep drive into rust programming languageDeep drive into rust programming language
Deep drive into rust programming language
 
Java Quiz Questions
Java Quiz QuestionsJava Quiz Questions
Java Quiz Questions
 
Rundown of Async/Await in Rust
Rundown of Async/Await in RustRundown of Async/Await in Rust
Rundown of Async/Await in Rust
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
file
filefile
file
 
Clean Code
Clean CodeClean Code
Clean Code
 
Wpfと非同期
Wpfと非同期Wpfと非同期
Wpfと非同期
 
Embedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile DevicesEmbedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile Devices
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
 
C# Async Await
C# Async AwaitC# Async Await
C# Async Await
 

Andere mochten auch

Real life XMPP Instant Messaging
Real life XMPP Instant MessagingReal life XMPP Instant Messaging
Real life XMPP Instant MessagingMickaël Rémond
 
Multi Chat
Multi ChatMulti Chat
Multi ChatSoftTeco
 
2015: L'année d'Elixir, Code, écosystème et communauté
2015: L'année d'Elixir, Code, écosystème et communauté2015: L'année d'Elixir, Code, écosystème et communauté
2015: L'année d'Elixir, Code, écosystème et communautéMickaël Rémond
 
Nanomsg - Scalable Networking Library
Nanomsg - Scalable Networking LibraryNanomsg - Scalable Networking Library
Nanomsg - Scalable Networking LibraryHamidreza Soleimani
 
ProcessOne Push Platform: XMPP-based Push Solutions
ProcessOne Push Platform: XMPP-based Push SolutionsProcessOne Push Platform: XMPP-based Push Solutions
ProcessOne Push Platform: XMPP-based Push SolutionsMickaël Rémond
 
Archipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF MeetupArchipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF MeetupMickaël Rémond
 
Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2Hamidreza Soleimani
 
Real time Web Application with XMPP and Wave
Real time Web Application with XMPP and WaveReal time Web Application with XMPP and Wave
Real time Web Application with XMPP and WaveMickaël Rémond
 
WaveOne server and client by ProcessOne
WaveOne server and client by ProcessOneWaveOne server and client by ProcessOne
WaveOne server and client by ProcessOneMickaël Rémond
 
Nodejs Applications in Production
Nodejs Applications in ProductionNodejs Applications in Production
Nodejs Applications in ProductionHamidreza Soleimani
 
Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Hamidreza Soleimani
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupMickaël Rémond
 
Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8
Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8 Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8
Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8 Mickaël Rémond
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPPJack Moffitt
 

Andere mochten auch (20)

Real life XMPP Instant Messaging
Real life XMPP Instant MessagingReal life XMPP Instant Messaging
Real life XMPP Instant Messaging
 
Multi Chat
Multi ChatMulti Chat
Multi Chat
 
Erlang White Label
Erlang White LabelErlang White Label
Erlang White Label
 
2015: L'année d'Elixir, Code, écosystème et communauté
2015: L'année d'Elixir, Code, écosystème et communauté2015: L'année d'Elixir, Code, écosystème et communauté
2015: L'année d'Elixir, Code, écosystème et communauté
 
Nanomsg - Scalable Networking Library
Nanomsg - Scalable Networking LibraryNanomsg - Scalable Networking Library
Nanomsg - Scalable Networking Library
 
ProcessOne Push Platform: XMPP-based Push Solutions
ProcessOne Push Platform: XMPP-based Push SolutionsProcessOne Push Platform: XMPP-based Push Solutions
ProcessOne Push Platform: XMPP-based Push Solutions
 
Archipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF MeetupArchipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF Meetup
 
Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 
Real time Web Application with XMPP and Wave
Real time Web Application with XMPP and WaveReal time Web Application with XMPP and Wave
Real time Web Application with XMPP and Wave
 
WaveOne server and client by ProcessOne
WaveOne server and client by ProcessOneWaveOne server and client by ProcessOne
WaveOne server and client by ProcessOne
 
Multitasking in iOS 7
Multitasking in iOS 7Multitasking in iOS 7
Multitasking in iOS 7
 
Nodejs Applications in Production
Nodejs Applications in ProductionNodejs Applications in Production
Nodejs Applications in Production
 
XMPP Academy #1
XMPP Academy #1XMPP Academy #1
XMPP Academy #1
 
Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1
 
Practical Look at Erlang
Practical Look at ErlangPractical Look at Erlang
Practical Look at Erlang
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF Meetup
 
Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8
Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8 Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8
Phoenix Presence: Le service temps réel de Phoenix - Paris.ex #8
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
 
What is XMPP Protocol
What is XMPP ProtocolWhat is XMPP Protocol
What is XMPP Protocol
 

Ähnlich wie Create Your Own Language

Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?mikaelbarbero
 
Introduction to perl_ a scripting language
Introduction to perl_ a scripting languageIntroduction to perl_ a scripting language
Introduction to perl_ a scripting languageVamshi Santhapuri
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Diving into Functional Programming
Diving into Functional ProgrammingDiving into Functional Programming
Diving into Functional ProgrammingLev Walkin
 
Лев Валкин — Программируем функционально
Лев Валкин — Программируем функциональноЛев Валкин — Программируем функционально
Лев Валкин — Программируем функциональноDaria Oreshkina
 
02-chapter-1.ppt
02-chapter-1.ppt02-chapter-1.ppt
02-chapter-1.pptJoel Manio
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?lichtkind
 
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"Olga Lavrentieva
 
Future of PERL in IT
Future of PERL in ITFuture of PERL in IT
Future of PERL in ITNexiilabs
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Espen Brækken
 
List of programming_languages_by_type
List of programming_languages_by_typeList of programming_languages_by_type
List of programming_languages_by_typePhoenix
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthingtonoscon2007
 
Concepts of JetBrains MPS
Concepts of JetBrains MPSConcepts of JetBrains MPS
Concepts of JetBrains MPSVaclav Pech
 

Ähnlich wie Create Your Own Language (20)

Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?
 
Introduction to perl_ a scripting language
Introduction to perl_ a scripting languageIntroduction to perl_ a scripting language
Introduction to perl_ a scripting language
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Diving into Functional Programming
Diving into Functional ProgrammingDiving into Functional Programming
Diving into Functional Programming
 
Лев Валкин — Программируем функционально
Лев Валкин — Программируем функциональноЛев Валкин — Программируем функционально
Лев Валкин — Программируем функционально
 
02-chapter-1.ppt
02-chapter-1.ppt02-chapter-1.ppt
02-chapter-1.ppt
 
Avro
AvroAvro
Avro
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
Elixir
ElixirElixir
Elixir
 
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
 
Microsoft .NET Framework
Microsoft .NET FrameworkMicrosoft .NET Framework
Microsoft .NET Framework
 
Future of PERL in IT
Future of PERL in ITFuture of PERL in IT
Future of PERL in IT
 
perl lauange
perl lauangeperl lauange
perl lauange
 
Pearl
PearlPearl
Pearl
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
 
Elixir introduction
Elixir introductionElixir introduction
Elixir introduction
 
List of programming_languages_by_type
List of programming_languages_by_typeList of programming_languages_by_type
List of programming_languages_by_type
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthington
 
Concepts of JetBrains MPS
Concepts of JetBrains MPSConcepts of JetBrains MPS
Concepts of JetBrains MPS
 

Mehr von Hamidreza Soleimani

Principles of Engineering Management | Hamidreza Soleimani | Diginext Academy
Principles of Engineering Management | Hamidreza Soleimani | Diginext AcademyPrinciples of Engineering Management | Hamidreza Soleimani | Diginext Academy
Principles of Engineering Management | Hamidreza Soleimani | Diginext AcademyHamidreza Soleimani
 
How to Scale Your Engineering Team | Hamidreza Soleimani | Diginext Academy
How to Scale Your Engineering Team | Hamidreza Soleimani | Diginext AcademyHow to Scale Your Engineering Team | Hamidreza Soleimani | Diginext Academy
How to Scale Your Engineering Team | Hamidreza Soleimani | Diginext AcademyHamidreza Soleimani
 
The World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext AcademyThe World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext AcademyHamidreza Soleimani
 
Technology Companies Development Story
Technology Companies Development StoryTechnology Companies Development Story
Technology Companies Development StoryHamidreza Soleimani
 
Do Reinvent the Wheel - Nov 2021 - DigiNext.pdf
Do Reinvent the Wheel - Nov 2021 - DigiNext.pdfDo Reinvent the Wheel - Nov 2021 - DigiNext.pdf
Do Reinvent the Wheel - Nov 2021 - DigiNext.pdfHamidreza Soleimani
 
BEAM (Erlang VM) as a Soft Real-time Platform
BEAM (Erlang VM) as a Soft Real-time PlatformBEAM (Erlang VM) as a Soft Real-time Platform
BEAM (Erlang VM) as a Soft Real-time PlatformHamidreza Soleimani
 

Mehr von Hamidreza Soleimani (6)

Principles of Engineering Management | Hamidreza Soleimani | Diginext Academy
Principles of Engineering Management | Hamidreza Soleimani | Diginext AcademyPrinciples of Engineering Management | Hamidreza Soleimani | Diginext Academy
Principles of Engineering Management | Hamidreza Soleimani | Diginext Academy
 
How to Scale Your Engineering Team | Hamidreza Soleimani | Diginext Academy
How to Scale Your Engineering Team | Hamidreza Soleimani | Diginext AcademyHow to Scale Your Engineering Team | Hamidreza Soleimani | Diginext Academy
How to Scale Your Engineering Team | Hamidreza Soleimani | Diginext Academy
 
The World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext AcademyThe World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext Academy
 
Technology Companies Development Story
Technology Companies Development StoryTechnology Companies Development Story
Technology Companies Development Story
 
Do Reinvent the Wheel - Nov 2021 - DigiNext.pdf
Do Reinvent the Wheel - Nov 2021 - DigiNext.pdfDo Reinvent the Wheel - Nov 2021 - DigiNext.pdf
Do Reinvent the Wheel - Nov 2021 - DigiNext.pdf
 
BEAM (Erlang VM) as a Soft Real-time Platform
BEAM (Erlang VM) as a Soft Real-time PlatformBEAM (Erlang VM) as a Soft Real-time Platform
BEAM (Erlang VM) as a Soft Real-time Platform
 

Kürzlich hochgeladen

result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 

Kürzlich hochgeladen (20)

result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 

Create Your Own Language

  • 1. Create Your Own Language 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 we create 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 lots of 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 should we create it? Reason 1: Implementing a new idea Reason 2: Solving a new problem Reason 3: Mastering language concepts Reason 4: Just for fun!
  • 5. How can we create a new language?
  • 6. 1. Designing 1.1. Identifying the problem 1.2. Planning the target platform/machine 1.3. Determining language category, paradigm, types, etc
  • 7. 2. Implementing Frontend 2.1. Lexical Scanning (Token Generating)
 (example: lex, flex, leex, etc) 2.2. Syntax & Semantics Parsing (AST Generating)
 (example: yacc, bison, yecc) 2.3. Preprocessing 2.4. Lint Analyzing 2.5. Generating Intermediate Language
 (example: GCC IR, LLVM IR, BEAM Bytecode, Java Bytecode)
  • 8. 3. Implementing Backend 3.1. Analyzing Intermediate Language 3.2. Optimizing 3.3. Generating Machine Code 3.4. Evaluating and Executing
  • 9. Lets look inside Erlang compiler
  • 10. – Holy Wikipedia What is 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.”
  • 11. Code Generation Steps Erlang Source Code Parse Transformed & Preprocessed Code (erlc -P) Source Transformed Code (erlc -E) Abstract Syntax Tree (erlc +dabstr) Expanded Abstract Syntax Tree (erlc +dexp) Core Erlang (erlc +to_core) Assembler Code (erlc -S) BEAM Bytecode (erlc)
  • 12. Source Code $ vim test.erl
  • 13. Parse Transformed Code $ erlc -P test.erl
  • 14. Source Transformed Code $ erlc -E test.erl
  • 15. AST Code $ erlc +dabstr test.erl
  • 16. Expanded AST Code $ erlc +dexp test.erl
  • 17. Core Erlang Code $ erlc +to_core test.erl
  • 18. Assembler Code $ erlc -S test.erl
  • 19. BEAM Byte Code $ erlc test.erl
  • 20. Lets create a query language for Tnesia
  • 21. – https://github.com/bisphone/Tnesia What is Tnesia? “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.”
  • 22. The Problem It seems that its Erlang API looks strange to non-Erlang developer!
  • 23. The Solution Create a Query Language (TQL) that can be used over HTTP.
  • 25. Lexical Scanning Using leex which is a Erlang lexer Definitions Rules
  • 26. Parsing Non-terminals Terminals Rules Using yecc which is an Erlang parser generator Root-symbol
  • 27. Evaluating Evaluating AST in Erlang without any intermediate code generation
  • 28. Question || Comment - https://hamidreza-s.github.com