SlideShare una empresa de Scribd logo
1 de 3
Hack: a new programming language for HHVM
Posted last Thursday
Infra · Culture · HipHop · Languages
In a hurry? Try Hack now: http://hacklang.org/
Today we're releasing Hack, a programming language we developed for HHVM that interoperates
seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline
provided by static typing, while adding many features commonly found in other modern
programming languages.
We have deployed Hack at Facebook and it has been a great success. Over the last year, we
have migrated nearly our entire PHP codebase to Hack, thanks to both organic adoption and a
number of homegrown refactoring tools.
We're also proud to release an open source version of Hack to the public at http://hacklang.org/
as part of our HHVM runtime platform, which will now support both Hack and PHP.
Motivation
Every PHP programmer is familiar with day-to-day tasks that can be tricky or cumbersome. The
code above is a great example of a common mistake where a method could unexpectedly be
called on a null object, causing an error that wouldn't be caught until runtime. Another example is
a complex API, where developers may have a solid understanding of its semantics but still spend
time looking up mundane method names in documentation.
At Facebook scale — with thousands of engineers shipping new code twice a day — slowdowns
like these are even more problematic. Before Hack, we had a simple language with a quick
feedback loop — but how could we mitigate the sorts of problems described above? Could early
error detection coexist with rapid iteration, all while preserving our investment in PHP? Could
improved code analysis and introspection help make developers more productive with tools like
auto-complete?
Traditionally, dynamically typed languages allow for rapid development but sacrifice the ability to
catch errors early and introspect code quickly, particularly on larger codebases. Conversely,
statically typed languages provide more of a safety net, but often at the cost of quick iteration. We
believed there had to be a sweet spot.
Thus, Hack was born. We believe that it offers the best of both dynamically typed and statically
typed languages, and that it will be valuable to projects of all sizes.
The Hack language
Hack has deep roots in PHP. In fact, most PHP files are already valid Hack files. We made a
conscious choice not to support a handful of deprecated functions and features that were
incompatible with static typing (e.g. “variable variables” and the extract() function). We have also
added many new features that we believe will help make developers more productive.
Our principal addition is static typing. We have developed a system to annotate function
signatures and class members with type information; our type checking algorithm (the “type
checker”) infers the rest. Type checking is incremental, such that even within a single file some
code can be converted to Hack while the rest remains dynamically typed. Technically speaking,
Hack is a “gradually typed*”* language: dynamically typed code interoperates seamlessly with
statically typed code.
Within Hack's type system, we have introduced several features such as generics, nullable types,
type aliasing, and constraints on type parameters. These new language features are unobtrusive,
so the code you write with Hack will still look and feel like the dynamic language to which PHP
programmers are accustomed.
However, Hack adds additional features beyond static type checking, including Collections,
lambda expressions, and run-time enforcement of return types and parameter types.
Collections provide a clean, type-safe alternative to PHP arrays. We designed them specifically to
work well with static typing and generics. The Collections API offers many classic higher-order
functions such as map() and filter() to facilitate functional programming styles.
Lambda expressions give a concise syntax for creating closures. While PHP has closures, it
requires the programmer to explicitly name the variables they need to use from enclosing scopes.
With Hack's lambda expressions, we automatically infer these uses, saving you needless work.
Lambda expressions make it more convenient to take full advantage of the Collections API.
Run-time enforcement of return types and parameter types (including scalar types like int and
string) provides safety beyond what can be checked statically while type annotations are being
gradually added to a codebase. Run-time enforcement helps programmers detect and diagnose
certain kinds of problems more easily, and it helps HHVM's JIT produce more efficient code by
making it safe to trust type annotations for optimization purposes.
Instantaneous type checking
During development, a PHP programmer typically goes back and forth rapidly between the
source code and the browser. Engineers can iterate as quickly as they need, testing and tuning
an experience until it's perfect.
Traditionally, a type checker would disrupt this feedback loop as it takes time to analyze the
source code. We didn't want to slow the PHP workflow, so we came up with a new approach to
reconcile instantaneous feedback with type safety.
Our solution was to architect the type checker as a local server that watches the filesystem. The
server keeps all information about the source code in memory and automatically updates itself
when a file changes on disk. This approach has paid off: the type checker typically runs in less
than 200 milliseconds and rarely takes more than a second, making it easy to integrate into the
development workflow without introducing a noticeable delay.
Code ion
Hack's type safety and refactoring benefits grow the more it is used within a codebase.
Understanding that it would be difficult for some code to be completely transitioned to Hack right
away, it was important to us that Hack be developed such that it can coexist directly with other
PHP files as it is being introduced incrementally.
The rest of the conversion process, such as adding type annotations and using new language
features, can be done as appropriate for the codebase. For example, a type annotation can be
added for one function but left off another function, even in the same file. If a function parameter
or class member does not have an explicit type annotation, the type checker considers its type to
be dynamic, and it does not check the type of that value.
Within Facebook, we found that our engineers appreciated Hack enough that they started
converting the majority of their own code voluntarily. With millions of lines of code in our tree, we
also wanted some form of automation, so we built and use a number of code modification tools to
assist the process (which we are releasing as part of Hack).
Don't worry, your PHP is safe!
HHVM is still a PHP runtime, and we intend to keep it that way. In fact, we are working hard to
reach parity with PHP-5. One of HHVM's top priorities is to run unmodified PHP-5 source code,
both for the community and because we rely on third-party PHP libraries internally.
HHVM is now a runtime that supports *both* PHP and Hack, so you can start to take advantage
of Hack's new features incrementally.
Have fun with Hack!
We are delighted to open-source both Hack and the tools you can use to automatically convert
your codebase. This is just the first step, and we are dedicated to continuing to evolve this
software to make development even easier for both our own engineers and the broader
community. Hack's value is *not* limited to big projects: with type information, good error
messages, and fast feedback, small codebases can reap the benefits of Hack as well.
Next month, we will also introduce the language at the Hack Developer Day on the Facebook
campus in Menlo Park, and we hope to see you there in person or online.
We would love to have your feedback on our work so far, and welcome you all to participate in the
HHVM and Hack community.
Acknowledgements
There are many people who have contributed to the development of Hack.
The core Hack team consists of Joel Beales, Eugene Letuchy, Gabriel Levi, Joel Marcey, Erik
Meijer, Alok Menghrajani, Bryan O'Sullivan, Drew Paroski, James Pearce, Joel Pobar, and
Joshua Van Dyke Watzman.
A special thanks goes to our early community adopters for providing valuable feedback to make
the language better: James Miller, Simon Welsh, Nils Adermann, Fabien Potencier, and
Alexander Mols.
Hack is written primarily in OCaml. We would like to thank the Gallium team (INRIA) for the
development of the OCaml language, and the Ocsigen team (CNRS - University of Paris Diderot -
INRIA) for the development of the js_of_ocaml part of Ocsigen.
And, of course, thank you to everyone else who has helped make Hack the language it is today.
The list is too exhaustive for a blog post, but you know who you are.

