Hack for HHVM Converting Facebook Julien Verlaguet Software Engineer.

Slides:



Advertisements
Similar presentations
Chapter 8 Technicalities: Functions, etc. Bjarne Stroustrup
Advertisements

Yaser Zhian Dead Mage IGDI, Workshop 10, May 30 th -31 st, 2013.
(Thinking About) Introducing Agile Testing to the One Laptop Per Child Project C. Titus Brown Asst. Prof., Michigan State U. C. Titus Brown.
1 The C Language An International Standard CIS2450 Professional Aspect of Software Engineering.
Hitting the ‘Up-To-Date ’ VB2009 – Steven Ginn Bull’s eye.
Type Checking, Inference, & Elaboration CS153: Compilers Greg Morrisett.
Dynamic Typing COS 441 Princeton University Fall 2004.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 20 Slide 1 Critical systems development.
Lightweight Abstraction for Mathematical Computation in Java 1 Pavel Bourdykine and Stephen M. Watt Department of Computer Science Western University London.
OnBase Troubleshooting
Type Checking.
Applied Software Project Management INTRODUCTION Applied Software Project Management 1 5/20/2015.
Lecture 2 Page 1 CS 236, Spring 2008 Security Principles and Policies CS 236 On-Line MS Program Networks and Systems Security Peter Reiher Spring, 2008.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Lecture Roger Sutton CO331 Visual programming 15: Debugging 1.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
Pointers and Dynamic Variables. Objectives on completion of this topic, students should be able to: Correctly allocate data dynamically * Use the new.
Applied Software Project Management 1 Introduction Dr. Mengxia Zhu Computer Science Department Southern Illinois University Carbondale.
Semantics for MinML COS 441 Princeton University Fall 2004.
Type Inference: CIS Seminar, 11/3/2009 Type inference: Inside the Type Checker. A presentation by: Daniel Tuck.
CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Winter 2013.
Software design and development Marcus Hunt. Application and limits of procedural programming Procedural programming is a powerful language, typically.
© 2014 Carnegie Robotics LLC. Use or disclosure of document data is subject to the restrictions on the title pagePage 1 Lessons Learned The most important.
A quadratic equation is a second degree polynomial, usually written in general form: The a, b, and c terms are called the coefficients of the equation,
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Lecture 18 Page 1 CS 111 Online Design Principles for Secure Systems Economy Complete mediation Open design Separation of privileges Least privilege Least.
Lecture 22 Miscellaneous Topics 4 + Memory Allocation.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
Applied Software Project Management Andrew Stellman & Jennifer Greenehttp:// Applied Software Project Management Chapter 1: Introduction.
16 - Generics. 2 NOEA2009Java-kursus – Generics ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can.
Inheritance. Recall the plant that we defined earlier… class Plant { public: Plant( double theHeight ) : hasLeaves( true ), height (theHeight) { } Plant(
Why you should be using Version Control. Matt Krass Electrical/Software Engineer November 22, 2014.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 3: Objects, Types, and Values 1 Based on slides.
Generics in.NET and C# Generics. ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can apply polymorphism.
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Software Engineering 1 Some Definitions Lesson 2.
CHAPTER 10: CORE MECHANICS Definitions and Mechanisms.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
Word problems DON’T PANIC! Some students believe they can’t do word problem solving in math. Don’t panic. It helps to read the question more than once.
Refactoring & Testability. Testing in OOP programming No life in flexible methodologies and for refactoring- infected developers without SOME kind of.
Chapter 7 The Practices: dX. 2 Outline Iterative Development Iterative Development Planning Planning Organizing the Iterations into Management Phases.
Week 4 - Monday.  What did we talk about last time?  Queues  Implementing queues with circular arrays.
CS5103 Software Engineering Lecture 02 More on Software Process Models.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
Chapter 1: Fundamental of Testing Systems Testing & Evaluation (MNN1063)
IDNAbis and Security Protocols or Internationalization Issues with Short Strings John C Klensin SAAG – 26 July 2007.
5-Jan-16 Recursive descent parsing. Some notes on recursive descent The starter code that I gave you did not exactly fit the grammar that I gave you Both.
(1) Test Driven Development Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
Copyright 2014 – Noah Mendelsohn Code Tuning Noah Mendelsohn Tufts University Web:
CSE 143 Lecture 4 More ArrayIntList : Pre/postconditions; exceptions; testing reading: slides created by Marty Stepp and Hélène Martin
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
1.Net programmingGenericsNOEA / 2009 Generics 11. Generics in.NET and C#
Version Control and SVN ECE 297. Why Do We Need Version Control?
Project Overview CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.
Lecture 3 Page 1 CS 236 Online Security Mechanisms CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Preventing bugs with pluggable type-checking Michael Ernst MIT
Today’s Agenda ML Development Workflow –Emacs –Using use –The REPL More ML –Shadowing Variables –Debugging Tips –Boolean Operations –Comparison Operations.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
Computer Engineering page 1 Integer arithmetic Depends what you mean by “integer”. Assume at 3-bit string. –Then we define: zero = 000 one = 001 Use zero,
6. (supplemental) User Interface Design. User Interface Design System users often judge a system by its interface rather than its functionality A poorly.
Chapter 6 CS 3370 – C++ Functions.
User-Centered Design Data Entry CS 4640 Programming Languages for Web Applications [The Design of Everyday Things, Don Norman, Ch 7]
User-Centered Design Data Entry CS 4640 Programming Languages for Web Applications [The Design of Everyday Things, Don Norman, Ch 7]
Presentation transcript:

Hack for HHVM Converting Facebook Julien Verlaguet Software Engineer

Facebook ▪ A large PHP codebase (> 10M lines) ▪ Thousands of engineers ▪ Performance matters! (HipHop, HHVM) ▪ The development cycle is fast: we push twice a day! ▪ PHP is a good technical choice to iterate quickly

PHP: how it all started! FAS T

Hack ▪ A statically typed language for HHVM ▪ Compatible with PHP: ▪ Interoperates with no overhead ▪ Same representation at runtime ▪ Instantaneous type-checking ▪ Designed for incremental adoption: ▪ Gradual typing ▪ Allows different “modes” (strict, partial, decl)

A simple example

Hack Types ▪ All PHP types: int, MyClassName, array ▪ Nullable: ?int, ?MyClassName ▪ Mixed: anything (careful) ▪ Tuples: (int, bool, X) ▪ Closures: (function(int): int) ▪ Collections: Vector, Map ▪ Generics: A, foo (T $x): T ▪ Constraints: foo (T $x): T

Hack ▪ We knew we wanted an IDE from day one: ▪ Usually, the IDE and the type-checker are distinct entities ▪ Hack is both a type-checker and an IDE ▪ The type-checker is a server (hh_server): ▪ The server type-checks all the files ▪ Keeps track of the dependencies ▪ Recomputes types when something changed

Question Can we convert millions of lines?

Prerequisites for conversion ▪ Address concerns regarding static-typing ▪ Have a backup plan ▪ Zero friction for developers (they can always bail out) ▪ Automated conversion

The concerns ▪ Too slow! ▪ Too verbose! ▪ Bad error messages! ▪ Not flexible enough!

Hack: you have nothing to lose! ▪ Too slow! ▪ Response time < 200ms ▪ Too verbose! ▪ Types are inferred ▪ Bad error messages! ▪ Error messages tell you how to solve the problem ▪ Not flexible enough! ▪ It’s gradually typed

When things go wrong? ▪ We are always strictly MORE restrictive ▪ In the type-checker: ▪ Removing a type-annotation never introduces an error ▪ Removing a type-annotation never changes the behavior at runtime ▪ At runtime: ▪ We introduce new constructions distinct from the old ones ▪ We make old constructions more warn or fail

Different modes ▪ <?hh // strict ▪ If all the code is strict then it’s sound ▪ <?hh ▪ Dynamic code is assumed to be correct ▪ <?hh // decl ▪ Don’t check the code, only consider definitions ▪ // UNSAFE ▪ Trust me: I am an engineer!

Gradual typing

Error messages You can try it online:

The rules ▪ If the entire code is strict, the code is type-safe ▪ Adding an annotation should never force you to add another ▪ Removing an annotation should never introduce an error ▪ Simple mental model ▪ Be “dumb” by default ▪ Scale

Conversion strategy: tighten the belt ▪ Convert everything to <?hh ▪ Add annotations gradually ▪ Build awareness ▪ More coverage for tools ▪ The problems: ▪ Gives a false sense of security ▪ Refactoring tools not really usable

Tighten the belt ▪ A global type-inference system to “guess” annotations ▪ A monitoring system to detect mistakes ▪ Refactoring tools to remove (or harden) annotations

Where are we at?

Question: can we scale this? Constant refactoring for language changes became a habit!

Let’s go back to the 90s

Release day (1999)

What happened? ▪ A cultural change (release early, release often) ▪ Tools (git, mercurial etc …) ▪ More code is visible (github etc …) ▪ What use to be painful became easy ▪ Thanks to a gradual process: every morning I “git rebase”

Can we do the same with programming languages?

The Facebook conversion ▪ Large enough / Small enough ▪ Lesson learnt, programmers must be able to choose: ▪ When (find the right time to upgrade) ▪ How much? (the upgrade process must be incremental) ▪ Where? (They can leave the parts that they don’t care about) ▪ Sometimes, the opposite is true, flip a switch (return types) ▪ Keep a simple mental model ▪ Controlling the code is a HUGE unfair advantage

The future of Hack ▪ Collaborate with the open-source community ▪ Tune the experience ▪ Provide more tools (IDE) ▪ Carry-on improving the language ▪ Make our own codebase more and more strict

Questions?