-
Notifications
You must be signed in to change notification settings - Fork 4
Rationale
PHP is one of the leading choices for writing web applications, and there are a couple of reasons for this. PHP is available almost everywhere, and lets you hack into and iterate fairly quickly. Just change a file, hit refresh, and all your changes will be there. Unfortunately, PHP is not a well designed language, and it's easy to make mistakes that lead to huge security holes. The ecosystem, while big, isn't as easy to use as some alternatives (like JavaScript's Node.js), so people end up reinventing things that already exist quite often. Lastly, the language doesn't have a good support for concurrency, which is essential as web applications grow larger.
Purr aims to provide the same benefits of PHP, without the problems the language has. It focuses on ease of development, concurrency, and security.
Purr compiles to JavaScript and runs on top of Node.js. Not only Node.js is easy to setup and runs on several platforms, but it has a large ecosystem that is really to use. Purr will ship with its own package manager that's built on top of npm to make working with web applications even easier.
PHP allows you to mix PHP code and HTML code, and has built-in tools to talk to SQL databases. However, these tools are insecure, and not easy to abstract over. Purr solves these two problems by turning both HTML and SQL into actual objects.
Both examples will do the right thing, regardless of the input for these functions.
let $title page =>
<html>
<head>
<title>{ $title }</title>
</head>
<body>
<h1>Hello, world.</h1>
</body>
</html>
let $table titles => sql(SELECT title FROM { $table })
With Purr you can keep your workflow of changing the files and just hitting refresh on the webpage to see the changes.
Purr has built-in support for concurrency. You write your code as if it was sequential, and the language will take care of everything for you:
GET / _ => do {
$users <- db all-users;
$data <- parallel <| $users map: (db get-user-info: _)
return Body: ($data render-index)
}