SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
JOXA
A Full Featured Lisp on the Erlang VM
Monday, June 3, 13
How Compilers Work
-module(test).
-export([hello_world/0]).
hello_world() ->
io:format("Hello World").
Something Like This (That A Human Can Understand):
Monday, June 3, 13
How Compilers Work
Becomes Something Like This (That a Machine Can Understand):
00000b0 7453 5472 0000 0000 6d49 5470 0000 2800
00000c0 0000 0300 0000 0300 0000 0400 0000 0100
00000d0 0000 0600 0000 0700 0000 0100 0000 0600
00000e0 0000 0700 0000 0200 7845 5470 0000 2800
00000f0 0000 0300 0000 0500 0000 0100 0000 0600
0000100 0000 0500 0000 0000 0000 0400 0000 0200
0000110 0000 0000 0000 0200 694c 5474 0000 2300
0000120 0000 1700 9c78 6063 6060 6064 e060 ce6f
0000130 e066 48f6 c9cd 57c9 cf08 ca2f 0149 2700
0000140 0526 0026 6f4c 5463 0000 0400 0000 0000
0000150 7441 7274 0000 2800 6c83 0000 0100 0268
0000160 0064 7603 6e73 006c 0000 6e01 0010 b64a
0000170 6c18 9101 034d 1cdb 0854 48dc f414 6a6a
0000180 4943 666e 0000 a600 6c83 0000 0400 0268
0000190 0064 6f07 7470 6f69 736e 006c 0000 6801
00001a0 6402 0600 756f 6474 7269 006b 2f1d 6f68
00001b0 656d 652f 656d 7272 7469 2f74 6f77 6b72
Monday, June 3, 13
Compiler Passes
Source
Code
Scanner Parser
IR
Optimizer
Intermediate
Representation
(IR)
Semantic
Analyzer
Machine Code
Generator
Machine
Code
Monday, June 3, 13
Erlang Passes
Source
Code
Scanner Parser
Monday, June 3, 13
Erlang Passes
-module(test).
-export([hello_world/0]).
hello_world() ->
io:format("Hello World").
Start With This
Monday, June 3, 13
Erlang Passes
[{attribute,1,module,test},
{attribute,2,export,[{hello_world,0}]},
{function,2,hello_world,0,
[{clause,2,[],[],
[{call,3,
{remote,3,{atom,3,io},{atom,3,format}},
[{string,3,"Hello World"}]}]}]}]
And End With This:
Monday, June 3, 13
Erlang Passes
Core
Erlang
Erlang
ASM
Machine
Code
Monday, June 3, 13
Erlang Passes
Core Erlang:
{c_module,[],
{c_literal,[],test},
[{c_var,[],{hello_world,0}},
{c_var,[],{module_info,0}},
{c_var,[],{module_info,1}}],
[],
[{{c_var,[],{hello_world,0}},
{c_fun,[2,{file,[]}],
[],
{c_call,[3,{file,[]}],
{c_literal,[3,{file,[]}],io},
{c_literal,[3,{file,[]}],format},
[{c_literal,[3,{file,[]}],"Hello World"}]}}},
.......
Monday, June 3, 13
Erlang Passes
Erlang ASM:
{test,[{hello_world,0},{module_info,0},{module_info,1}],
[],
[{function,hello_world,0,2,
[{label,1},
{line,[{location,[],2}]},
{func_info,{atom,test},{atom,hello_world},0},
{label,2},
{move,{literal,"Hello World"},{x,0}},
{line,[{location,[],3}]},
{call_ext_only,1,{extfunc,io,format,1}}]},
{function,module_info,0,4,
[{label,3},
{line,[]},
{func_info,{atom,test},{atom,module_info},0},
{label,4},
{move,{atom,test},{x,0}},
{line,[]},
{call_ext_only,1,{extfunc,erlang,get_module_info,1}}]},
{function,module_info,1,6,
[{label,5},
{line,[]},
{func_info,{atom,test},{atom,module_info},1},
{label,6},
{move,{x,0},{x,1}},
{move,{atom,test},{x,0}},
{line,[]},
{call_ext_only,2,
{extfunc,erlang,get_module_info,...}}]}],
7}
Monday, June 3, 13
Erlang Passes
Erlang ASM:
{test,[{hello_world,0},{module_info,0},{module_info,1}],
[],
[{function,hello_world,0,2,
[{label,1},
{line,[{location,[],2}]},
{func_info,{atom,test},{atom,hello_world},0},
{label,2},
{move,{literal,"Hello World"},{x,0}},
{line,[{location,[],3}]},
{call_ext_only,1,{extfunc,io,format,1}}]},
{function,module_info,0,4,
[{label,3},
{line,[]},
{func_info,{atom,test},{atom,module_info},0},
{label,4},
{move,{atom,test},{x,0}},
{line,[]},
{call_ext_only,1,{extfunc,erlang,get_module_info,1}}]},
{function,module_info,1,6,
[{label,5},
{line,[]},
{func_info,{atom,test},{atom,module_info},1},
{label,6},
{move,{x,0},{x,1}},
{move,{atom,test},{x,0}},
{line,[]},
{call_ext_only,2,
{extfunc,erlang,get_module_info,...}}]}],
7}
Monday, June 3, 13
Erlang Passes
Machine Code
00000b0 7453 5472 0000 0000 6d49 5470 0000 2800
00000c0 0000 0300 0000 0300 0000 0400 0000 0100
00000d0 0000 0600 0000 0700 0000 0100 0000 0600
00000e0 0000 0700 0000 0200 7845 5470 0000 2800
00000f0 0000 0300 0000 0500 0000 0100 0000 0600
0000100 0000 0500 0000 0000 0000 0400 0000 0200
0000110 0000 0000 0000 0200 694c 5474 0000 2300
0000120 0000 1700 9c78 6063 6060 6064 e060 ce6f
0000130 e066 48f6 c9cd 57c9 cf08 ca2f 0149 2700
0000140 0526 0026 6f4c 5463 0000 0400 0000 0000
0000150 7441 7274 0000 2800 6c83 0000 0100 0268
0000160 0064 7603 6e73 006c 0000 6e01 0010 b64a
0000170 6c18 9101 034d 1cdb 0854 48dc f414 6a6a
0000180 4943 666e 0000 a600 6c83 0000 0400 0268
0000190 0064 6f07 7470 6f69 736e 006c 0000 6801
00001a0 6402 0600 756f 6474 7269 006b 2f1d 6f68
00001b0 656d 652f 656d 7272 7469 2f74 6f77 6b72
Monday, June 3, 13
Core Erlang
Designed as a ‘target language’ for compilers
Strict, higher-order functional language with clear and simple
semantics
Should be as regular as possible to facilitate development of code
walking tools
Translation from Erlang to Core Erlang should be as
straightforward
Should have a human readable textual representation
Monday, June 3, 13
Core - The Language Designer
Erlang compiles to core erlang!
Almost all the optimizations and error checking are in the core
Erlang passes!
Core Erlang as a nice ast building module in cerl.erl
Its easy to target!
Monday, June 3, 13
Erlang & Core Erlang
-module(test).
-export([hello_world/0]).
hello_world() ->
io:format("Hello World").
module 'test' ['hello_world'/0]
attributes []
'hello_world'/0 =
fun () ->
call 'io':'format'
(“Hello World”)
Erlang: Core Erlang:
Monday, June 3, 13
Erlang & Core Erlang AST
Erlang: Core Erlang:
[{attribute,1,module,test},
{attribute,2,export,[{hello_world,0}]},
{function,2,hello_world,0,
[{clause,2,[],[],
[{call,3,
{remote,3,{atom,3,io},{atom,3,format}},
[{string,3,"Hello World"}]}]}]}]
{c_module,[],
{c_literal,[],test},
[{c_var,[],{hello_world,0}}],
[],
[{{c_var,[],{hello_world,0}},
{c_fun,[2,{file,[]}],
[],
{c_call,[3,{file,[]}],
{c_literal,[3,{file,[]}],io},
{c_literal,[3,{file,[]}],format},
[{c_literal,[3,{file,[]}],
"Hello World"}]}}},
Monday, June 3, 13
Joxa & Core Erlang
(ns test
(require io))
(defn+ hello-world ()
(io/format “Hello World”))
module 'test' ['hello-world'/0]
attributes []
'hello-world'/0 =
fun () ->
call 'io':'format'
(“Hello World”)
Joxa: Core Erlang:
Monday, June 3, 13
Joxa & Core Erlang AST
Joxa: Core Erlang:
[ns, test,
[require, io]]
[{fun, ‘hello-world’, 0},
[]
[{fun, io, format}
[[H e l l o  W o r
l d]]]
{c_module,[],
{c_literal,[],test},
[{c_var,[],{hello_world,0}}],
[],
[{{c_var,[],{hello_world,0}},
{c_fun,[2,{file,[]}],
[],
{c_call,[3,{file,[]}],
{c_literal,[3,{file,[]}],io},
{c_literal,[3,{file,[]}],format},
[{c_literal,[3,{file,[]}],
"Hello World"}]}}},
Monday, June 3, 13
Joxa Passes
Source
Code
PEG Based
Scanner
Joxa AST
Core
Erlang
Erlang
ASM
Machine
Code
Monday, June 3, 13
What is Joxa
Designed as a Simple, Functional, Lisp (though not as a
Common Lisp)
Designed to be a general purpose, usable language in its own
right
Also designed to be a platform for DSLs
Monday, June 3, 13
What is Joxa’s Status
Still many features we want to implement
Better Joxa Layer Warnings
More metadata (apropo, live arguments)
Support for Slime + Swank
Production Quality
Monday, June 3, 13
A Quick Introduction
(ns sieve-of-eratosthenes
(require (lists :joxify)
(io :joxify))
(use (joxa-core :as core :only (!=/2))
(erlang :only (rem/2 +/2))))
(defn sieve (v primes)
(case v
([] primes)
((h . t)
(sieve (lists/filter (fn (x)
(!= (rem x h) 0)) t)
(+ primes 1)))))
(defn+ sieve (v)
(sieve (lists/seq 2 v) 1))
Monday, June 3, 13
A Quick Intro - Macros
(defmacro+ and (&rest args)
(case args
([x y]
`(erlang/and ~x ~y))
((a . b)
`(erlang/and ~a (joxa-core/and ~@b)))
(arg
arg)))
(defmacro+ or (&rest args)
(case args
([x y]
`(erlang/or ~x ~y))
((a . b)
`(erlang/or ~a (joxa-core/and ~@b)))
(arg
arg)))
Monday, June 3, 13
;; Apply the body to every item in the list. The 'value' part of an
;; expression may be a pattern. If the pattern does not match then
;; the non-matching element is skipped
;; Without Guard
;; (dolist (x (lists/seq 0 1)) (+ x 1))
;; With Guard
;; (dolist (x (when (> x 1)) (lists/seq 0 10)) (+ x 1))
;;
(defmacro+ dolist (binding &rest body)
(case binding
([val items]
(let* (arg (joxa-core/gensym "doseq"))
`(lists/foreach
(fn (~arg)
(case ~arg
~@(if (needs-catchall? val)
[`(~val
~@body) `(_ :ok)]
[`(~val
~@body)]))) ~items)))
([val guard items]
(let* (arg (joxa-core/gensym "dolist"))
`(lists/foreach
(fn (~arg)
(case ~arg
(~val ~guard
~@body)
(_ :ok))) ~items)))
(invalid
(erlang/error {:invalid-binding invalid }))))
Monday, June 3, 13
;; Apply the body to every item in the list. The 'value' part of an
;; expression may be a pattern. If the pattern does not match then
;; the non-matching element is skipped, The result of each body is
;; cated to the list and returned as a new list
;; Without Guard
;; (joxa-lists/map (x (lists/seq 0 1)) (+ x 1))
;; With Guard
;; (joxa-lists/map (x (> x 1) (lists/seq 0 10)) (+ x 1))
(defmacro+ map (binding &rest body)
(let* (catcher (joxa-core/gensym "map")
acc-sym (joxa-core/gensym "map")
arg (joxa-core/gensym "map")
body-gen <BODY GEN SEE ->
(case (body-gen binding)
({fun-body items}
`(lists/reverse
(lists/foldl
(fn (~arg ~acc-sym)
~fun-body) [] ~items))))))
BODY GEN:
(fn (binding1)
(case binding1
([val items]
{`(case ~arg
~@(if (needs-catchall? val)
[`(~val
((do ~@body) . ~acc-sym))
`(_ ~acc-sym)]
[`(~val
((do ~@body) . ~acc-sym))])) items})
([val guard items]
{`(case ~arg
~@(if (needs-catchall? val)
[`(~val
(case ~guard
(:true ((do ~@body) . ~acc-sym))
(:false ~acc-sym))
((do ~@body) . ~acc-sym))
`(_ ~acc-sym)]
[`(~val
(case ~guard
(:true ((do ~@body) . ~acc-sym))
(:false ~acc-sym)))])) items})
(invalid
(erlang/error {:invalid-binding invalid })))))
Monday, June 3, 13
Records
Provide a unit of abstraction around Erlang’s record syntax
Getters, Setters, Pattern Decomposition Generated
Much, Much prettier then Erlang Records
Monday, June 3, 13
More Information
http://joxa.org/
http://docs.joxa.org
https://groups.google.com/group/erlware-questions
irc://irc.freenode.net/joxa (#joxa on freenode)
Monday, June 3, 13

