SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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)
 

Destacado

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
 

Destacado (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
 

Similar 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
 

Similar 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

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

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