Hack - Why Should I Care?

Hack - Why Should I Care?

version given at Nomad PHP EU in April 2015

2fe1b2866cfd498a513295d60d5cad0f?s=128

Joel Clermont

April 23, 2015
Tweet

Transcript

  1. Hack
 Why Should I Care? Joel Clermont
 @jclermont

  2. What to expect • No insider secrets

  3. What to expect • No insider secrets • High-level tour

    of Hack’s unique features
  4. What to expect • No insider secrets • High-level tour

    of Hack’s unique features • Make the case why you should try it out
  5. What to expect • No insider secrets • High-level tour

    of Hack’s unique features • Make the case why you should try it out • Show you how to get started
  6. What to expect • No insider secrets • High-level tour

    of Hack’s unique features • Make the case why you should try it out • Show you how to get started • Answer all your questions
  7. Quick Tour of Hack

  8. Type Annotations

  9. Type Annotations

  10. Type Annotations

  11. Type Annotations
 Where do we need them?

  12. Type Annotations
 Where do we need them? 1

  13. Type Annotations
 Where do we need them? 1 2

  14. Type Annotations
 Where do we need them? 1 2 3

  15. Type Annotations
 Where do we need them? 1 2 3

  16. Type Annotations
 Where do we need them?

  17. Type Annotations
 What do we get out of it? •

    Easier for developers to understand intent
  18. Type Annotations
 What do we get out of it? •

    Easier for developers to understand intent • Correctness of our type system
  19. Type Annotations
 What do we get out of it? •

    Easier for developers to understand intent • Correctness of our type system • Easier to refactor
  20. Doesn’t PHP already have type hints?

  21. Doesn’t PHP already have type hints? • Scalar type hints

  22. Doesn’t PHP already have type hints? • Scalar type hints

    • Typed arrays
  23. Doesn’t PHP already have type hints? • Scalar type hints

    • Typed arrays • Nullable types
  24. Doesn’t PHP already have type hints? • Scalar type hints

    • Typed arrays • Nullable types • Function return type hints
  25. Doesn’t PHP already have type hints? • Scalar type hints

    • Typed arrays • Nullable types • Function return type hints • Type checker
  26. More useful Hack types

  27. More useful Hack types

  28. More useful Hack types

  29. More useful Hack types

  30. More useful Hack types

  31. Questions?

  32. Still not convinced?
 
 DEMO

  33. What’s wrong?

  34. What’s wrong?

  35. What’s wrong?

  36. What’s wrong?

  37. What’s wrong?

  38. Solution 1

  39. Solution 2

  40. Solution 3

  41. What’s wrong?

  42. None
  43. Solution

  44. Questions?

  45. More Cool Features

  46. Lambdas

  47. Lambdas

  48. Lambdas

  49. Lambdas

  50. Collections Why would I need anything besides an array?

  51. Collections Anyone know what this is?

  52. Collections Hack gives us the right tool for each job

  53. Collections Cleaner API

  54. Collections Other nice features • Familiar interface

  55. Collections Other nice features • Familiar interface • OutOfBoundsException

  56. Collections Other nice features • Familiar interface • OutOfBoundsException •

    Collections are objects (no more passing by ref)
  57. Collections Other nice features • Familiar interface • OutOfBoundsException •

    Collections are objects (no more passing by ref) • Immutable collections too
  58. Trailing Commas You know you want them

  59. And more . . . • User attributes • Enhancements

    to traits • Async / await • Constructor promotion • Shapes • Type aliases . . . .
  60. Questions?

  61. Why should you consider it? Safety Language Features (Developer) Speed

  62. Trying out Hack is not scary • Gradual process

  63. Trying out Hack is not scary • Gradual process •

    Full PHP interoperability
  64. Trying out Hack is not scary • Gradual process •

    Full PHP interoperability • Not just for multi-million line codebases
  65. Trying out Hack is not scary • Gradual process •

    Full PHP interoperability • Not just for multi-million line codebases • Awesome tooling
  66. How to get started • Install HHVM (packages available)

  67. How to get started • Install HHVM (packages available) •

    Convert existing code with hackificator
  68. How to get started • Install HHVM (packages available) •

    Convert existing code with hackificator • Monitor logs for type errors
  69. How to get started • Install HHVM (packages available) •

    Convert existing code with hackificator • Monitor logs for type errors • Harden your types over time
  70. Resources • Conversion guide
 http://docs.hhvm.com/manual/en/install.hack.conversion.php • HHVM blog http://hhvm.com/blog •

    IRC channel #hhvm • http://hhvm.com/frameworks/ • https://github.com/facebook/hhvm/wiki/Extensions
  71. grumpy-learning.com

  72. Questions? @jclermont https://joind.in/talk/view/14452

  73. Feedback please @jclermont https://joind.in/talk/view/14452

  74. Thank you! @jclermont
 
 https://joind.in/talk/view/14452