Top Related Projects
The Kotlin Programming Language.
The PHP Interpreter
Node.js JavaScript runtime ✨🐢🚀✨
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Empowering everyone to build reliable and efficient software.
Quick Overview
HHVM (HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP. Developed by Facebook, HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance compared to traditional PHP engines.
Pros
- High performance: HHVM's JIT compilation results in faster execution of PHP and Hack code
- Compatibility: Supports a large subset of PHP syntax and features
- Scalability: Designed to handle high-traffic websites and large-scale applications
- Active development: Regularly updated and maintained by Facebook and the community
Cons
- Learning curve: Requires familiarity with HHVM-specific configurations and optimizations
- Incomplete PHP compatibility: Some PHP extensions and features may not be fully supported
- Resource intensive: Can consume more memory compared to traditional PHP interpreters
- Limited adoption: Not as widely used as other PHP engines, potentially leading to less community support
Getting Started
To get started with HHVM, follow these steps:
- Install HHVM on your system (example for Ubuntu):
sudo apt-get update
sudo apt-get install software-properties-common apt-transport-https
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94
sudo add-apt-repository https://dl.hhvm.com/ubuntu
sudo apt-get update
sudo apt-get install hhvm
- Create a simple PHP or Hack file (e.g.,
hello.php
):
<?php
echo "Hello, HHVM!";
- Run the file using HHVM:
hhvm hello.php
For more advanced usage and configuration options, refer to the official HHVM documentation.
Competitor Comparisons
The Kotlin Programming Language.
Pros of Kotlin
- More modern language design with better null safety and functional programming features
- Fully interoperable with Java, allowing gradual adoption in existing projects
- Supported by Google for Android development, with a growing ecosystem
Cons of Kotlin
- Smaller community and ecosystem compared to PHP (which HHVM supports)
- Potentially slower compilation times, especially for large projects
- Steeper learning curve for developers coming from PHP or JavaScript
Code Comparison
Kotlin:
fun main() {
val numbers = listOf(1, 2, 3, 4, 5)
val doubled = numbers.map { it * 2 }
println(doubled)
}
HHVM (PHP):
<?hh
function main(): void {
$numbers = vec[1, 2, 3, 4, 5];
$doubled = Vec\map($numbers, $num ==> $num * 2);
print_r($doubled);
}
Summary
Kotlin is a modern, statically-typed language designed for JVM, Android, and web development. HHVM is a virtual machine for executing PHP code with improved performance. While Kotlin offers better language features and Android support, HHVM provides enhanced performance for existing PHP codebases. The choice between them depends on project requirements, existing infrastructure, and team expertise.
The PHP Interpreter
Pros of php-src
- Wider adoption and community support
- Better compatibility with existing PHP codebases
- More extensive documentation and learning resources
Cons of php-src
- Generally slower performance compared to HHVM
- Less focus on modern language features and optimizations
- Lacks some advanced features like async/await support
Code Comparison
php-src:
<?php
function hello($name) {
echo "Hello, $name!";
}
hello("World");
HHVM:
<?hh
function hello(string $name): void {
echo "Hello, $name!";
}
hello("World");
The main difference in this example is HHVM's use of the Hack language, which includes type annotations and stricter typing. HHVM supports both PHP and Hack, allowing for gradual adoption of Hack's features.
HHVM generally offers better performance for large-scale applications, particularly those using the Hack language. However, php-src remains the standard implementation for most PHP projects due to its widespread compatibility and extensive ecosystem support.
Both projects are actively maintained, with php-src focusing on incremental improvements to the PHP language, while HHVM continues to evolve the Hack language and optimize performance for large-scale applications.
Node.js JavaScript runtime ✨🐢🚀✨
Pros of Node.js
- Larger ecosystem with more packages and community support
- Better performance for I/O-bound tasks and asynchronous operations
- Easier to learn and use, especially for JavaScript developers
Cons of Node.js
- Less suitable for CPU-intensive tasks compared to HHVM
- Lacks static typing, which can lead to runtime errors
- Single-threaded nature can be a limitation for certain use cases
Code Comparison
Node.js:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
});
server.listen(8080);
HHVM (Hack):
<?hh
<<__EntryPoint>>
function main(): void {
$server = Server::create()
->withIP('127.0.0.1')
->withPort(8080)
->withDocumentRoot('/var/www')
->start();
}
Both examples show a basic HTTP server setup, but HHVM uses Hack language syntax and requires more boilerplate code. Node.js offers a more concise and familiar JavaScript approach, while HHVM provides stronger typing and potential performance benefits for certain applications.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
Pros of TypeScript
- Broader adoption and community support
- Seamless integration with JavaScript ecosystem
- Static typing for improved developer productivity and code quality
Cons of TypeScript
- Compilation step required, which can slow down development
- Learning curve for developers new to static typing
- Limited performance improvements compared to vanilla JavaScript
Code Comparison
TypeScript:
interface User {
name: string;
age: number;
}
function greet(user: User): string {
return `Hello, ${user.name}!`;
}
HHVM (Hack):
type User = shape(
'name' => string,
'age' => int,
);
function greet(User $user): string {
return "Hello, {$user['name']}!";
}
Key Differences
- TypeScript focuses on enhancing JavaScript with optional static typing, while HHVM is a virtual machine designed to execute PHP and Hack code.
- TypeScript compiles to JavaScript, whereas HHVM runs PHP and Hack directly.
- TypeScript has wider adoption in web development, while HHVM is more specialized for high-performance server-side applications.
Use Cases
- TypeScript: Web applications, Node.js projects, and large-scale JavaScript codebases
- HHVM: High-traffic websites, server-side applications requiring improved PHP performance
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Pros of runtime
- Broader language support, including C#, F#, and Visual Basic
- More active development and larger community support
- Cross-platform compatibility (Windows, macOS, Linux)
Cons of runtime
- Larger codebase and potentially more complex setup
- May have higher memory usage for certain applications
Code Comparison
HHVM (PHP):
<?hh
class Example {
public function greet(string $name): string {
return "Hello, $name!";
}
}
runtime (C#):
public class Example
{
public string Greet(string name)
{
return $"Hello, {name}!";
}
}
Key Differences
- HHVM focuses on PHP and Hack languages, while runtime supports multiple .NET languages
- HHVM uses JIT compilation for PHP, whereas runtime provides a complete .NET ecosystem
- runtime offers more extensive libraries and frameworks for various application types
Community and Ecosystem
- runtime has a larger and more diverse community due to its broader language support
- HHVM has a more specialized community focused on high-performance PHP applications
- Both projects are open-source, but runtime has more frequent updates and contributions
Performance Considerations
- HHVM may offer better performance for specific PHP workloads
- runtime provides optimized performance across various languages and application types
- Both projects aim to improve execution speed and resource utilization
Empowering everyone to build reliable and efficient software.
Pros of Rust
- Memory safety without garbage collection, leading to better performance and lower resource usage
- Strong type system and ownership model, reducing runtime errors and improving concurrency
- Growing ecosystem with a focus on systems programming and web assembly
Cons of Rust
- Steeper learning curve due to unique concepts like ownership and lifetimes
- Longer compilation times compared to HHVM's JIT compilation
- Less mature ecosystem for web development compared to PHP/HHVM
Code Comparison
Rust example:
fn main() {
let numbers = vec![1, 2, 3, 4, 5];
let sum: i32 = numbers.iter().sum();
println!("Sum: {}", sum);
}
HHVM (PHP) example:
<?hh
function main(): void {
$numbers = vec[1, 2, 3, 4, 5];
$sum = \HH\Lib\Vec\sum($numbers);
echo "Sum: $sum\n";
}
Summary
Rust and HHVM serve different purposes. Rust is a systems programming language focusing on safety and performance, while HHVM is a virtual machine for executing PHP code. Rust offers better memory safety and performance but has a steeper learning curve. HHVM provides faster PHP execution but is limited to PHP-based applications. The choice between them depends on the specific project requirements and developer expertise.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
HHVM
HHVM page | HHVM documentation | Hacklang page | General group | Dev group | Twitter
HHVM is an open-source virtual machine designed for executing programs written in Hack. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining amazing development flexibility.
HHVM should be used together with a webserver like the built in, easy to deploy Proxygen, or a FastCGI-based webserver on top of nginx or Apache.
Installing
If you're new, try our getting started guide.
You can install a prebuilt package or compile from source.
Running
You can run standalone programs just by passing them to hhvm: hhvm example.hack
.
If you want to host a website:
- Install your favorite webserver. Proxygen is built into HHVM, fast and easy to deploy.
- Install our package
- Start your webserver
- Run
sudo /etc/init.d/hhvm start
- Visit your site at
http://.../main.hack
Our getting started guide provides a slightly more detailed introduction as well as links to more information.
Contributing
We'd love to have your help in making HHVM better. If you're interested, please read our guide to contributing.
License
HHVM is licensed under the PHP and Zend licenses except as otherwise noted.
The Hack typechecker is licensed under the MIT License except as otherwise noted.
The Hack Standard Library is licensed under the MIT License except as otherwise noted.
Reporting Crashes
See Reporting Crashes for helpful tips on how to report crashes in an actionable manner.
Security
For information on reporting security vulnerabilities in HHVM, see SECURITY.md.
FAQ
Our user FAQ has answers to many common questions about HHVM, from general questions to questions geared towards those that want to use.
There is also a FAQ for contributors to HHVM.
Top Related Projects
The Kotlin Programming Language.
The PHP Interpreter
Node.js JavaScript runtime ✨🐢🚀✨
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Empowering everyone to build reliable and efficient software.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot