{"_id":"58f1030e52fe830f0030868d","__v":1,"category":{"_id":"58e6b68eb1eece19008b81fe","project":"5612c2a00fbdb60d00e4c7d1","version":"5612c2a00fbdb60d00e4c7d4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-04-06T21:43:42.570Z","from_sync":false,"order":1,"slug":"api","title":"Lasp"},"parentDoc":null,"version":{"_id":"5612c2a00fbdb60d00e4c7d4","__v":7,"project":"5612c2a00fbdb60d00e4c7d1","createdAt":"2015-10-05T18:34:08.611Z","releaseDate":"2015-10-05T18:34:08.611Z","categories":["5612c2a10fbdb60d00e4c7d5","58e6b64bc397de1b00173c09","58e6b68eb1eece19008b81fe","58e6b6d185ec873100be9734","58f5e5c2616bbb1b00d54c15","58f5eaa74c413f19007a2858","58f767a79c723f19004e1ca9"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.0.1","version":"0.0.1"},"project":"5612c2a00fbdb60d00e4c7d1","githubsync":"","user":"5612c290c0731b0d00625078","updates":["58f36e02f7f9280f00775be0"],"next":{"pages":[],"description":""},"createdAt":"2017-04-14T17:12:46.370Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Lasp is about writing correct distributed programs.\n\nThe goal of Lasp is to allow you to write a program once and know that it will behave the same whether it is executed on one computer or distributed across many.\n\nTo demonstrate, consider the following dataflow program running on a single node.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/599ef8d-confluence-1.png\",\n        \"confluence-1.png\",\n        2835,\n        580,\n        \"#0b0a0a\"\n      ]\n    }\n  ]\n}\n[/block]\nIn this example, both `A` and `B` are sets, and every time `A` changes we will repopulate `B` with the new value of the transformation applied to `A`.\n\nNow, consider if we replicate this computation on every node in the cluster and each of these nodes is going to communicate with other nodes in the cluster to propagate changes to their copies of both `A` and `B`.\n\nIn this diagram, unidirectional arrows indicate the direction that data can flow, and bidirectional arrows indicate replication between objects, where changes can propagate in either direction, between different replicas running on different nodes.  In this example, changes can freely propagate between replicas of `A` and replicas of `B` through a background anti-entropy protocol that ensures each replica is kept up-to-date with its peer replicas.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/862dedc-confluence-2.png\",\n        \"confluence-2.png\",\n        2835,\n        1654,\n        \"#0d0c0b\"\n      ]\n    }\n  ]\n}\n[/block]\nNow, because of the realities of distributed systems, there's multiple schedules that events can take based on network availability and who the nodes choose to randomly propagate changes with each other.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"What's a schedule?\",\n  \"body\": \"When we say schedule, we refer to one possible order all of the messages in a given execution might be delivered in.  In distributed systems, there exists an extremely large space of possible schedules, where only some of those schedules may or may not produce the same outcome.\"\n}\n[/block]\nFor instance, consider the following schedule.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/82ea886-confluence-3.png\",\n        \"confluence-3.png\",\n        2835,\n        1654,\n        \"#060708\"\n      ]\n    }\n  ]\n}\n[/block]\nIn this schedule, designated by the red color, each node propagates their value of `A` to other nodes in the system, then each apply the transformation to produce a new value of `B`.\n\nBut, let's consider another completely valid schedule.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8ba33ec-confluence-4.png\",\n        \"confluence-4.png\",\n        2835,\n        1654,\n        \"#060607\"\n      ]\n    }\n  ]\n}\n[/block]\nIn this schedule, designated by the purple color, each node propagates their value of `B` after the first node in the system transforms  its `A` into its value for `B`.\n\nThese different schedules are just a few of the many ways that information may flow through a distributed system, and it can be complicated to reason about all of the ways that a distributed computation might resolve. Lasp removes this complexity completely, and ensures that your programs compute the same results for all schedules.\n\nRegardless of schedule, they are reducible, or equivalent, to the original sequential specification.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/4322f3d-confluence-1.png\",\n        \"confluence-1.png\",\n        2835,\n        580,\n        \"#0b0a0a\"\n      ]\n    }\n  ]\n}\n[/block]\nDevelopers no longer need to worry about the order in which messages are delivered or worry about any of the specific details around data replication and distribution.  Furthermore, in Lasp, altering the propagation strategy or network topology does not change program behavior.\n\nLasp is not [yet!] as expressive as common languages like Python or Java, or even recent languages like Go or Rust. To achieve its properties, Lasp guides the programmer to use [Conflict-free Replicated Data Types (CRDTs)](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) and to program using operations with special mathematical properties (monotonic, order-preserving homomorphisms).\n\nSpecial thanks for [Frank McSherry](http://www.frankmcsherry.org/about/) for his valuable input on this article.","excerpt":"Lasp is a programming model for building correct distributed applications.","slug":"what-is-lasp","type":"basic","title":"What is Lasp?"}

What is Lasp?

Lasp is a programming model for building correct distributed applications.

Lasp is about writing correct distributed programs. The goal of Lasp is to allow you to write a program once and know that it will behave the same whether it is executed on one computer or distributed across many. To demonstrate, consider the following dataflow program running on a single node. [block:image] { "images": [ { "image": [ "https://files.readme.io/599ef8d-confluence-1.png", "confluence-1.png", 2835, 580, "#0b0a0a" ] } ] } [/block] In this example, both `A` and `B` are sets, and every time `A` changes we will repopulate `B` with the new value of the transformation applied to `A`. Now, consider if we replicate this computation on every node in the cluster and each of these nodes is going to communicate with other nodes in the cluster to propagate changes to their copies of both `A` and `B`. In this diagram, unidirectional arrows indicate the direction that data can flow, and bidirectional arrows indicate replication between objects, where changes can propagate in either direction, between different replicas running on different nodes. In this example, changes can freely propagate between replicas of `A` and replicas of `B` through a background anti-entropy protocol that ensures each replica is kept up-to-date with its peer replicas. [block:image] { "images": [ { "image": [ "https://files.readme.io/862dedc-confluence-2.png", "confluence-2.png", 2835, 1654, "#0d0c0b" ] } ] } [/block] Now, because of the realities of distributed systems, there's multiple schedules that events can take based on network availability and who the nodes choose to randomly propagate changes with each other. [block:callout] { "type": "warning", "title": "What's a schedule?", "body": "When we say schedule, we refer to one possible order all of the messages in a given execution might be delivered in. In distributed systems, there exists an extremely large space of possible schedules, where only some of those schedules may or may not produce the same outcome." } [/block] For instance, consider the following schedule. [block:image] { "images": [ { "image": [ "https://files.readme.io/82ea886-confluence-3.png", "confluence-3.png", 2835, 1654, "#060708" ] } ] } [/block] In this schedule, designated by the red color, each node propagates their value of `A` to other nodes in the system, then each apply the transformation to produce a new value of `B`. But, let's consider another completely valid schedule. [block:image] { "images": [ { "image": [ "https://files.readme.io/8ba33ec-confluence-4.png", "confluence-4.png", 2835, 1654, "#060607" ] } ] } [/block] In this schedule, designated by the purple color, each node propagates their value of `B` after the first node in the system transforms its `A` into its value for `B`. These different schedules are just a few of the many ways that information may flow through a distributed system, and it can be complicated to reason about all of the ways that a distributed computation might resolve. Lasp removes this complexity completely, and ensures that your programs compute the same results for all schedules. Regardless of schedule, they are reducible, or equivalent, to the original sequential specification. [block:image] { "images": [ { "image": [ "https://files.readme.io/4322f3d-confluence-1.png", "confluence-1.png", 2835, 580, "#0b0a0a" ] } ] } [/block] Developers no longer need to worry about the order in which messages are delivered or worry about any of the specific details around data replication and distribution. Furthermore, in Lasp, altering the propagation strategy or network topology does not change program behavior. Lasp is not [yet!] as expressive as common languages like Python or Java, or even recent languages like Go or Rust. To achieve its properties, Lasp guides the programmer to use [Conflict-free Replicated Data Types (CRDTs)](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) and to program using operations with special mathematical properties (monotonic, order-preserving homomorphisms). Special thanks for [Frank McSherry](http://www.frankmcsherry.org/about/) for his valuable input on this article.