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 full-size slide

  2. What to expect
    • No insider secrets

    View full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size slide

  7. Quick Tour of Hack

    View full-size slide

  8. Type Annotations

    View full-size slide

  9. Type Annotations

    View full-size slide

  10. Type Annotations

    View full-size slide

  11. Type Annotations

    Where do we need them?

    View full-size slide

  12. Type Annotations

    Where do we need them?
    1

    View full-size slide

  13. Type Annotations

    Where do we need them?
    1
    2

    View full-size slide

  14. Type Annotations

    Where do we need them?
    1
    2 3

    View full-size slide

  15. Type Annotations

    Where do we need them?
    1
    2 3

    View full-size slide

  16. Type Annotations

    Where do we need them?

    View full-size slide

  17. Type Annotations

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

    View full-size slide

  18. Type Annotations

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

    View full-size 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 full-size slide

  20. Doesn’t PHP already
    have type hints?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  26. More useful Hack types

    View full-size slide

  27. More useful Hack types

    View full-size slide

  28. More useful Hack types

    View full-size slide

  29. More useful Hack types

    View full-size slide

  30. More useful Hack types

    View full-size slide

  31. Still not convinced?


    DEMO

    View full-size slide

  32. What’s wrong?

    View full-size slide

  33. What’s wrong?

    View full-size slide

  34. What’s wrong?

    View full-size slide

  35. What’s wrong?

    View full-size slide

  36. What’s wrong?

    View full-size slide

  37. What’s wrong?

    View full-size slide

  38. More Cool Features

    View full-size slide

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

    View full-size slide

  40. Collections
    Anyone know what this is?

    View full-size slide

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

    View full-size slide

  42. Collections
    Cleaner API

    View full-size slide

  43. Collections
    Other nice features
    • Familiar interface

    View full-size slide

  44. Collections
    Other nice features
    • Familiar interface
    • OutOfBoundsException

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  47. Trailing Commas
    You know you want them

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  50. Trying out Hack is not scary
    • Gradual process

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  58. 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 full-size slide

  59. grumpy-learning.com

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  62. Thank you!
    @jclermont


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

    View full-size slide