Mais conteúdo relacionado

Mais procurados

JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the ASTJarrod Overson
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...Haris Mahmood
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersFITC
 
Home Automation with Android Things and the Google Assistant
Home Automation with Android Things and the Google AssistantHome Automation with Android Things and the Google Assistant
Home Automation with Android Things and the Google AssistantNilhcem
 
The Ring programming language version 1.3 book - Part 64 of 88
The Ring programming language version 1.3 book - Part 64 of 88The Ring programming language version 1.3 book - Part 64 of 88
The Ring programming language version 1.3 book - Part 64 of 88Mahmoud Samir Fayed
 
Down the rabbit hole, profiling in Django
Down the rabbit hole, profiling in DjangoDown the rabbit hole, profiling in Django
Down the rabbit hole, profiling in DjangoRemco Wendt
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 
Slaying the Dragon: Implementing a Programming Language in Ruby
Slaying the Dragon: Implementing a Programming Language in RubySlaying the Dragon: Implementing a Programming Language in Ruby
Slaying the Dragon: Implementing a Programming Language in RubyJason Yeo Jie Shun
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Damien Seguy
 

Mais procurados (13)

JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
 
Home Automation with Android Things and the Google Assistant
Home Automation with Android Things and the Google AssistantHome Automation with Android Things and the Google Assistant
Home Automation with Android Things and the Google Assistant
 
