mi n i ma l i s t i c t y p e d l u a i s h e r e
play

mi n i ma l i s t i c t y p e d L u a i s h e r - PowerPoint PPT Presentation

mi n i ma l i s t i c t y p e d L u a i s h e r e H i s h a m Mu h a mma d < h i s h a m@k o n g h q . c o m> mi n i ma l i s t i c e x p e r i me n t a l e me r g i


  1. mi n i ma l i s t i c t y p e d L u a i s h e r e H i s h a m Mu h a mma d < h i s h a m@k o n g h q . c o m>

  2. mi n i ma l i s t i c e x p e r i me n t a l e me r g i n g

  3. mi n i ma l i s t i c e x p e r i me n t a l e me r g i n g

  4. u n t y p e d : n o t y p e s a t a l l a s s e mb l y , u n ( i ) t y p e d l a mb d a c a l c u l u s t y p e d : t y p e s e x i s t ! s t r i n g a n d n u mb e r a r e d i fg e r e n t t h i n g s ( e v e n i f y o u c a n d o " 1 " + 2 )

  5. d y n a mi c a l l y t y p e d : v a l u e s h a v e t y p e s , v a r i a b l e s d o n ' t L u a , S c h e me , J a v a S c r i p t , P y t h o n , R u b y , P H P , e t c . s t a t i c a l l y t y p e d : v a l u e s h a v e t y p e s , v a r i a b l e s h a v e t y p e s C , J a v a , G o , C # , R u s t , H a s k e l l , e t c .

  6. P y t h o n → my p y , p y t y p e R u b y → S o r b e t P H P → H a c k J a v a S c r i p t → T y p e S c r i p t R a c k e t → T y p e d R a c k e t e t c .

  7. L u a ?

  8. a d d i n g t y p e s ( o r a n y t h i n g ! ) ma k e s a l a n g u a g e l a r g e r - c o n c e p t u a l l y - a n d i n i mp l e me n t a t i o n

  9. a d d i n g t y p e s ( o r a n y t h i n g ! ) ma k e s a l a n g u a g e l a r g e r - c o n c e p t u a l l y - a n d i n i mp l e me n t a t i o n

  10. a d d i n g t y p e s ( o r a n y t h i n g ! ) ma k e s a l a n g u a g e l a r g e r - c o n c e p t u a l l y - a n d i n i mp l e me n t a t i o n

  11. i f t h e l a n g u a g e g r o ws t o o mu c h , i t d o e s n ' t f e e l l i k e L u a a n y mo r e

  12. i f t h e l a n g u a g e g r o ws t o o mu c h , i t d o e s n ' t f e e l l i k e L u a a n y mo r e i f t h e t y p e c h e c k e r i s t o o s i mp l i s t i c , i t d o e s n ' t f e e l l i k e L u a a n y mo r e

  13. b u t we w a n t b o t h : a s ma l l l a n g u a g e t h a t fj t s i n y o u r h e a d a t y p e c h e c k e r t h a t c a t c h e s wh e n y o u ma k e a s i l l y t y p o

  14. t h e c h a l l e n g e : t o fj n d t h e s we e t s p o t b e t we e n mi n i ma l i s m a n d f u n c t i o n a l i t y

  15. t l

  16. mi n i ma l i mp l e me n t a t i o n i n t h e L u a s p i r i t : L u a : 2 9 7 k B t a r b a l l p u r e s t a n d a r d C , n o d e p e n d e n c i e s t l : s i n g l e fj l e , c u r r e n t l y 4 8 0 6 l i n e s p u r e L u a , n o d e p e n d e n c i e s

  17. n o d e p e n d e n c i e s : d r o p t l . l u a i n y o u r L u a p r o j e c t a n d o fg y o u g o

  18. tl check file.tl → tl gen file.tl file.lua → tl run file.tl

  19. t wo mo d e s : . t l ( " s t r i c t " mo d e ) . l u a ( " l a x " mo d e )

  20. function f(x) return x end local z = f(0)

  21. function f(x: number): number return x end local z = f(0)

  22. t l r e p o r t s e r r o r s a n d u n k n o wn s s e p a r a t e l y

  23. t y p e c h e c k e r : t h e b u l k o f t h e c o mp i l e r

  24. function keys(t: {string: string}): {string} local ks = {} for k, v in pairs(t) do table.insert(ks, k) end return ks end

  25. t y p e s o f t a b l e s

  26. wh a t i s a L u a t a b l e ?

  27. t a b l e s i n t l : {string:boolean} ma p s , l i k e {string} a r r a y , l i k e Point r e c o r d , l i k e Node a r r a y - r e c o r d , l i k e a r r a y - ma p ? n o t y e t

  28. t a b l e s i n t l : {string:boolean} ma p s , l i k e {string} a r r a y , l i k e Point r e c o r d , l i k e Node a r r a y - r e c o r d , l i k e a r r a y - ma p ? n o t y e t

  29. t a b l e s i n t l : {string:boolean} ma p s , l i k e {string} a r r a y , l i k e Point r e c o r d , l i k e Node a r r a y - r e c o r d , l i k e a r r a y - ma p ? n o t y e t

  30. t a b l e s i n t l : {string:boolean} ma p s , l i k e {string} a r r a y , l i k e Point r e c o r d , l i k e Node a r r a y - r e c o r d , l i k e a r r a y - ma p ? n o t y e t

  31. t a b l e s i n t l : {string:boolean} ma p s , l i k e {string} a r r a y , l i k e Point r e c o r d , l i k e Node a r r a y - r e c o r d , l i k e a r r a y - ma p ? n o t y e t

  32. t a b l e s i n t l : {string:boolean} ma p s , l i k e {string} a r r a y , l i k e Point r e c o r d , l i k e Node a r r a y - r e c o r d , l i k e a r r a y - ma p ? n o t y e t

  33. n o mi n a l r e c o r d s Point = record x: number y: number end

  34. n o i n h e r i t a n c e o r i n t e r f a c e s / t r a i t s ( f o r n o w? )

  35. wi t h d y n a mi c t y p e s , i t ' s t r i v i a l t o wr i t e v e r y g e n e r i c c o d e

  36. function keys(t: {`K: `V}): {`K} local ks = {} for k, v in pairs(t) do table.insert(ks, k) end return ks end

  37. p r i o r i t i z i n g p r a c t i c a l n e e d s o v e r a f e a t u r e c h e c k l i s t

  38. y a y , t y p e s ! n o w wh a t ?

  39. wh i c h e r r o r s a r e l e f t ?

  40. oops.lua:279: attempt to index a nil value (field '?') stack traceback: oops.lua:279: in function 'oh_no' oops.lua:12: in function 'not_again' oops.lua:490: in function 'main' [C]: in ?

  41. t l ( a n d L u a ) : a n y v a r i a b l e ma y b e n i l

  42. o p t i o n t y p e s ? Maybe i n H a s k e l l , Result i n R u s t , e t c . . .

  43. t r i c k i e r f o r L u a : t[x] e v e r y r e t u r n s a n o p t i o n t y p e ? n a h

  44. . . . h a v e t h e c o mp i l e r d e t e c t i t ?

  45. d u g o u t o f t h e r a b b i t h o l e !

  46. . . . b y t h e F O S D E M d e a d l i n e a n d b y u s e r f e e d b a c k !

  47. p r a c t i c a l i s s u e s ! i

  48. d e fj n i t i o n fj l e s require("socket") socket.d.tl wh e n t y p e c h e c k i n g , l o a d socket.lua wh e n r u n n i n g , l o a d

  49. L u a h a s n o f u n c t i o n o v e r l o a d i n g ! b u t i t ' s c o mmo n t o f a k e i t

  50. c h a l l e n g e : love.graphics.print( { {1,1,1,1}, "Hello", {1,0,0,1}, " World" } )

  51. coloredtext ? wh a t i s t h e t y p e o f

  52. coloredtext ? wh a t i s t h e t y p e o f any 1 .

  53. coloredtext ? wh a t i s t h e t y p e o f any 1 . table 2 .

  54. coloredtext ? wh a t i s t h e t y p e o f any 1 . table 2 . {any} 3 .

  55. coloredtext ? wh a t i s t h e t y p e o f any 1 . table 2 . {any} 3 . {string or {number}} 4 .

  56. coloredtext ? wh a t i s t h e t y p e o f any 1 . table 2 . {any} 3 . {string or {number}} 4 . {[i%2==1]:{number},[i%2==0]:string} 5 .

  57. coloredtext ? wh a t i s t h e t y p e o f any 1 . table 2 . {any} 3 . {string or {number}} 4 . {[i%2==1]:{number},[i%2==0]:string} 5 . {[i%2==1]:({number}|len==4), 6 . [i%2==0]:string}

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend