Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hack - Why Should I Care?

Hack - Why Should I Care?

version given at Nomad PHP EU in April 2015

Joel Clermont

April 23, 2015
Tweet

More Decks by Joel Clermont

Other Decks in Programming

Transcript

  1. Hack

    Why Should I Care?
    Joel Clermont

    @jclermont

    View Slide

  2. What to expect
    • No insider secrets

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  7. Quick Tour of Hack

    View Slide

  8. Type Annotations

    View Slide

  9. Type Annotations

    View Slide

  10. Type Annotations

    View Slide

  11. Type Annotations

    Where do we need them?

    View Slide

  12. Type Annotations

    Where do we need them?
    1

    View Slide

  13. Type Annotations

    Where do we need them?
    1
    2

    View Slide

  14. Type Annotations

    Where do we need them?
    1
    2 3

    View Slide

  15. Type Annotations

    Where do we need them?
    1
    2 3

    View Slide

  16. Type Annotations

    Where do we need them?

    View Slide

  17. Type Annotations

    What do we get out of it?
    • Easier for developers to understand intent

    View Slide

  18. Type Annotations

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

    View Slide

  19. Type Annotations

    What do we get out of it?
    • Easier for developers to understand intent
    • Correctness of our type system
    • Easier to refactor

    View Slide

  20. Doesn’t PHP already
    have type hints?

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  26. More useful Hack types

    View Slide

  27. More useful Hack types

    View Slide

  28. More useful Hack types

    View Slide

  29. More useful Hack types

    View Slide

  30. More useful Hack types

    View Slide

  31. Questions?

    View Slide

  32. Still not convinced?


    DEMO

    View Slide

  33. What’s wrong?

    View Slide

  34. What’s wrong?

    View Slide

  35. What’s wrong?

    View Slide

  36. What’s wrong?

    View Slide

  37. What’s wrong?

    View Slide

  38. Solution 1

    View Slide

  39. Solution 2

    View Slide

  40. Solution 3

    View Slide

  41. What’s wrong?

    View Slide

  42. View Slide

  43. Solution

    View Slide

  44. Questions?

    View Slide

  45. More Cool Features

    View Slide

  46. Lambdas

    View Slide

  47. Lambdas

    View Slide

  48. Lambdas

    View Slide

  49. Lambdas

    View Slide

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

    View Slide

  51. Collections
    Anyone know what this is?

    View Slide

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

    View Slide

  53. Collections
    Cleaner API

    View Slide

  54. Collections
    Other nice features
    • Familiar interface

    View Slide

  55. Collections
    Other nice features
    • Familiar interface
    • OutOfBoundsException

    View Slide

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

    View Slide

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

    View Slide

  58. Trailing Commas
    You know you want them

    View Slide

  59. And more . . .
    • User attributes
    • Enhancements to traits
    • Async / await
    • Constructor promotion
    • Shapes
    • Type aliases . . . .

    View Slide

  60. Questions?

    View Slide

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

    View Slide

  62. Trying out Hack is not scary
    • Gradual process

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  71. grumpy-learning.com

    View Slide

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

    View Slide

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

    View Slide

  74. Thank you!
    @jclermont


    https://joind.in/talk/view/14452

    View Slide