ATS language overview

6,227 views

Published on

ATS language overview
https://github.com/master-q/masterq-docs/blob/master/presentations/20150913_fpmeetup/20150913_fpmeetup.md

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,227
On SlideShare
0
From Embeds
0
Number of Embeds
4,570
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

ATS language overview

  1. 1. ATS language overviewATS language overviewATS language overviewATS language overviewATS language overview Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
  2. 2. Remember Heartbleed bug?Remember Heartbleed bug?Remember Heartbleed bug?Remember Heartbleed bug?Remember Heartbleed bug? Should we use safer language than C?Should we use safer language than C?Should we use safer language than C?Should we use safer language than C?Should we use safer language than C? == In English == "Preventing heartbleed bugs with safe programming languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs- with-safe-languages.html == In Japanease == "安全なプログラミング言語を使って heartbleed を防ぐには" https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md == In English == "Preventing heartbleed bugs with safe programming languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs- with-safe-languages.html == In Japanease == "安全なプログラミング言語を使って heartbleed を防ぐには" https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md == In English == "Preventing heartbleed bugs with safe programming languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs- with-safe-languages.html == In Japanease == "安全なプログラミング言語を使って heartbleed を防ぐには" https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md == In English == "Preventing heartbleed bugs with safe programming languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs- with-safe-languages.html == In Japanease == "安全なプログラミング言語を使って heartbleed を防ぐには" https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md == In English == "Preventing heartbleed bugs with safe programming languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs- with-safe-languages.html == In Japanease == "安全なプログラミング言語を使って heartbleed を防ぐには" https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe- languages.md "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug." "A safer systems programming language could have prevented the bug."
  3. 3. What is ATS?What is ATS?What is ATS?What is ATS?What is ATS? ☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/☆ http://www.ats-lang.org/ ☆ Syntax like ML☆ Syntax like ML☆ Syntax like ML☆ Syntax like ML☆ Syntax like ML ☆ DML-style dependent types☆ DML-style dependent types☆ DML-style dependent types☆ DML-style dependent types☆ DML-style dependent types ☆ Linear types☆ Linear types☆ Linear types☆ Linear types☆ Linear types ☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC☆ Optional GC ☆ Optional malloc/free☆ Optional malloc/free☆ Optional malloc/free☆ Optional malloc/free☆ Optional malloc/free ☆ Optional run-time☆ Optional run-time☆ Optional run-time☆ Optional run-time☆ Optional run-time
  4. 4. Author: Hongwei XiAuthor: Hongwei XiAuthor: Hongwei XiAuthor: Hongwei XiAuthor: Hongwei Xi
  5. 5. Fizzbuzz on Standard MLFizzbuzz on Standard MLFizzbuzz on Standard MLFizzbuzz on Standard MLFizzbuzz on Standard ML (* http://rosettacode.org/wiki/FizzBuzz#Standard_ML *) local fun fbstr i = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => Int.toString i fun fizzbuzz' (n, j) = if n = j then () else (print (fbstr j ^ "n"); fizzbuzz' (n, j+1)) in fun fizzbuzz n = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end (* http://rosettacode.org/wiki/FizzBuzz#Standard_ML *) local fun fbstr i = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => Int.toString i fun fizzbuzz' (n, j) = if n = j then () else (print (fbstr j ^ "n"); fizzbuzz' (n, j+1)) in fun fizzbuzz n = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end (* http://rosettacode.org/wiki/FizzBuzz#Standard_ML *) local fun fbstr i = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => Int.toString i fun fizzbuzz' (n, j) = if n = j then () else (print (fbstr j ^ "n"); fizzbuzz' (n, j+1)) in fun fizzbuzz n = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end (* http://rosettacode.org/wiki/FizzBuzz#Standard_ML *) local fun fbstr i = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => Int.toString i fun fizzbuzz' (n, j) = if n = j then () else (print (fbstr j ^ "n"); fizzbuzz' (n, j+1)) in fun fizzbuzz n = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end (* http://rosettacode.org/wiki/FizzBuzz#Standard_ML *) local fun fbstr i = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => Int.toString i fun fizzbuzz' (n, j) = if n = j then () else (print (fbstr j ^ "n"); fizzbuzz' (n, j+1)) in fun fizzbuzz n = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end
  6. 6. Fizzbuzz on ATSFizzbuzz on ATSFizzbuzz on ATSFizzbuzz on ATSFizzbuzz on ATS #include "share/atspre_define.hats" #include "share/atspre_staload.hats" local fun fbstr (i:int): string = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => tostring_int i fun fizzbuzz' (n:int, j:int): void = if n = j then () else (println! (fbstr j); fizzbuzz' (n, j+1)) in fun fizzbuzz (n:int): void = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end implement main0 () = () #include "share/atspre_define.hats" #include "share/atspre_staload.hats" local fun fbstr (i:int): string = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => tostring_int i fun fizzbuzz' (n:int, j:int): void = if n = j then () else (println! (fbstr j); fizzbuzz' (n, j+1)) in fun fizzbuzz (n:int): void = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end implement main0 () = () #include "share/atspre_define.hats" #include "share/atspre_staload.hats" local fun fbstr (i:int): string = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => tostring_int i fun fizzbuzz' (n:int, j:int): void = if n = j then () else (println! (fbstr j); fizzbuzz' (n, j+1)) in fun fizzbuzz (n:int): void = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end implement main0 () = () #include "share/atspre_define.hats" #include "share/atspre_staload.hats" local fun fbstr (i:int): string = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => tostring_int i fun fizzbuzz' (n:int, j:int): void = if n = j then () else (println! (fbstr j); fizzbuzz' (n, j+1)) in fun fizzbuzz (n:int): void = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end implement main0 () = () #include "share/atspre_define.hats" #include "share/atspre_staload.hats" local fun fbstr (i:int): string = case (i mod 3 = 0, i mod 5 = 0) of (true , true ) => "FizzBuzz" | (true , false) => "Fizz" | (false, true ) => "Buzz" | (false, false) => tostring_int i fun fizzbuzz' (n:int, j:int): void = if n = j then () else (println! (fbstr j); fizzbuzz' (n, j+1)) in fun fizzbuzz (n:int): void = fizzbuzz' (n, 1) val _ = fizzbuzz 100 end implement main0 () = ()
  7. 7. How to compile itHow to compile itHow to compile itHow to compile itHow to compile it $ patscc -DATS_MEMALLOC_LIBC -o fizzbuzz fizzbuzz.dats $ ls fizzbuzz* fizzbuzz.dats fizzbuzz_dats.c $ size fizzbuzz text data bss dec hex filename 6364 796 40 7200 1c20 fizzbuzz $ ldd fizzbuzz linux-vdso.so.1 (0x00007ffefef06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd024f9b000) /lib64/ld-linux-x86-64.so.2 (0x00005623ca0a6000) $ ./fizzbuzz | head 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz $ patscc -DATS_MEMALLOC_LIBC -o fizzbuzz fizzbuzz.dats $ ls fizzbuzz* fizzbuzz.dats fizzbuzz_dats.c $ size fizzbuzz text data bss dec hex filename 6364 796 40 7200 1c20 fizzbuzz $ ldd fizzbuzz linux-vdso.so.1 (0x00007ffefef06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd024f9b000) /lib64/ld-linux-x86-64.so.2 (0x00005623ca0a6000) $ ./fizzbuzz | head 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz $ patscc -DATS_MEMALLOC_LIBC -o fizzbuzz fizzbuzz.dats $ ls fizzbuzz* fizzbuzz.dats fizzbuzz_dats.c $ size fizzbuzz text data bss dec hex filename 6364 796 40 7200 1c20 fizzbuzz $ ldd fizzbuzz linux-vdso.so.1 (0x00007ffefef06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd024f9b000) /lib64/ld-linux-x86-64.so.2 (0x00005623ca0a6000) $ ./fizzbuzz | head 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz $ patscc -DATS_MEMALLOC_LIBC -o fizzbuzz fizzbuzz.dats $ ls fizzbuzz* fizzbuzz.dats fizzbuzz_dats.c $ size fizzbuzz text data bss dec hex filename 6364 796 40 7200 1c20 fizzbuzz $ ldd fizzbuzz linux-vdso.so.1 (0x00007ffefef06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd024f9b000) /lib64/ld-linux-x86-64.so.2 (0x00005623ca0a6000) $ ./fizzbuzz | head 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz $ patscc -DATS_MEMALLOC_LIBC -o fizzbuzz fizzbuzz.dats $ ls fizzbuzz* fizzbuzz.dats fizzbuzz_dats.c $ size fizzbuzz text data bss dec hex filename 6364 796 40 7200 1c20 fizzbuzz $ ldd fizzbuzz linux-vdso.so.1 (0x00007ffefef06000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd024f9b000) /lib64/ld-linux-x86-64.so.2 (0x00005623ca0a6000) $ ./fizzbuzz | head 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz
  8. 8. ATS compile flowATS compile flowATS compile flowATS compile flowATS compile flow
  9. 9. What can ATS do?What can ATS do?What can ATS do?What can ATS do?What can ATS do? ☆ Write code on bare metal hardware☆ Write code on bare metal hardware☆ Write code on bare metal hardware☆ Write code on bare metal hardware☆ Write code on bare metal hardware ☆ Write code in Linux kernel☆ Write code in Linux kernel☆ Write code in Linux kernel☆ Write code in Linux kernel☆ Write code in Linux kernel ☆ Use strong type without any OS☆ Use strong type without any OS☆ Use strong type without any OS☆ Use strong type without any OS☆ Use strong type without any OS ☆ Prove code using dependent types☆ Prove code using dependent types☆ Prove code using dependent types☆ Prove code using dependent types☆ Prove code using dependent types ☆ Safely use malloc using linear types☆ Safely use malloc using linear types☆ Safely use malloc using linear types☆ Safely use malloc using linear types☆ Safely use malloc using linear types ☆ Safely use pointer using linear types☆ Safely use pointer using linear types☆ Safely use pointer using linear types☆ Safely use pointer using linear types☆ Safely use pointer using linear types
  10. 10. Demo running on bare metalDemo running on bare metalDemo running on bare metalDemo running on bare metalDemo running on bare metal http://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nchttp://youtu.be/5uPue0Jo1nc Arduino Uno hardware:Arduino Uno hardware:Arduino Uno hardware:Arduino Uno hardware:Arduino Uno hardware: ☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture☆ 8-bit Harvard architecture ☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB☆ Flash Memory: 32 KB ☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB☆ SRAM: 2 KB
  11. 11. Demo software architectureDemo software architectureDemo software architectureDemo software architectureDemo software architecture https://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-atshttps://github.com/fpiot/arduino-ats
  12. 12. Proof: Curry–Howard in ATSProof: Curry–Howard in ATSProof: Curry–Howard in ATSProof: Curry–Howard in ATSProof: Curry–Howard in ATS ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Type: Function signature introduced by keyword "fun" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Program: Function body introduced by keyword "implement" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proposition: Proof function signature introduced by keyword "prfun" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement" ☆ Proof: Proof function body introduced by keyword "primplement"
  13. 13. Proof: style of functionsProof: style of functionsProof: style of functionsProof: style of functionsProof: style of functions
  14. 14. Proof: function signatureProof: function signatureProof: function signatureProof: function signatureProof: function signature
  15. 15. Proof: function bodyProof: function bodyProof: function bodyProof: function bodyProof: function body
  16. 16. Proof: before compilingProof: before compilingProof: before compilingProof: before compilingProof: before compiling
  17. 17. Proof: after compilingProof: after compilingProof: after compilingProof: after compilingProof: after compiling Proof is erased at compile time.Proof is erased at compile time.Proof is erased at compile time.Proof is erased at compile time.Proof is erased at compile time.
  18. 18. Proof: pros of mixed functionProof: pros of mixed functionProof: pros of mixed functionProof: pros of mixed functionProof: pros of mixed function You can write following application:You can write following application:You can write following application:You can write following application:You can write following application: ☆ Program without garbage collection☆ Program without garbage collection☆ Program without garbage collection☆ Program without garbage collection☆ Program without garbage collection ☆ Proof to prove the program☆ Proof to prove the program☆ Proof to prove the program☆ Proof to prove the program☆ Proof to prove the program Good news for low-level programming!Good news for low-level programming!Good news for low-level programming!Good news for low-level programming!Good news for low-level programming!
  19. 19. Linear type: type of listLinear type: type of listLinear type: type of listLinear type: type of listLinear type: type of list List defined with linear type.List defined with linear type.List defined with linear type.List defined with linear type.List defined with linear type.
  20. 20. Linear type: create listLinear type: create listLinear type: create listLinear type: create listLinear type: create list Compile error occurs, if consuming is forgotten. Compile error occurs, if consuming is forgotten. Compile error occurs, if consuming is forgotten. Compile error occurs, if consuming is forgotten. Compile error occurs, if consuming is forgotten.
  21. 21. Linear type: append listLinear type: append listLinear type: append listLinear type: append listLinear type: append list
  22. 22. Please read our fanzine !Please read our fanzine !Please read our fanzine !Please read our fanzine !Please read our fanzine ! Read "Functional Ikamusume" book!Read "Functional Ikamusume" book!Read "Functional Ikamusume" book!Read "Functional Ikamusume" book!Read "Functional Ikamusume" book! http://www.paraiso-lang.org/ikmsm/books/c88.htmlhttp://www.paraiso-lang.org/ikmsm/books/c88.htmlhttp://www.paraiso-lang.org/ikmsm/books/c88.htmlhttp://www.paraiso-lang.org/ikmsm/books/c88.htmlhttp://www.paraiso-lang.org/ikmsm/books/c88.html
  23. 23. Join "Japan ATS User Group" !Join "Japan ATS User Group" !Join "Japan ATS User Group" !Join "Japan ATS User Group" !Join "Japan ATS User Group" ! http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/ We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. We translate following ATS documents into Japanese. * ATSプログラミング入門 http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ * ATSプログラミングチュートリアル http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ * Effective ATS https://github.com/jats-ug/translate/blob/master/Manual/ EffectiveATS.md * ATSプログラミング入門 http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ * ATSプログラミングチュートリアル http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ * Effective ATS https://github.com/jats-ug/translate/blob/master/Manual/ EffectiveATS.md * ATSプログラミング入門 http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ * ATSプログラミングチュートリアル http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ * Effective ATS https://github.com/jats-ug/translate/blob/master/Manual/ EffectiveATS.md * ATSプログラミング入門 http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ * ATSプログラミングチュートリアル http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ * Effective ATS https://github.com/jats-ug/translate/blob/master/Manual/ EffectiveATS.md * ATSプログラミング入門 http://jats-ug.metasepi.org/doc/ATS2/INT2PROGINATS/ * ATSプログラミングチュートリアル http://jats-ug.metasepi.org/doc/ATS2/ATS2TUTORIAL/ * Effective ATS https://github.com/jats-ug/translate/blob/master/Manual/ EffectiveATS.md Join us and review it!Join us and review it!Join us and review it!Join us and review it!Join us and review it!

×