Más contenido relacionado

La actualidad más candente

The essence of the VivaCore code analysis library
The essence of the VivaCore code analysis libraryThe essence of the VivaCore code analysis library
The essence of the VivaCore code analysis libraryPVS-Studio
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swiftTim Burks
 
IRJET- Mail Server Communication:PHP
IRJET-  	  Mail Server Communication:PHPIRJET-  	  Mail Server Communication:PHP
IRJET- Mail Server Communication:PHPIRJET Journal
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Tim Burks
 
Comparison of Programming Platforms
Comparison of Programming PlatformsComparison of Programming Platforms
Comparison of Programming PlatformsAnup Hariharan Nair
 
Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015iScripts
 
Python in the browser
Python in the browserPython in the browser
Python in the browserPyCon Italia
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCTim Burks
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCTim Burks
 
Java magazine jan feb 2018
Java magazine jan feb 2018Java magazine jan feb 2018
Java magazine jan feb 2018Acacio Martins
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson F. de A. Mafra
 
Mark asoi ppt
Mark asoi pptMark asoi ppt
Mark asoi pptmark-asoi
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students shafiq sangi
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVMjexp
 

La actualidad más candente (20)

The essence of the VivaCore code analysis library
The essence of the VivaCore code analysis libraryThe essence of the VivaCore code analysis library
The essence of the VivaCore code analysis library
 
Networked APIs with swift
Networked APIs with swiftNetworked APIs with swift
Networked APIs with swift
 
Php unit i
Php unit i Php unit i
Php unit i
 
Slides
SlidesSlides
Slides
 
IRJET- Mail Server Communication:PHP
IRJET-  	  Mail Server Communication:PHPIRJET-  	  Mail Server Communication:PHP
IRJET- Mail Server Communication:PHP
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
109842496 jni
109842496 jni109842496 jni
109842496 jni
 
Comparison of Programming Platforms
Comparison of Programming PlatformsComparison of Programming Platforms
Comparison of Programming Platforms
 
Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015
 
Programming in C++
Programming in C++Programming in C++
Programming in C++
 
Python in the browser
Python in the browserPython in the browser
Python in the browser
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Implementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPCImplementing OpenAPI and GraphQL services with gRPC
Implementing OpenAPI and GraphQL services with gRPC
 
Java magazine jan feb 2018
Java magazine jan feb 2018Java magazine jan feb 2018
Java magazine jan feb 2018
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
Mark asoi ppt
Mark asoi pptMark asoi ppt
Mark asoi ppt
 
What is python
What is pythonWhat is python
What is python
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVM
 

Destacado

Media Transmisi Wire
Media Transmisi WireMedia Transmisi Wire
Media Transmisi WireMuhamad XF
 
Company Profile of WishBeen
Company Profile of WishBeenCompany Profile of WishBeen
Company Profile of WishBeenWishBeen
 
Working with wildlife for the construction industry
Working with wildlife for the construction industryWorking with wildlife for the construction industry
Working with wildlife for the construction industryThe Ecology Consultancy
 
Wishbeen - For Travel Experts
Wishbeen - For Travel ExpertsWishbeen - For Travel Experts
Wishbeen - For Travel ExpertsWishBeen
 
Andrew Zimakas | Tapping Into Your Community for Support
Andrew Zimakas | Tapping Into Your Community for SupportAndrew Zimakas | Tapping Into Your Community for Support
Andrew Zimakas | Tapping Into Your Community for SupportCM1TO
 
HTC, Nokia offer giant choices among phablets
HTC, Nokia offer giant choices among phabletsHTC, Nokia offer giant choices among phablets
HTC, Nokia offer giant choices among phabletsabandonedtempta94
 
Document test 20131114
Document test 20131114Document test 20131114
Document test 20131114IdeaConseil
 
Julie Sheldon | Contest & Promotions
Julie Sheldon | Contest & PromotionsJulie Sheldon | Contest & Promotions
Julie Sheldon | Contest & PromotionsCM1TO
 
Pesent Perfect
Pesent PerfectPesent Perfect
Pesent PerfectLizzy94
 
Wow site and Beacon concept
Wow site and Beacon conceptWow site and Beacon concept
Wow site and Beacon conceptjfournaux
 
Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...
Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...
Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...Angad Malhotra
 
You can meet a innovative diving planning tool.
You can meet a innovative diving planning tool. You can meet a innovative diving planning tool.
You can meet a innovative diving planning tool. WishBeen
 
Ryan Ginsberg | Building Community Through Twitter
Ryan Ginsberg | Building Community Through TwitterRyan Ginsberg | Building Community Through Twitter
Ryan Ginsberg | Building Community Through TwitterCM1TO
 
Jonathan Sy | When Shit Hits the Fan
Jonathan Sy | When Shit Hits the FanJonathan Sy | When Shit Hits the Fan
Jonathan Sy | When Shit Hits the FanCM1TO
 
My uts dian
My uts dianMy uts dian
My uts diandian_dwi
 
моя проффесия
моя проффесиямоя проффесия
моя проффесияZHekaaaaaaaaa
 
Andrew Cherwenka | Measurement
Andrew Cherwenka | MeasurementAndrew Cherwenka | Measurement
Andrew Cherwenka | MeasurementCM1TO
 

Destacado (20)

Media Transmisi Wire
Media Transmisi WireMedia Transmisi Wire
Media Transmisi Wire
 
CleverCapital
CleverCapitalCleverCapital
CleverCapital
 
Company Profile of WishBeen
Company Profile of WishBeenCompany Profile of WishBeen
Company Profile of WishBeen
 
Working with wildlife for the construction industry
Working with wildlife for the construction industryWorking with wildlife for the construction industry
Working with wildlife for the construction industry
 
Dukhovnost spb
Dukhovnost spbDukhovnost spb
Dukhovnost spb
 
Tien ich cua Homyland 2
Tien ich cua Homyland 2Tien ich cua Homyland 2
Tien ich cua Homyland 2
 
Wishbeen - For Travel Experts
Wishbeen - For Travel ExpertsWishbeen - For Travel Experts
Wishbeen - For Travel Experts
 
Andrew Zimakas | Tapping Into Your Community for Support
Andrew Zimakas | Tapping Into Your Community for SupportAndrew Zimakas | Tapping Into Your Community for Support
Andrew Zimakas | Tapping Into Your Community for Support
 
HTC, Nokia offer giant choices among phablets
HTC, Nokia offer giant choices among phabletsHTC, Nokia offer giant choices among phablets
HTC, Nokia offer giant choices among phablets
 
Document test 20131114
Document test 20131114Document test 20131114
Document test 20131114
 
Julie Sheldon | Contest & Promotions
Julie Sheldon | Contest & PromotionsJulie Sheldon | Contest & Promotions
Julie Sheldon | Contest & Promotions
 
Pesent Perfect
Pesent PerfectPesent Perfect
Pesent Perfect
 
Wow site and Beacon concept
Wow site and Beacon conceptWow site and Beacon concept
Wow site and Beacon concept
 
Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...
Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...
Can platelet-rich plasma (PRP) improve bone healing? A comparison between the...
 
You can meet a innovative diving planning tool.
You can meet a innovative diving planning tool. You can meet a innovative diving planning tool.
You can meet a innovative diving planning tool.
 
Ryan Ginsberg | Building Community Through Twitter
Ryan Ginsberg | Building Community Through TwitterRyan Ginsberg | Building Community Through Twitter
Ryan Ginsberg | Building Community Through Twitter
 
Jonathan Sy | When Shit Hits the Fan
Jonathan Sy | When Shit Hits the FanJonathan Sy | When Shit Hits the Fan
Jonathan Sy | When Shit Hits the Fan
 
My uts dian
My uts dianMy uts dian
My uts dian
 
моя проффесия
моя проффесиямоя проффесия
моя проффесия
 
Andrew Cherwenka | Measurement
Andrew Cherwenka | MeasurementAndrew Cherwenka | Measurement
Andrew Cherwenka | Measurement
 

Similar a Hack language

PHP Web Development.pdf
PHP Web Development.pdfPHP Web Development.pdf
PHP Web Development.pdfSonia Simi
 
Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!Francesco Fullone
 
Federico Feroldi Php In Yahoo
Federico Feroldi Php In YahooFederico Feroldi Php In Yahoo
Federico Feroldi Php In YahooFederico Feroldi
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfburasyacob012
 
PhP Training Institute In Delhi
PhP Training Institute In DelhiPhP Training Institute In Delhi
PhP Training Institute In DelhiDivyaSharma84779
 
PHP Development Tools that will Work Through 2023
PHP Development Tools that will Work Through 2023PHP Development Tools that will Work Through 2023
PHP Development Tools that will Work Through 2023AResourcePool
 
PHP Training In Chandigar1.docx
PHP Training In Chandigar1.docxPHP Training In Chandigar1.docx
PHP Training In Chandigar1.docxExcellence Academy
 
Php vs asp.net most valuable differences to learn and select the best one f...
Php vs asp.net   most valuable differences to learn and select the best one f...Php vs asp.net   most valuable differences to learn and select the best one f...
Php vs asp.net most valuable differences to learn and select the best one f...Concetto Labs
 
Top 8 Powerful Tools Developers Use for Laravel Web Development.pdf
Top 8 Powerful Tools Developers Use for Laravel Web Development.pdfTop 8 Powerful Tools Developers Use for Laravel Web Development.pdf
Top 8 Powerful Tools Developers Use for Laravel Web Development.pdfMoonTechnolabsPvtLtd
 
Some Very Useful PHP Tools
Some Very Useful PHP ToolsSome Very Useful PHP Tools
Some Very Useful PHP ToolsSem Jacobs
 
PHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital WorldPHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital Worldcompany
 

Similar a Hack language (20)

Hack and HHVM
Hack and HHVMHack and HHVM
Hack and HHVM
 
PHP Web Development.pdf
PHP Web Development.pdfPHP Web Development.pdf
PHP Web Development.pdf
 
PHP
PHPPHP
PHP
 
Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!
 
Federico Feroldi Php In Yahoo
Federico Feroldi Php In YahooFederico Feroldi Php In Yahoo
Federico Feroldi Php In Yahoo
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
 
PhP Training Institute In Delhi
PhP Training Institute In DelhiPhP Training Institute In Delhi
PhP Training Institute In Delhi
 
PHP TRAINING
PHP TRAININGPHP TRAINING
PHP TRAINING
 
How PHP works
How PHP works How PHP works
How PHP works
 
Report.docx
Report.docxReport.docx
Report.docx
 
Programming language
Programming languageProgramming language
Programming language
 
PHP Development Tools that will Work Through 2023
PHP Development Tools that will Work Through 2023PHP Development Tools that will Work Through 2023
PHP Development Tools that will Work Through 2023
 
PHP for Software Development
PHP for Software DevelopmentPHP for Software Development
PHP for Software Development
 
PHP Training In Chandigar1.docx
PHP Training In Chandigar1.docxPHP Training In Chandigar1.docx
PHP Training In Chandigar1.docx
 
Php vs asp.net most valuable differences to learn and select the best one f...
Php vs asp.net   most valuable differences to learn and select the best one f...Php vs asp.net   most valuable differences to learn and select the best one f...
Php vs asp.net most valuable differences to learn and select the best one f...
 
Top 8 Powerful Tools Developers Use for Laravel Web Development.pdf
Top 8 Powerful Tools Developers Use for Laravel Web Development.pdfTop 8 Powerful Tools Developers Use for Laravel Web Development.pdf
Top 8 Powerful Tools Developers Use for Laravel Web Development.pdf
 
24307183 php
24307183 php24307183 php
24307183 php
 
Some Very Useful PHP Tools
Some Very Useful PHP ToolsSome Very Useful PHP Tools
Some Very Useful PHP Tools
 
PHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital WorldPHP Web Development: Empowering the Digital World
PHP Web Development: Empowering the Digital World
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 

Último

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxleah joy valeriano
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 