The Ring programming language version 1.3 book - Part 64 of 88
The Ring programming language version 1.3 book - Part 64 of 88The Ring programming language version 1.3 book - Part 64 of 88
The Ring programming language version 1.3 book - Part 64 of 88
 
Down the rabbit hole, profiling in Django
Down the rabbit hole, profiling in DjangoDown the rabbit hole, profiling in Django
Down the rabbit hole, profiling in Django
 
Introduccion a Jasmin
Introduccion a JasminIntroduccion a Jasmin
Introduccion a Jasmin
 
ZIO Queue
ZIO QueueZIO Queue
ZIO Queue
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
WebXR if X = how?
WebXR if X = how?WebXR if X = how?
WebXR if X = how?
 
I Love Ruby
I Love RubyI Love Ruby
I Love Ruby
 
Slaying the Dragon: Implementing a Programming Language in Ruby
Slaying the Dragon: Implementing a Programming Language in RubySlaying the Dragon: Implementing a Programming Language in Ruby
Slaying the Dragon: Implementing a Programming Language in Ruby
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)
 

Destaque

Ross Golden Exam Review
Ross Golden Exam Review Ross Golden Exam Review
Ross Golden Exam Review rossg0711
 
Yin Yang Of Financial Reform
Yin Yang Of Financial ReformYin Yang Of Financial Reform
Yin Yang Of Financial Reformhubert_laird
 
Behaviours and Applications
Behaviours and ApplicationsBehaviours and Applications
Behaviours and Applicationsericbmerritt
 
4 trends presentation website final
4 trends presentation   website final4 trends presentation   website final
4 trends presentation website finalblondie78250
 
Thiet kecsdl
 Thiet kecsdl Thiet kecsdl
Thiet kecsdlnonachan
 
Solving The Innovation Puzzle
Solving The Innovation PuzzleSolving The Innovation Puzzle
Solving The Innovation Puzzlehubert_laird
 

Destaque (7)

Ross Golden Exam Review
Ross Golden Exam Review Ross Golden Exam Review
Ross Golden Exam Review
 
Yin Yang Of Financial Reform
Yin Yang Of Financial ReformYin Yang Of Financial Reform
Yin Yang Of Financial Reform
 
Behaviours and Applications
Behaviours and ApplicationsBehaviours and Applications
Behaviours and Applications
 
4 trends presentation website final
4 trends presentation   website final4 trends presentation   website final
4 trends presentation website final
 
Ch1
Ch1Ch1
Ch1
 
Thiet kecsdl
 Thiet kecsdl Thiet kecsdl
Thiet kecsdl
 
Solving The Innovation Puzzle
Solving The Innovation PuzzleSolving The Innovation Puzzle
Solving The Innovation Puzzle
 

Semelhante a 20120822 joxa

Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189Mahmoud Samir Fayed
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowKrzysztof Szafranek
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageWayne Tsai
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLConnor McDonald
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
Internet of Things Magic Show
Internet of Things Magic ShowInternet of Things Magic Show
Internet of Things Magic ShowStephen Chin
 
Introduction to Debuggers
Introduction to DebuggersIntroduction to Debuggers
Introduction to DebuggersSaumil Shah
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupBadoo Development
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is HumanAlex Liu
 
Java bytecode Malware Analysis
Java bytecode Malware AnalysisJava bytecode Malware Analysis
Java bytecode Malware AnalysisBrian Baskin
 
Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013
Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013
Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013Amazon Web Services
 
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_ЯндексеТанки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_ЯндексеYandex
 
Shibuyajs Digest
Shibuyajs DigestShibuyajs Digest
Shibuyajs Digesttakesako
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMsunng87
 

Semelhante a 20120822 joxa (20)

CompilersAndLibraries
CompilersAndLibrariesCompilersAndLibraries
CompilersAndLibraries
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Groovy
GroovyGroovy
Groovy
 
The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usage
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQL
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Internet of Things Magic Show
Internet of Things Magic ShowInternet of Things Magic Show
Internet of Things Magic Show
 
Introduction to Debuggers
Introduction to DebuggersIntroduction to Debuggers
Introduction to Debuggers
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
 
To Err Is Human
To Err Is HumanTo Err Is Human
To Err Is Human
 
Eta
EtaEta
Eta
 
Java bytecode Malware Analysis
Java bytecode Malware AnalysisJava bytecode Malware Analysis
Java bytecode Malware Analysis
 
Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013
Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013
Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013
 
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_ЯндексеТанки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
 
Shibuyajs Digest
Shibuyajs DigestShibuyajs Digest
Shibuyajs Digest
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVM
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 

