mi n i ma l i s m v e r s u s t y p e s
play

mi n i ma l i s m v e r s u s t y p e s H i s h - PowerPoint PPT Presentation

mi n i ma l i s m v e r s u s t y p e s 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 m L u a : fj t s i n my h e a d g t y p e s p a i


  1. mi n i ma l i s m v e r s u s t y p e s 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 m L u a : fj t s i n my h e a d

  3. g

  4. t y p e s p a i r - p r o g r a mmi n g wi t h t h e c o mp u t e r

  5. 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 )

  6. 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 , E r l a n g , 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 .

  7. s t r o n g l y t y p e d we a k l y t y p e d

  8. 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 , E r l a n g , 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 .

  9. wh a t h a p p e n s wh e n we p u t mi n i ma l i s m a n d t y p e s t o g e t h e r ?

  10. a b r i e f h i s t o r y o f t y p i n g L u a

  11. 2 0 1 3 : T i d a l L o c k h t t p s : / / g i t h u b . c o m/ f a b 1 3 n / me t a l u a / b l o b / t i l o / s r c / t i l o / r e a d me . md

  12. 2 0 1 5 : T y p e d L u a h t t p s : / / g i t h u b . c o m/ a n d r e mm/ t y p e d l u a

  13. 2 0 1 7 : T i t a n h t t p s : / / g i t h u b . c o m/ t i t a n - l a n g / t i t a n

  14. 2 0 1 8 : P a l l e n e h t t p s : / / g i t h u b . c o m/ p a l l e n e - l a n g / p a l l e n e

  15. a n d y e t

  16. wh y i s i t s o h a r d ?

  17. o n c e y o u a d d t y p e s a n d t h e wh o l e e n c h i l a d a t h a t c o me s wi t h i t , t h e n t h e l a n g u a g e i s n o l o n g e r mi n i ma l i s t i c , r i g h t ?

  18. o n c e y o u a d d t y p e s a n d t h e wh o l e e n c h i l a d a t h a t c o me s wi t h i t , t h e n t h e l a n g u a g e i s n o l o n g e r mi n i ma l i s t i c , r i g h t ? t y p e s ma k e o u r t i n y l a n g u a g e s c o mp l i c a t e d ?

  19. t h e p r o b l e m i s k i n d a t h e o p p o s i t e

  20. d y n a mi c a l l y t y p e d l a n g u a g e s H U G E h a v e t y p e s y s t e ms

  21. t y p e s y s t e m: s e t o f r u l e s t h a t d e s c r i b e wh a t a r e t h e v a l i d i n t e r a c t i o n s o f v a l u e s i n c o r r e c t p r o g r a ms

  22. t y p e s y s t e m: s e t o f r u l e s t h a t d e s c r i b e wh a t a r e t h e v a l i d i n t e r a c t i o n s o f v a l u e s i n c o r r e c t p r o g r a ms i t ' s i n y o u r h e a d !

  23. y o u a r e t h e t y p e c h e c k e r

  24. obj.x, obj.y = get_coords() c a n ' t d o t h a t : get_coords y e s t e r d a y I c h a n g e d f r o m return x, y t o return { x = x, y = y }

  25. wh a t a r e t h e r u l e s i n y o u r h e a d ?

  26. 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 , E r l a n g , 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 . d e p e n d e n t 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 . . . a n d t y p e s h a v e v a l u e s ! a n d t y p e s ! I d r i s , A g d a . . . n o t t h a t ma n y y e t !

  27. function f(a, b)

  28. function f(a, b) a : i n t e g e r b : i f a < 2 5 6 t h e n s t r i n g e l s e a r r a y o f s t r i n g s

  29. function f(a, b) a : i n t e g e r b : i f a < 2 5 6 t h e n s t r i n g e l s e a r r a y o f s t r i n g s red: integer green: integer blue: integer

  30. function f(a, b) a : i n t e g e r b : i f a < 2 5 6 t h e n s t r i n g e l s e a r r a y o f s t r i n g s red: integer green: integer blue: integer f(red, {1, 2, 3})

  31. C u r r y - H o wa r d c o r r e s p o n d e n c e p r o p o s i t i o n s ↔ t y p e s l o g i c ↔ t y p e s y s t e m

  32. b t w , a r i t h me t i c s i s u n d e c i d a b l e

  33. local t = {} local ok, err = load_values_into_table(t) if not ok then return nil, "failed! " .. err end return { r = t[1], g = t[2], b = t[3] }

  34. L u a : t a b l e i s t h e o n l y s t r u c t u r e d t y p e

  35. e v e r y t h i n g i s a t a b l e a t a b l e i s a n y t h i n g

  36. e v e r y t h i n g i s a t a b l e a t a b l e i s a n y t h i n g a n a r r a y

  37. e v e r y t h i n g i s a t a b l e a t a b l e i s a n y t h i n g a n a r r a y a d i c t i o n a r y

  38. e v e r y t h i n g i s a t a b l e a t a b l e i s a n y t h i n g a n a r r a y a d i c t i o n a r y a s t r u c t

  39. e v e r y t h i n g i s a t a b l e a t a b l e i s a n y t h i n g a n a r r a y a d i c t i o n a r y a s t r u c t a n o b j e c t

  40. e v e r y t h i n g i s a t a b l e a t a b l e i s a n y t h i n g a n a r r a y a d i c t i o n a r y a s t r u c t a n o b j e c t a d i c t i o n a r y ma p p i n g o b j e c t s t o s t r i n g s o r a r r a y s d e p e n d i n g o n wh e t h e r fj e l d x o f t h e k e y o b j e c t i s t r u e o r f a l s e

  41. e x p r e s s i v e n e s s

  42. n o t r e a l l y wh a t a l a n g u a g e c a n e x p r e s s b u t h o w c a n y o u e x p r e s s i t

  43. d y n a mi c a l l y t y p e d l a n g u a g e s a r e s u p e r e x p r e s s i v e l i k e a b l a n k s h e e t o f p a p e r

  44. t y p e c h e c k e r wo r k s b o t h f o r g o o d ( " T h a n k y o u f o r c a t c h i n g my s i l l y t y p o ! " ) a n d b a d ( " n o , I _ k n o w_ t h a t t h i s u s e o f t h e v a r i a b l e i s s a f e ! " )

  45. e x p r e s s i v e n e s s i s t h e f e e l o f a l a n g u a g e

  46. local t = {} t.name = "items" t[1] = 100 t[2] = 200

  47. h e r e ' s t h e d i l e mma : h o w mu c h o f t h e l a n g u a g e d o y o u c h a n g e ?

  48. i f y o u wa n t t o ma k e i t f e e l l i k e L u a , t h e n t h e t y p e c h e c k e r i s s u p e r c o mp l e x i f y o u wa n t t o fj n i s h y o u r t y p e c h e c k e r , y o u h a v e t o ma k e c u t s s o me wh e r

  49. t wo o p t i o n s o n wh e r e t o ma k e c u t s

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