Último (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 

Hack language

  • 1. Hack: a new programming language for HHVM Posted last Thursday Infra · Culture · HipHop · Languages In a hurry? Try Hack now: http://hacklang.org/ Today we're releasing Hack, a programming language we developed for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming languages. We have deployed Hack at Facebook and it has been a great success. Over the last year, we have migrated nearly our entire PHP codebase to Hack, thanks to both organic adoption and a number of homegrown refactoring tools. We're also proud to release an open source version of Hack to the public at http://hacklang.org/ as part of our HHVM runtime platform, which will now support both Hack and PHP. Motivation Every PHP programmer is familiar with day-to-day tasks that can be tricky or cumbersome. The code above is a great example of a common mistake where a method could unexpectedly be called on a null object, causing an error that wouldn't be caught until runtime. Another example is a complex API, where developers may have a solid understanding of its semantics but still spend time looking up mundane method names in documentation. At Facebook scale — with thousands of engineers shipping new code twice a day — slowdowns like these are even more problematic. Before Hack, we had a simple language with a quick feedback loop — but how could we mitigate the sorts of problems described above? Could early error detection coexist with rapid iteration, all while preserving our investment in PHP? Could improved code analysis and introspection help make developers more productive with tools like auto-complete? Traditionally, dynamically typed languages allow for rapid development but sacrifice the ability to catch errors early and introspect code quickly, particularly on larger codebases. Conversely, statically typed languages provide more of a safety net, but often at the cost of quick iteration. We believed there had to be a sweet spot. Thus, Hack was born. We believe that it offers the best of both dynamically typed and statically typed languages, and that it will be valuable to projects of all sizes. The Hack language Hack has deep roots in PHP. In fact, most PHP files are already valid Hack files. We made a conscious choice not to support a handful of deprecated functions and features that were incompatible with static typing (e.g. “variable variables” and the extract() function). We have also added many new features that we believe will help make developers more productive. Our principal addition is static typing. We have developed a system to annotate function signatures and class members with type information; our type checking algorithm (the “type checker”) infers the rest. Type checking is incremental, such that even within a single file some code can be converted to Hack while the rest remains dynamically typed. Technically speaking, Hack is a “gradually typed*”* language: dynamically typed code interoperates seamlessly with statically typed code. Within Hack's type system, we have introduced several features such as generics, nullable types,
  • 2. type aliasing, and constraints on type parameters. These new language features are unobtrusive, so the code you write with Hack will still look and feel like the dynamic language to which PHP programmers are accustomed. However, Hack adds additional features beyond static type checking, including Collections, lambda expressions, and run-time enforcement of return types and parameter types. Collections provide a clean, type-safe alternative to PHP arrays. We designed them specifically to work well with static typing and generics. The Collections API offers many classic higher-order functions such as map() and filter() to facilitate functional programming styles. Lambda expressions give a concise syntax for creating closures. While PHP has closures, it requires the programmer to explicitly name the variables they need to use from enclosing scopes. With Hack's lambda expressions, we automatically infer these uses, saving you needless work. Lambda expressions make it more convenient to take full advantage of the Collections API. Run-time enforcement of return types and parameter types (including scalar types like int and string) provides safety beyond what can be checked statically while type annotations are being gradually added to a codebase. Run-time enforcement helps programmers detect and diagnose certain kinds of problems more easily, and it helps HHVM's JIT produce more efficient code by making it safe to trust type annotations for optimization purposes. Instantaneous type checking During development, a PHP programmer typically goes back and forth rapidly between the source code and the browser. Engineers can iterate as quickly as they need, testing and tuning an experience until it's perfect. Traditionally, a type checker would disrupt this feedback loop as it takes time to analyze the source code. We didn't want to slow the PHP workflow, so we came up with a new approach to reconcile instantaneous feedback with type safety. Our solution was to architect the type checker as a local server that watches the filesystem. The server keeps all information about the source code in memory and automatically updates itself when a file changes on disk. This approach has paid off: the type checker typically runs in less than 200 milliseconds and rarely takes more than a second, making it easy to integrate into the development workflow without introducing a noticeable delay. Code ion Hack's type safety and refactoring benefits grow the more it is used within a codebase. Understanding that it would be difficult for some code to be completely transitioned to Hack right away, it was important to us that Hack be developed such that it can coexist directly with other PHP files as it is being introduced incrementally. The rest of the conversion process, such as adding type annotations and using new language features, can be done as appropriate for the codebase. For example, a type annotation can be added for one function but left off another function, even in the same file. If a function parameter or class member does not have an explicit type annotation, the type checker considers its type to be dynamic, and it does not check the type of that value. Within Facebook, we found that our engineers appreciated Hack enough that they started converting the majority of their own code voluntarily. With millions of lines of code in our tree, we also wanted some form of automation, so we built and use a number of code modification tools to assist the process (which we are releasing as part of Hack). Don't worry, your PHP is safe!
  • 3. HHVM is still a PHP runtime, and we intend to keep it that way. In fact, we are working hard to reach parity with PHP-5. One of HHVM's top priorities is to run unmodified PHP-5 source code, both for the community and because we rely on third-party PHP libraries internally. HHVM is now a runtime that supports *both* PHP and Hack, so you can start to take advantage of Hack's new features incrementally. Have fun with Hack! We are delighted to open-source both Hack and the tools you can use to automatically convert your codebase. This is just the first step, and we are dedicated to continuing to evolve this software to make development even easier for both our own engineers and the broader community. Hack's value is *not* limited to big projects: with type information, good error messages, and fast feedback, small codebases can reap the benefits of Hack as well. Next month, we will also introduce the language at the Hack Developer Day on the Facebook campus in Menlo Park, and we hope to see you there in person or online. We would love to have your feedback on our work so far, and welcome you all to participate in the HHVM and Hack community. Acknowledgements There are many people who have contributed to the development of Hack. The core Hack team consists of Joel Beales, Eugene Letuchy, Gabriel Levi, Joel Marcey, Erik Meijer, Alok Menghrajani, Bryan O'Sullivan, Drew Paroski, James Pearce, Joel Pobar, and Joshua Van Dyke Watzman. A special thanks goes to our early community adopters for providing valuable feedback to make the language better: James Miller, Simon Welsh, Nils Adermann, Fabien Potencier, and Alexander Mols. Hack is written primarily in OCaml. We would like to thank the Gallium team (INRIA) for the development of the OCaml language, and the Ocsigen team (CNRS - University of Paris Diderot - INRIA) for the development of the js_of_ocaml part of Ocsigen. And, of course, thank you to everyone else who has helped make Hack the language it is today. The list is too exhaustive for a blog post, but you know who you are.