Último

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Último (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

20120822 joxa

  • 1. JOXA A Full Featured Lisp on the Erlang VM Monday, June 3, 13
  • 2. How Compilers Work -module(test). -export([hello_world/0]). hello_world() -> io:format("Hello World"). Something Like This (That A Human Can Understand): Monday, June 3, 13
  • 3. How Compilers Work Becomes Something Like This (That a Machine Can Understand): 00000b0 7453 5472 0000 0000 6d49 5470 0000 2800 00000c0 0000 0300 0000 0300 0000 0400 0000 0100 00000d0 0000 0600 0000 0700 0000 0100 0000 0600 00000e0 0000 0700 0000 0200 7845 5470 0000 2800 00000f0 0000 0300 0000 0500 0000 0100 0000 0600 0000100 0000 0500 0000 0000 0000 0400 0000 0200 0000110 0000 0000 0000 0200 694c 5474 0000 2300 0000120 0000 1700 9c78 6063 6060 6064 e060 ce6f 0000130 e066 48f6 c9cd 57c9 cf08 ca2f 0149 2700 0000140 0526 0026 6f4c 5463 0000 0400 0000 0000 0000150 7441 7274 0000 2800 6c83 0000 0100 0268 0000160 0064 7603 6e73 006c 0000 6e01 0010 b64a 0000170 6c18 9101 034d 1cdb 0854 48dc f414 6a6a 0000180 4943 666e 0000 a600 6c83 0000 0400 0268 0000190 0064 6f07 7470 6f69 736e 006c 0000 6801 00001a0 6402 0600 756f 6474 7269 006b 2f1d 6f68 00001b0 656d 652f 656d 7272 7469 2f74 6f77 6b72 Monday, June 3, 13
  • 10. Erlang Passes Erlang ASM: {test,[{hello_world,0},{module_info,0},{module_info,1}], [], [{function,hello_world,0,2, [{label,1}, {line,[{location,[],2}]}, {func_info,{atom,test},{atom,hello_world},0}, {label,2}, {move,{literal,"Hello World"},{x,0}}, {line,[{location,[],3}]}, {call_ext_only,1,{extfunc,io,format,1}}]}, {function,module_info,0,4, [{label,3}, {line,[]}, {func_info,{atom,test},{atom,module_info},0}, {label,4}, {move,{atom,test},{x,0}}, {line,[]}, {call_ext_only,1,{extfunc,erlang,get_module_info,1}}]}, {function,module_info,1,6, [{label,5}, {line,[]}, {func_info,{atom,test},{atom,module_info},1}, {label,6}, {move,{x,0},{x,1}}, {move,{atom,test},{x,0}}, {line,[]}, {call_ext_only,2, {extfunc,erlang,get_module_info,...}}]}], 7} Monday, June 3, 13
  • 11. Erlang Passes Erlang ASM: {test,[{hello_world,0},{module_info,0},{module_info,1}], [], [{function,hello_world,0,2, [{label,1}, {line,[{location,[],2}]}, {func_info,{atom,test},{atom,hello_world},0}, {label,2}, {move,{literal,"Hello World"},{x,0}}, {line,[{location,[],3}]}, {call_ext_only,1,{extfunc,io,format,1}}]}, {function,module_info,0,4, [{label,3}, {line,[]}, {func_info,{atom,test},{atom,module_info},0}, {label,4}, {move,{atom,test},{x,0}}, {line,[]}, {call_ext_only,1,{extfunc,erlang,get_module_info,1}}]}, {function,module_info,1,6, [{label,5}, {line,[]}, {func_info,{atom,test},{atom,module_info},1}, {label,6}, {move,{x,0},{x,1}}, {move,{atom,test},{x,0}}, {line,[]}, {call_ext_only,2, {extfunc,erlang,get_module_info,...}}]}], 7} Monday, June 3, 13
  • 12. Erlang Passes Machine Code 00000b0 7453 5472 0000 0000 6d49 5470 0000 2800 00000c0 0000 0300 0000 0300 0000 0400 0000 0100 00000d0 0000 0600 0000 0700 0000 0100 0000 0600 00000e0 0000 0700 0000 0200 7845 5470 0000 2800 00000f0 0000 0300 0000 0500 0000 0100 0000 0600 0000100 0000 0500 0000 0000 0000 0400 0000 0200 0000110 0000 0000 0000 0200 694c 5474 0000 2300 0000120 0000 1700 9c78 6063 6060 6064 e060 ce6f 0000130 e066 48f6 c9cd 57c9 cf08 ca2f 0149 2700 0000140 0526 0026 6f4c 5463 0000 0400 0000 0000 0000150 7441 7274 0000 2800 6c83 0000 0100 0268 0000160 0064 7603 6e73 006c 0000 6e01 0010 b64a 0000170 6c18 9101 034d 1cdb 0854 48dc f414 6a6a 0000180 4943 666e 0000 a600 6c83 0000 0400 0268 0000190 0064 6f07 7470 6f69 736e 006c 0000 6801 00001a0 6402 0600 756f 6474 7269 006b 2f1d 6f68 00001b0 656d 652f 656d 7272 7469 2f74 6f77 6b72 Monday, June 3, 13
  • 13. Core Erlang Designed as a ‘target language’ for compilers Strict, higher-order functional language with clear and simple semantics Should be as regular as possible to facilitate development of code walking tools Translation from Erlang to Core Erlang should be as straightforward Should have a human readable textual representation Monday, June 3, 13
  • 14. Core - The Language Designer Erlang compiles to core erlang! Almost all the optimizations and error checking are in the core Erlang passes! Core Erlang as a nice ast building module in cerl.erl Its easy to target! Monday, June 3, 13
  • 15. Erlang & Core Erlang -module(test). -export([hello_world/0]). hello_world() -> io:format("Hello World"). module 'test' ['hello_world'/0] attributes [] 'hello_world'/0 = fun () -> call 'io':'format' (“Hello World”) Erlang: Core Erlang: Monday, June 3, 13
  • 16. Erlang & Core Erlang AST Erlang: Core Erlang: [{attribute,1,module,test}, {attribute,2,export,[{hello_world,0}]}, {function,2,hello_world,0, [{clause,2,[],[], [{call,3, {remote,3,{atom,3,io},{atom,3,format}}, [{string,3,"Hello World"}]}]}]}] {c_module,[], {c_literal,[],test}, [{c_var,[],{hello_world,0}}], [], [{{c_var,[],{hello_world,0}}, {c_fun,[2,{file,[]}], [], {c_call,[3,{file,[]}], {c_literal,[3,{file,[]}],io}, {c_literal,[3,{file,[]}],format}, [{c_literal,[3,{file,[]}], "Hello World"}]}}}, Monday, June 3, 13
  • 17. Joxa & Core Erlang (ns test (require io)) (defn+ hello-world () (io/format “Hello World”)) module 'test' ['hello-world'/0] attributes [] 'hello-world'/0 = fun () -> call 'io':'format' (“Hello World”) Joxa: Core Erlang: Monday, June 3, 13
  • 18. Joxa & Core Erlang AST Joxa: Core Erlang: [ns, test, [require, io]] [{fun, ‘hello-world’, 0}, [] [{fun, io, format} [[H e l l o W o r l d]]] {c_module,[], {c_literal,[],test}, [{c_var,[],{hello_world,0}}], [], [{{c_var,[],{hello_world,0}}, {c_fun,[2,{file,[]}], [], {c_call,[3,{file,[]}], {c_literal,[3,{file,[]}],io}, {c_literal,[3,{file,[]}],format}, [{c_literal,[3,{file,[]}], "Hello World"}]}}}, Monday, June 3, 13
  • 19. Joxa Passes Source Code PEG Based Scanner Joxa AST Core Erlang Erlang ASM Machine Code Monday, June 3, 13
  • 20. What is Joxa Designed as a Simple, Functional, Lisp (though not as a Common Lisp) Designed to be a general purpose, usable language in its own right Also designed to be a platform for DSLs Monday, June 3, 13
  • 21. What is Joxa’s Status Still many features we want to implement Better Joxa Layer Warnings More metadata (apropo, live arguments) Support for Slime + Swank Production Quality Monday, June 3, 13
  • 22. A Quick Introduction (ns sieve-of-eratosthenes (require (lists :joxify) (io :joxify)) (use (joxa-core :as core :only (!=/2)) (erlang :only (rem/2 +/2)))) (defn sieve (v primes) (case v ([] primes) ((h . t) (sieve (lists/filter (fn (x) (!= (rem x h) 0)) t) (+ primes 1))))) (defn+ sieve (v) (sieve (lists/seq 2 v) 1)) Monday, June 3, 13
  • 23. A Quick Intro - Macros (defmacro+ and (&rest args) (case args ([x y] `(erlang/and ~x ~y)) ((a . b) `(erlang/and ~a (joxa-core/and ~@b))) (arg arg))) (defmacro+ or (&rest args) (case args ([x y] `(erlang/or ~x ~y)) ((a . b) `(erlang/or ~a (joxa-core/and ~@b))) (arg arg))) Monday, June 3, 13
  • 24. ;; Apply the body to every item in the list. The 'value' part of an ;; expression may be a pattern. If the pattern does not match then ;; the non-matching element is skipped ;; Without Guard ;; (dolist (x (lists/seq 0 1)) (+ x 1)) ;; With Guard ;; (dolist (x (when (> x 1)) (lists/seq 0 10)) (+ x 1)) ;; (defmacro+ dolist (binding &rest body) (case binding ([val items] (let* (arg (joxa-core/gensym "doseq")) `(lists/foreach (fn (~arg) (case ~arg ~@(if (needs-catchall? val) [`(~val ~@body) `(_ :ok)] [`(~val ~@body)]))) ~items))) ([val guard items] (let* (arg (joxa-core/gensym "dolist")) `(lists/foreach (fn (~arg) (case ~arg (~val ~guard ~@body) (_ :ok))) ~items))) (invalid (erlang/error {:invalid-binding invalid })))) Monday, June 3, 13
  • 25. ;; Apply the body to every item in the list. The 'value' part of an ;; expression may be a pattern. If the pattern does not match then ;; the non-matching element is skipped, The result of each body is ;; cated to the list and returned as a new list ;; Without Guard ;; (joxa-lists/map (x (lists/seq 0 1)) (+ x 1)) ;; With Guard ;; (joxa-lists/map (x (> x 1) (lists/seq 0 10)) (+ x 1)) (defmacro+ map (binding &rest body) (let* (catcher (joxa-core/gensym "map") acc-sym (joxa-core/gensym "map") arg (joxa-core/gensym "map") body-gen <BODY GEN SEE -> (case (body-gen binding) ({fun-body items} `(lists/reverse (lists/foldl (fn (~arg ~acc-sym) ~fun-body) [] ~items)))))) BODY GEN: (fn (binding1) (case binding1 ([val items] {`(case ~arg ~@(if (needs-catchall? val) [`(~val ((do ~@body) . ~acc-sym)) `(_ ~acc-sym)] [`(~val ((do ~@body) . ~acc-sym))])) items}) ([val guard items] {`(case ~arg ~@(if (needs-catchall? val) [`(~val (case ~guard (:true ((do ~@body) . ~acc-sym)) (:false ~acc-sym)) ((do ~@body) . ~acc-sym)) `(_ ~acc-sym)] [`(~val (case ~guard (:true ((do ~@body) . ~acc-sym)) (:false ~acc-sym)))])) items}) (invalid (erlang/error {:invalid-binding invalid }))))) Monday, June 3, 13
  • 26. Records Provide a unit of abstraction around Erlang’s record syntax Getters, Setters, Pattern Decomposition Generated Much, Much prettier then Erlang Records Monday, June 3, 13