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

Hack - Why Should I Care?

Joel Clermont
November 07, 2014

Hack - Why Should I Care?

In March, Facebook released a new language called Hack. It adds static typing, generics and lambda expressions on top of the rest of the familiar PHP syntax. In addition, it allows for gradual adoption of these features and continued interoperability with existing PHP code. But why should you care? Do you need to work in a massive environment like Facebook to reap the rewards of learning a new language? I'll make a strong case that Hack (and HHVM) are worth your time, give you a good demo of the language and show you how to get started. I don't work for Facebook, but I dove into Hack the day it was announced and I've continued to follow its development with great interest. I have applications in production running on Hack and I'm eager to show PHP developers of all skill levels why it's worth their time to give Hack a look.

Joel Clermont

November 07, 2014
Tweet

More Decks by Joel Clermont

Other Decks in Technology

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

    Where do we need them?

    View Slide

  10. Type Annotations

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

    View Slide

  11. Type Annotations

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

    View Slide

  12. 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

  13. Doesn’t PHP already
    have type hints?

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  19. More useful Hack types

    View Slide

  20. Questions?

    View Slide

  21. Still not convinced?


    DEMO

    View Slide

  22. More Cool Features

    View Slide

  23. Lambdas

    View Slide

  24. Lambdas

    View Slide

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

    View Slide

  26. Collections
    Anyone know what this is?

    View Slide

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

    View Slide

  28. Collections
    Cleaner API

    View Slide

  29. Collections
    Other nice features
    • Familiar interface

    View Slide

  30. Collections
    Other nice features
    • Familiar interface
    • OutOfBoundsException

    View Slide

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

    View Slide

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

    View Slide

  33. Trailing Commas
    You know you want them

    View Slide

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

    View Slide

  35. Questions?

    View Slide

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

    View Slide

  37. Trying out Hack is not scary
    • Gradual process

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  44. 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

  45. 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

  46. Questions?

    View Slide

  47. Feedback please
    @jclermont
    https://joind.in/talk/view/12714

    View Slide

  48. Thank you!
    @jclermont


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

    View Slide