Include Hack

Total Page:16

File Type:pdf, Size:1020Kb

Include Hack HHVM - PHP++ PAUL TARJAN SARA GOLEMON HHVM OPEN SOURCE HHVM OPEN SOURCE What is HHVM? HHVM is not a source transformer That was HPHPc, it’s dead. ▪ Runs your PHP pages live, just like PHP ▪ Uses standard FastCGI transport ! Database Webserver A PHP P (mysql, posges, ! (apache, nginx, etc…) C mongo, redis, etc…) ▪ Runs anywhere (on 64-bit x86 linux) index.php ▪ Drop-in replacement for PHP login.php home.php (mostly) cart.php HHVM is not a source transformer That was HPHPc, it’s dead. ▪ Runs your PHP pages live, just like PHP ▪ Uses standard FastCGI transport ! Database Webserver HHVM (mysql, posges, ! (apache, nginx, etc…) mongo, redis, etc…) ▪ Runs anywhere (on 64-bit x86 linux) index.php ▪ Drop-in replacement for PHP login.php home.php (mostly) cart.php HHVM supports all PHP syntax Tracking HEAD And some of its own ▪ Splat & Variadics ▪ Scalar type hint (and much much more) ▪ Finally ▪ Async co-routines ! ▪ Generics ▪ Generators ▪ Collections (smart arrays) ▪ Namespaces ▪ XHP (Integrated XHTML) ▪ User Attributes HHVM’s Parity Gap ! • Only about 60% of PHP’s unit tests pass ▪ Missing Extensions ▪ Minor differences in error message output ▪ Most private extensions need a rewrite ! • 20 top frameworks (and more) do pass ▪ So I wouldn’t sweat the small stuff HHVM is easy to install If you’re on Ubuntu Or something Debianish… ▪ deb http://dl.hhvm.com/ubuntu trusty main ▪ apt-get update ▪ apt-get install hhvm (or hhvm-nightly) ▪ Provides one binary covering cli, debugger, & fcgi server ! ▪ Coming very soon to a Debian near you! HHVM is buildable On other linux distros (Mac in interp mode) ▪ http://hhvm.com/repo/wiki ▪ gcc 4.8 or later (We love C++11) ▪ Boost 1.49 or later ▪ Lots of other dependencies…. ▪ git clone [email protected]:facebook/hhvm cmake . make –j ▪ hphp/hhvm/hhvm xkcd.org/303 Running a FastCGI server nginx HHVM server {! hhvm.server.file_socket = /var/run/hhvm.sock! server_name www.example.com;! hhvm.server.type = fastcgi! ! hhvm.server.source_root = /var/www! root /var/www;! ! index index.php;! hhvm.log.level = Error! ! hhvm.log.user_log_file = true! location ~ \.php$ {! hhvm.log.file = /var/log/hhvm-error.log! fastcgi_pass unix:/var/run/hhvm.sock! ! fastcgi_index index.php;! hhvm.log.access.0.file = /var/log/hhvm-access.log! fastcgi_param SCRIPT_FILENAME! hhvm.log.access.0.format=%h %l %u %t \”%r\” %>s %b! /var/www$fastcgi_script_name;! ! include fastcgi_param;! ! }! ! } ! ! ; hhvm -m daemon -c /etc/hhvm/hhvm.ini -u www-data! Open Source means something HHVM’s walled garden HPHPc in 2010 - 2011 Throw it over the wall (FOSDEM 2010) 200 ▪ Handful of internal developers ▪ Irregular “when we get to it” pushes to github 150 ▪ Little curation of tasks/pull-requests 100 ▪ Nearly zero documentation ▪ Brittle build system 50 ▪ Went dark in late 2011 0 HipHop in 2012 “Oh right, we have an OSS project…” 200 ▪ Growing team as HHVM begins to take over from HPHPc ▪ Built out a semi-daily push process (fairly manual) 150 ▪ Begin working through backlog of issues and pull-requests 100 ▪ Still pretty thin on documentation ▪ Update build system 50 ▪ Launched social channels 0 HHVM in 2013 Making Open Source HHVM a priority 200 ▪ Dedicated HHVM-OSS team ▪ Automated most of push process (multiple daily runs) 150 ▪ Declared “bug bankruptcy” (about 500 issues at the time) More than 2000 bugs opened and properly closed since then 100 ▪ Improved process for taking pull-requests More than 750 PRs merged since April 2013 50 ▪ Introduce support for optional and 3rd party extensions 0 ▪ Blogging/Technical articles HHVM in 2014 Bringing down the walls ▪ OSS build integrated with FB’s CI testing ▪ Immediate* mirroring of FB->Github repo ▪ Proper documentation! - docs.hhvm.com ▪ Hack programming language announced ▪ Automated import of github PRs ▪ Internal diffs developed in the open ▪ Inclusion in standard distros** xkcd.org/1205 ▪ Composer support for community-driven extensions** ! * 30 min push window ** Coming in 2nd half of 2014 HHVM Community HHVM Community Who’s already running it? ▪ Facebook: 100% Production traffic since Feb 2013 ▪ Baidu: "Most products migrated to HHVM" ▪ Pocket Rent: github.com/PocketRent/BeatBox ▪ Escalate.EU: Cloud monitoring/alerts ▪ GREE: Games Developer ! ▪ Clearly a lot of people at least trying: 30K downloads in June PHP is webscale HHVM’s JIT is the secret sauce HHVM – Bytecode interpreter ! Y Invalidate Modified? Cache • PHP5 style bytecode execution N • APC-like caching of bytecodes Compile to Bytecode • Perf about on par with PHP5 Run Bytecode HHVM – Native code JIT Y Invalidate Modified? ! Cache ▪ Bytecodes run a few times “cold” N Y ▪ Variable type inference Have Compile to Native? Bytecode ▪ Hotpath detection N ▪ Transform to native code Run Native Y Hot? N Compile to Native Run Bytecode HHVM – Repo Authoritative Mode PreCompile ! Bytecode ▪ “Production Mode” Y ▪ Improved offline pre-analysis Have Native? ▪ Assumes no changes N ! Run Native Y ▪ Another 10-25% perf gain Hot? N Compile to Native Run Bytecode HHVM – Compiling to Native <?php Zend Source Engine Optimized Intermediate Optimized Virtual Bytecode Bytecode Representation IR Assembly Machine OpCache+ Code But don’t take my word for it... Magento (Daniel Sloof) Response time (lower is better) 800 600 400 200 Response time (milliseconds) 0 Homepage Category view Product view Search ‘test’ Add to cart Shopping cart CMS Page PHP 5.5 HHVM Magento (Daniel Sloof) Transaction rate (higher is better) 100 75 50 Transactions per second25 0 Homepage Category view Product view Search ‘test’ Add to cart Shopping cart CMS Page PHP 5.5 HHVM Symfony (Christian Stocker) Requests per Second ( 120 90 60 Requests per Second 30 0 1 2 3 4 5 6 10 20 50 PHP 5.5 HHVM Symfony (Christian Stocker) Page Load Time ( 900 675 450 Page Load Time 225 0 1 2 3 4 5 6 10 20 50 PHP 5.5 HHVM Sure it’s fast, but what else can it do? HACK (yes, it’s a horrible name…) Type Hinting gone mad Static Analysis ▪ Scalars ▪ Analyze entire code tree without running ▪ bool, int, float, num, string ▪ Return typehints ▪ Report type errors like a strictly typed language ▪ Typed properties ▪ Fallback on loose typing ▪ Constructor arg promotion when needed (because that’s what PHP is good at) ▪ Specialization ▪ array<int> ▪ array<string,array<string,stdClass>> HACK <?hh ! Basic Hack class Foo { private int $num = 123; ▪ Static Analyzer traces value public function add(int $delta): Foo { through whole program $this->num += $delta; return $this; } ! public function get(): int { return $this->num; ▪ Looks for mismatches and } public function __construct(int $num): void { reports errors $this->num = $num; } ! } ! $f = new Foo(123); ▪ “Foo::add() expected int” $f->add(456); $f->add(“banana”); “Foo::add() received string” HACK – Constructor arg promotion <?hh ! Avoid repeated patterns class Foo { ! ▪ public/protected/private public function add(int $delta): Foo { $this->num += $delta; as __construct arg modifiers return $this; } ! ! public function get(): int { return $this->num; ▪ Declares the property } ! and initializes from value public function __construct(private int $num) :void { } } ! ! $f = new Foo(123); ▪ echo $f->add(456)->get(); Less boilerplate, more coding HACK – Generics <?hh ! Specialize common code class Foo<T> { public function add(T $delta): Foo { ▪ T is replaced w/ specialization type at $this->num += $delta; return $this; instantiation } ! public function get(): T { ! return $this->num; } ▪ Type-checker propagates replacement ! public function __constructor(private T $num) through generic :void { } ! } ! ! $i = new Foo(123); // Makes a Foo<int> ▪ echo $i->add(456)->get(); Less boilerplate, ! $f = new Foo(3.14); // Makes a Foo<float> more coding echo $f->add(2.17)->get(); HACK – Collections <?hh ! Specialized array objects function foo(Vector<int> $nums, Set<string> $names, ▪ Vector, Set, Map, StableMap Map<int,string> $numNameMap, FrozenVector<int> $nums2): bool { ! ! foreach($nums as $num) { $mappedName = $numNameMap[$num]; ▪ if ($names->contains($mappedName)) { Frozen* return true; Mutable* (default) } } ! ! if ($nums2->count() == 0) return true; return false; } ▪ Support ArrayAccess ▪ Extensive library of methods Async Functions <?hh ! Cooperative Multitasking async function getPage($url) : Awaitable<string> { ▪ Parallelizing made easy $fp = fopen($url, ‘r’); return await async_get_contents($fp); } ! ! // Sends all requests in parallel, ▪ // blocks for response Allow multiple functions to run $pages = await [ cooperatively getPage(‘http://php.net’), getPage(‘http://example.com’), getPage(‘http://hhvm.com’), ! ]; ! ▪ While one is blocking, the other executes hh_server convert - The Hackificator ! ! <?hh function g($y): { ! f(42); function f( $x): { return f(103); if ($x) { } return new Foo(); ! } else { function h(): { return null; g('hello world'); } g(44); } } hh_server convert - The Hackificator ! ! <?hh function g($y): { ! f(42); function f(@int $x): @?Foo { return f(103); if ($x) { } return new Foo(); ! } else { function h(): @void { return null; g('hello world'); } g(44); } } hh_server convert - The Hackificator ! ! <?hh function g($y): @?Foo { ! f(42); function f(@int $x): @?Foo { return f(103); if ($x) { } return new Foo(); ! } else { function h(): @void { return null; g('hello world'); } g(44); } } Hackificating 100% 90% 80% 70% 60% 50% 40% 30% 20% 10% 0 Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 2014 2014 2014 2014 User Attributes <?php ! User-defined metadata <<Author(“sgolemon”),Clowny>> function life() { ▪ Arbitrary
Recommended publications
  • 16 Inspiring Women Engineers to Watch
    Hackbright Academy Hackbright Academy is the leading software engineering school for women founded in San Francisco in 2012. The academy graduates more female engineers than UC Berkeley and Stanford each year. https://hackbrightacademy.com 16 Inspiring Women Engineers To Watch Women's engineering school Hackbright Academy is excited to share some updates from graduates of the software engineering fellowship. Check out what these 16 women are doing now at their companies - and what languages, frameworks, databases and other technologies these engineers use on the job! Software Engineer, Aclima Tiffany Williams is a software engineer at Aclima, where she builds software tools to ingest, process and manage city-scale environmental data sets enabled by Aclima’s sensor networks. Follow her on Twitter at @twilliamsphd. Technologies: Python, SQL, Cassandra, MariaDB, Docker, Kubernetes, Google Cloud Software Engineer, Eventbrite 1 / 16 Hackbright Academy Hackbright Academy is the leading software engineering school for women founded in San Francisco in 2012. The academy graduates more female engineers than UC Berkeley and Stanford each year. https://hackbrightacademy.com Maggie Shine works on backend and frontend application development to make buying a ticket on Eventbrite a great experience. In 2014, she helped build a WiFi-enabled basal body temperature fertility tracking device at a hardware hackathon. Follow her on Twitter at @magksh. Technologies: Python, Django, Celery, MySQL, Redis, Backbone, Marionette, React, Sass User Experience Engineer, GoDaddy 2 / 16 Hackbright Academy Hackbright Academy is the leading software engineering school for women founded in San Francisco in 2012. The academy graduates more female engineers than UC Berkeley and Stanford each year.
    [Show full text]
  • Magento on HHVM Speeding up Your Webshop with a Drop-In PHP Replacement
    Magento on HHVM Speeding up your webshop with a drop-in PHP replacement. Daniel Sloof [email protected] What is HHVM? ● HipHop Virtual Machine ● Created by engineers at Facebook ● Essentially a reimplementation of PHP ● Originally translated PHP to C++, now translates PHP to bytecode ● Just-in-time compiler, turning generated bytecode into machine code ● In some cases 5 to 10 times faster than regular PHP So what’s the problem? ● HHVM not entirely compatible with PHP ● Magento’s PHP triggering many of these incompatibilities ● Choosing between ○ Forking Magento to work around HHVM ○ Fixing issues within the extensive HHVM C++ codebase Resulted in... fixing HHVM ● Already over 100 commits fixing Magento related HHVM bugs; ○ SimpleXML (majority of bugfixes) ○ sessions ○ number_format ○ __get and __set ○ many more... ● Most of these fixes already merged back into the official (github) repository ● Community Edition running (relatively) stable! Benchmarks Before we go to the results... ● Magento 1.8 with sample data ● Standard Apache2 / php-fpm / MySQL stack (with APC opcode cache). ● Standard HHVM configuration (repo-authoritative mode disabled, JIT enabled) ● Repo-authoritative mode has potential to increase performance by a large margin ● Tool of choice: siege Benchmarks: Response time Average across 50 requests Benchmarks: Transaction rate While increasing siege concurrency until avg. response time ~2 seconds What about <insert caching mechanism here>? ● HHVM does not get in the way ● Dynamic content still needs to be generated ● Replaces PHP - not Varnish, Redis, FPC, Block Cache, etc. ● As long as you are burning CPU cycles (always), you will benefit from HHVM ● Think about speeding up indexing, order placement, routing, etc.
    [Show full text]
  • Automated Program Transformation for Improving Software Quality
    Automated Program Transformation for Improving Software Quality Rijnard van Tonder CMU-ISR-19-101 October 2019 Institute for Software Research School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Thesis Committee: Claire Le Goues, Chair Christian Kästner Jan Hoffmann Manuel Fähndrich, Facebook, Inc. Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Software Engineering. Copyright 2019 Rijnard van Tonder This work is partially supported under National Science Foundation grant numbers CCF-1750116 and CCF-1563797, and a Facebook Testing and Verification research award. The views and conclusions contained in this document are those of the author and should not be interpreted as representing the official policies, either expressed or implied, of any sponsoring corporation, institution, the U.S. government, or any other entity. Keywords: syntax, transformation, parsers, rewriting, crash bucketing, fuzzing, bug triage, program transformation, automated bug fixing, automated program repair, separation logic, static analysis, program analysis Abstract Software bugs are not going away. Millions of dollars and thousands of developer-hours are spent finding bugs, debugging the root cause, writing a patch, and reviewing fixes. Automated techniques like static analysis and dynamic fuzz testing have a proven track record for cutting costs and improving software quality. More recently, advances in automated program repair have matured and see nascent adoption in industry. Despite the value of these approaches, automated techniques do not come for free: they must approximate, both theoretically and in the interest of practicality. For example, static analyzers suffer false positives, and automatically produced patches may be insufficiently precise to fix a bug.
    [Show full text]
  • Nástroje Pro Sjednocení Datových Zdrojů Projektu Gloffer Tools for Unification of Data Sources Project Gloffer
    VŠB – Technická univerzita Ostrava Fakulta elektrotechniky a informatiky Katedra informatiky Nástroje pro sjednocení datových zdrojů projektu Gloffer Tools for unification of data sources project Gloffer 2018 Bc. Jakub Malchárek Rád bych poděkoval panu Ing. Radoslavu Fasugovi, Ph.D. za odbornou pomoc a konzultaci při zpracování této diplomové práce a cenné rady v průběhu implementace. Abstrakt V této diplomové práci se zabývám analýzou dostupných technologií pro implementaci webo- vého portálu Gloffer. Jsou zde popsány databáze (MySQL, Redis, MongoDB, Aerospike, Apache HBase, Apache Cassandra, Google Bigtable, Memcached), vyhledávače (Solr, Lucene, Elastic Search), webové servery (Apache HTTP server, Apache Tomcat), zprostředkovatelé zpráv (Rab- bit MQ), distribuované výpočetní technologie (Apache Hadoop) a vývojové technologie (PHP 7, Nette Framework, Java, Spring Framework). Cílem je nejen popis těchto technologií, ale také ná- vrh a implementace rozhraní pro sjednocení datových zdrojů projektu Gloffer v programovacím jazyce Java s využitím Spring Frameworku. Výstupem práce je inteligentní nástroj zpřístupňující data z více datových zdrojů. Závěr práce obsahuje výkonové testování vyvinutého nástroje. Klíčová slova: Aerospike, Apache Cassandra, Apache Hadoop, Apache HBase, Apache HTTP server, Apache Tomcat, aplikační rozhraní, datové zdroje, Elastic Search, fulltext, Google Bi- gtable, index, Java, Lucene, Memcached, MongoDB, MySQL, Nette Framework, PHP, Rabbit MQ, Redis, REST, Solr, Spring Framework Abstract In this diploma thesis I deal with analysis of the available technologies for implementation of the Gloffer web portal. There are described databases (MySQL, Redis, MongoDB, Aerospike, Apache HBase, Apache Cassandra, Google Bigtable, Memcached), search engines (Solr, Lucene, Elastic Search), web servers (Apache HTTP server, Apache Tomcat), message brokers (Rabbit MQ), distributed computing technologies (Apache Hadoop) and develop technologies (PHP 7, Nette Framework, Java, Spring Framework).
    [Show full text]
  • Artificial Intelligence for Understanding Large and Complex
    Artificial Intelligence for Understanding Large and Complex Datacenters by Pengfei Zheng Department of Computer Science Duke University Date: Approved: Benjamin C. Lee, Advisor Bruce M. Maggs Jeffrey S. Chase Jun Yang Dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in the Department of Computer Science in the Graduate School of Duke University 2020 Abstract Artificial Intelligence for Understanding Large and Complex Datacenters by Pengfei Zheng Department of Computer Science Duke University Date: Approved: Benjamin C. Lee, Advisor Bruce M. Maggs Jeffrey S. Chase Jun Yang An abstract of a dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in the Department of Computer Science in the Graduate School of Duke University 2020 Copyright © 2020 by Pengfei Zheng All rights reserved except the rights granted by the Creative Commons Attribution-Noncommercial Licence Abstract As the democratization of global-scale web applications and cloud computing, under- standing the performance of a live production datacenter becomes a prerequisite for making strategic decisions related to datacenter design and optimization. Advances in monitoring, tracing, and profiling large, complex systems provide rich datasets and establish a rigorous foundation for performance understanding and reasoning. But the sheer volume and complexity of collected data challenges existing techniques, which rely heavily on human intervention, expert knowledge, and simple statistics. In this dissertation, we address this challenge using artificial intelligence and make the case for two important problems, datacenter performance diagnosis and datacenter workload characterization. The first thrust of this dissertation is the use of statistical causal inference and Bayesian probabilistic model for datacenter straggler diagnosis.
    [Show full text]
  • Facebook Messenger Engineering
    SED 1037 Transcript EPISODE 1037 [INTRODUCTION] [00:00:00] JM: Facebook Messenger is a chat application that millions of people use every day to talk to each other. Over time, Messenger has grown to include group chats, video chats, animations, facial filters, stories and many more features. Messenger is a tool for utility as well as for entertainment. Messengers used on both mobile and desktop, but the size of the mobile application is particularly important. There are many users who are on devices that do not have much storage space. As Messenger has accumulated features, the iOS codebase has grown larger and larger. Several generations of Facebook engineers have rotated through the company with responsibility of working on Facebook Messenger, and that has led to different ways of managing information within the same codebase. The iOS codebase had room for improvement and Project LightSpeed was a project within Facebook that had the goal of making Messenger on iOS much smaller. Mohsen Agsen and is an engineer with Facebook and he joins the show to talk about the process of rewriting the Messenger app. This is a great deep dive into how to rewrite a mission- critical iOS application, and this team became very large at a certain point within Facebook. It's a great story and I hope you enjoy it as well. [SPONSOR MESSAGE] [00:01:27] JM: When I’m building a new product, G2i is the company that I call on to help me find a developer who can build the first version of my product. G2i is a hiring platform run by engineers that matches you with React, React Native, GraphQL and mobile engineers who you can trust.
    [Show full text]
  • Unicorn: a System for Searching the Social Graph
    Unicorn: A System for Searching the Social Graph Michael Curtiss, Iain Becker, Tudor Bosman, Sergey Doroshenko, Lucian Grijincu, Tom Jackson, Sandhya Kunnatur, Soren Lassen, Philip Pronin, Sriram Sankar, Guanghao Shen, Gintaras Woss, Chao Yang, Ning Zhang Facebook, Inc. ABSTRACT rative of the evolution of Unicorn's architecture, as well as Unicorn is an online, in-memory social graph-aware index- documentation for the major features and components of ing system designed to search trillions of edges between tens the system. of billions of users and entities on thousands of commodity To the best of our knowledge, no other online graph re- servers. Unicorn is based on standard concepts in informa- trieval system has ever been built with the scale of Unicorn tion retrieval, but it includes features to promote results in terms of both data volume and query volume. The sys- with good social proximity. It also supports queries that re- tem serves tens of billions of nodes and trillions of edges quire multiple round-trips to leaves in order to retrieve ob- at scale while accounting for per-edge privacy, and it must jects that are more than one edge away from source nodes. also support realtime updates for all edges and nodes while Unicorn is designed to answer billions of queries per day at serving billions of daily queries at low latencies. latencies in the hundreds of milliseconds, and it serves as an This paper includes three main contributions: infrastructural building block for Facebook's Graph Search • We describe how we applied common information re- product. In this paper, we describe the data model and trieval architectural concepts to the domain of the so- query language supported by Unicorn.
    [Show full text]
  • Ting-Yuan Hsia (408) 707-2897 | [email protected]| HPs:// HPs:// Education Santa Clara Univeristy, Santa Clara, CA, USA Sep
    Ting-Yuan Hsia (408) 707-2897 | [email protected]| hps://www.linkedin.com/in/ly2314| hps://www.ly2314.cc Education Santa Clara Univeristy, Santa Clara, CA, USA Sep. 2017 - Jun. 2019 Master of Science in Computer Science and Engineering GPA: 3.63 / 4 • Related Courses: Algorithm, Operating Systems, Data Mining, Cryptology, Computer Networks, Distributed Systems National Taiwan University, Taipei, Taiwan Sep. 2014 - Jun. 2016 Master of Science, Department of Electrical Engineering • Master thesis: “Scheduling-Aware Data Prefetching Based on Spark Framework”. • Related Courses: Machine Learning, Artificial Intelligence, Fault Tolerant Computing, Network and Computer Security National Taiwan University, Taipei, Taiwan Sep. 2010 - Jun. 2014 Bachelor of Science in Engineering, Department of Electrical Engineering • Related Courses: Data Structure and Programming Experience Software Development Engineer Jul. 2019 - Present NetApp, Inc. Sunnyvale, CA, USA • Develop and maintain ONTAP data protection technology including SnapMirror, SnapDiff, Volume Move. Software Engineer Intern Jun. 2018 - Sep. 2018 Facebook, Inc. Menlo Park, CA, USA • Developed a cache service from scratch for an internal system and it reduced page loading time by 60%. • The cache service was implemented in C++ and contains a Thrift interface which can be queried from PHP, C++ and Python clients. • Modified both back-end service and frontend user interface for pagination capability. Software Engineer Jan. 2013 - Jul. 2016 Zuvio Inc. Taipei, Taiwan • Developed and maintained client-side products including PowerPoint Add-ins and desktop applications from scratch using C#, XAML, WPF and VSTO. Teaching Assistant Feb. 2016 - Jul. 2016 National Taiwan University, Department of Electrical Engineering Taipei, Taiwan • Graded and assisted students in EE 4052, Computer Programming.
    [Show full text]
  • Extra Notes - React - Getting Started
    Extra Notes - React - Getting Started Dr Nick Hayward React JavaScript Library A quick introduction to React JavaScript library. Further details are available at the React website. Contents Intro Overview why use React? state changes component lifecycle a few benefits Getting started part 1 and 2 JSX benefits composite components more dynamic values conditionals non-DOM attributes reserved words data flow State stateless child components stateful parent component props vs state State - an example Minimal state Component lifecycle method groupings Additional reading &c. References Intro React began life as a port of a custom PHP framework called XHP, which was developed internally at Facebook. XHP, as a PHP framework, was designed to render the full page for each request. React developed from this concept, thereby creating a client-side implementation of loading the full page. Overview React can, therefore, be perceived as a type of state machine, thereby allowing a developer to control and manage the inherent complexity of state as it changes over time. It is able to achieve this by concentrating on a narrow scope for development, maintaining and updating the DOM responding to events React is best perceived as a view library, and has no definite requirements or restrictions on storage, data structure, routing, and so on. This allows developers the freedom to incorporate React code into a broad scope of applications and frameworks. why use React? React is often considered the V in the traditional MVC. As defined in the React docs, it was designed to solve one problem, building large applications with data that changes over time.
    [Show full text]
  • Dmon: Efficient Detection and Correction of Data Locality
    DMon: Efficient Detection and Correction of Data Locality Problems Using Selective Profiling Tanvir Ahmed Khan and Ian Neal, University of Michigan; Gilles Pokam, Intel Corporation; Barzan Mozafari and Baris Kasikci, University of Michigan https://www.usenix.org/conference/osdi21/presentation/khan This paper is included in the Proceedings of the 15th USENIX Symposium on Operating Systems Design and Implementation. July 14–16, 2021 978-1-939133-22-9 Open access to the Proceedings of the 15th USENIX Symposium on Operating Systems Design and Implementation is sponsored by USENIX. DMon: Efficient Detection and Correction of Data Locality Problems Using Selective Profiling Tanvir Ahmed Khan Ian Neal Gilles Pokam Barzan Mozafari University of Michigan University of Michigan Intel Corporation University of Michigan Baris Kasikci University of Michigan Abstract cally at run time. In fact, as we (§6.2) and others [2,15,20,27] Poor data locality hurts an application’s performance. While demonstrate, compiler-based techniques can sometimes even compiler-based techniques have been proposed to improve hurt performance when the assumptions made by those heuris- data locality, they depend on heuristics, which can sometimes tics do not hold in practice. hurt performance. Therefore, developers typically find data To overcome the limitations of static optimizations, the locality issues via dynamic profiling and repair them manually. systems community has invested substantial effort in devel- Alas, existing profiling techniques incur high overhead when oping dynamic profiling tools [28,38, 57,97, 102]. Dynamic used to identify data locality problems and cannot be deployed profilers are capable of gathering detailed and more accurate in production, where programs may exhibit previously-unseen execution information, which a developer can use to identify performance problems.
    [Show full text]
  • Hack and HHVM: Programming Productivity Without Breaking Things
    Hack & HHVM PROGRAMMING PRODUCTIVITY WITHOUT BREAKING THINGS Owen Yamauchi www.itbook.store/books/9781491920879 Hack and HHVM How can you take advantage of the HipHop Virtual Machine (HHVM) and “Hack is remarkable not the Hack programming language, two new technologies that Facebook only for the elegance and developed to run their web servers? With this practical guide, Owen Yamauchi—a member of Facebook’s core Hack and HHVM teams—shows power of its type system you how to get started with these battle-tested open source tools. and concurrency model, You’ll explore static typechecking and several other features that separate but because it provides Hack from its PHP origins, and learn how to set up, configure, deploy, existing PHP applications and monitor HHVM. Ideal for developers with basic PHP knowledge or a thoughtful, iterative experience with other languages, this book also demonstrates how these tools can be used with existing PHP codebases and new projects alike. migration strategy that can be executed at ■ Learn how Hack provides static typechecking while retaining scale. Yamauchi's survey PHP’s flexible, rapid development capability of the language and its ■ Write typesafe code with Hack’s generics feature runtime is clear, expert, ■ Explore HHVM, a just-in-time compilation runtime engine with and essential. Highly full PHP compatibility recommended. ■ Dive into Hack collections, asynchronous functions, and the ” —Ori Livneh XHP extension for PHP Principal Performance Engineer, ■ Understand Hack’s design rationale, including why it omits Wikimedia Foundation some PHP features ■ Use Hack for multitasking, and for generating HTML securely ■ Learn tools for working with Hack code, including PHP-to-Hack migration Owen Yamauchi is a software engineer at Facebook, where he works on the Hack and HHVM teams.
    [Show full text]
  • React: Facebook's Functional Turn on Writing Javascript
    practice DOI:10.1145/2980991 performance. The key to both advances Article development led by queue.acm.org is that components built from stan- dard JavaScript objects serve as the fun- damental building blocks for React’s A discussion with Pete Hunt, Paul O’Shannessy, internal framework, thus allowing for Dave Smith, and Terry Coatta greatly simplified composability. Once developers manage to get comfortable with building front ends in this way, they typically find they can more readi- ly see what is going on while also enjoy- React: ing greater flexibility in terms of how they structure and display data. All of which caused us to wonder about what led to the creation of React in the first place and what some of its most Facebook’s important guiding principles were. For- tunately for us, Pete Hunt, who at the time was an engineering manager at Instagram as well as one of the more Functional prominent members of Facebook’s React core team, is willing to shed some light on React’s beginnings. Hunt has since gone on to cofound Smyte, a San Turn on Francisco startup focused on security for marketplaces and social networks. Also helping to tell the story is Paul O’Shannessy, one of the first engi- Writing neers at Facebook to be dedicated to React full time. He came to that role from Mozilla, where he had previously worked on the Firefox front end. JavaScript The job of asking the probing ques- tions that drive the discussion forward falls to Dave Smith and Terry Coatta. Smith is an engineering director at HireVue, a Salt Lake City company fo- cused on team-building software, where he has had an opportunity to make ex- tensive use of both Angular and React.
    [Show full text]