Migrate contributors docs from google docs

This commit is contained in:
Matej Sima 2019-06-03 18:48:54 +02:00
parent 0f6f02328a
commit 1b9e5cd7e6
17 changed files with 232 additions and 13 deletions

View File

@ -0,0 +1,18 @@
---
id: back-end
title: Back End
---
The Back-End is the part that compiles down to Michelson. Instead of a single compilation step, it is separated in two parts.
## Transpiler and Mini_C
The Transpiler is a function that takes as input the Typed AST, and outputs expressions in a language that is basically a Michelson based on with named variables and first-class-environments.
On the one hand, there are cases in the AST like `E_if_bool` or `E_make_empty_list` that would be directly translated in Michelson like `IF {} {}` or `NIL`.
On the other hand, there are cases in the AST like `E_variable` or `E_environment_select` that specifically target the compiler.
The files of the Transpiler are in `transpiler/`, while those of Mini_c are in `mini_c/`.
## Compiler
The previous LIGOs compilation to Michelson model was quite complicated. The current one is quite straightforward, where the environment of variables (x -> 12, y -> “foo”) is compiled as Michelson stack (12 :: foo).
It has been simplified for multiple reasons:
Having a simple model reduces its number of points of failure.
Having a simple model makes optimizing it easier.
We submitted a change to the Tezos protocol that actually make it more efficient.

View File

@ -0,0 +1,15 @@
---
id: front-end
title: Front End
---
The Front-End is the part that deals with all syntactical matters. LIGO supports multiple Front-Ends. Each Front-End is composed of three different parts.
## Parser
A Parser is a function that takes a string of source code and outputs a structured representation of the program. This part usually uses Menhir, a parser generator compatible with OCaml.
Its files are in `parser/parser_name`.
## Concrete Syntax Tree
The CST is the aforementioned structured representation of the program. Is is structurally very close to the source code, and is mostly an intermediary there because manipulating string is not practical.
Its files are in `parser/parser_name`.
## Simplifier
A Simplifier is a function that takes a CST and outputs the corresponding Common AST. This is the actual bridge between a given syntax and LIGO.
Its files are in `simplify/parser_name`.

View File

@ -0,0 +1,16 @@
---
id: middle-end
title: Middle End
---
The Middle-End is the core of LIGO. It is also composed of three parts.
## Common AST
The Common AST is the closest thing to what could be called “LIGO lang”. As such, it should be as simple as possible. Collapsing particular cases in more general constructs is encouraged. Documenting it is crucial for people wholl write new parsers or editor support for Front-end related things.
Its files are in `ast_simplified/`, of interest is the definition of the AST itself in `ast_simplified/types.ml`.
## Type Checker
The Type Checker, among other things, checks that a given AST is valid with regard to type-safety. It also annotates expressions with their types, free-variables and local environments.
As time passes, we want to make the type-system stronger, to encode arbitrarily complex properties in an extensible manner.
Its files are in `typer/`.
## Typed AST
The Typed AST is the result of Type Checker. On top of it, we also want to define/export many features aiming at making building tools on top LIGO as easy as possible.
Its files are in `ast_typed/`, of interest is the definition of the Typed AST itself in `ast_typed/types.ml`.

View File

@ -0,0 +1,16 @@
---
id: overview
title: Overview
---
After going through the design principles and a few considerations linked to them, getting the Big Picture needs diving in technical matters.
![LIGO Overview](/img/big-picture-overview.png)
As shown in the Schema, LIGOs compiler is separated in roughly 3 separate parts:
- The Middle End. This is the core of LIGO. It defines its core data-structure (the Common AST), and its type-checking algorithm.
- The Front End. This is the bridge between a given syntax and the Common AST.
- The Back End. This is the bridge between the Common AST and a given compilation target. Currently, our only target is Michelson, but well also target Marigold, and if Tezos moves to Web Assembly, Web Assembly.

View File

@ -0,0 +1,21 @@
---
id: vendors
title: Vendors
---
Next to LIGOs main pipeline, we use some other libraries, that are in the folder `vendors`.
## ligo-utils
This, quite expectedly, defines utilities that are used in LIGO.
There are three kinds of utilities, corresponding to their dependencies.
`tezos-utils` contain utilities that depend on some Tezos libraries.
`proto-alpha-utils` contain utilities that depend on the compilation of some Tezos protocol. It is very big and thus cant be compiled in JS. This is because of a dependency to this that we dont have LIGO in the browser yet.
`simple-utils` contain most utilities. For instance, in `simple-utils` are `X_list` and `X_option`, that extend the `List` module and the `option` type found in `Pervasives`.
Of particular interest in `simple-utils` is `trace.ml`, a module used pervasively in LIGOs code-base. It deals with exceptions (and soon enough debugging annotations) in a functional manner. It offers a lot of utilities to build, combine and propagate exceptions. Given its used everywhere, that it relies on some advanced features of OCaml (higher order functions, ppx preprocessing) and that it exposes **a lot** of functions, its a good idea to look at this files documentation.
## tezos-modded
`tezos-modded` is a modded version of Tezos. There are modifications in it that are quite useful (exposing more functions from the protocol, giving more options to functions already defined), but not integrated yet.
It should in the end be integrated into the Tezos protocol, but until then, we use this.

View File

@ -0,0 +1,40 @@
---
id: getting-started
title: Getting started
---
## Where
As weve seen, LIGO is big, as such, it is easier to start focus on a specific part of LIGO. As very vague suggestions:
If you want to immediately see the result of your contributions, you might want to start with the Front-End. This is what most people will directly see of LIGO.
If you want to get into Programming Language Theory, you might want to start with the Middle-End. This is where the Type System and the Language Definition are (the closest thing so far that youll find in a research paper).
If you want to get into the nitty gritty details of compiling to special targets, youll want to focus on the Back-End.
If you want to develop tooling on top of LIGO (editor integration, for instance), youll want to look at `Ast_typed/types.ml`. This is where most information that is relevant to devs will be (for now).
If you really want to get a grasp of the whole pipeline, search for issues tagged with “Everything”, theyll have you look at multiple parts of the code base.
## What
Likely, the first issues will be about:
Adding tests
Extending the languages by adding new operators
Adding tests
Refactoring
Writing documentation and tutorials for users
Adding tests
Writing internal documentation when you understand a part of the code base
>Tests are **really** important, we dont have lots of them, and mostly regression ones. This cant be stressed enough. Some features are missing not because we cant add them, but because we dont know so as no tests tell us they are missing.
## How
Issues will be added to the Gitlab, tagged with On-boarding and Front-End / Middle-End / Back-End / Everything. If you try to tackle one issue, and you have **any** problem, please tell us, by creating a new Gitlab issue, contacting us on Riot, Discord or even by mail! Problems might include:
Installing the repository or the tools needed to work on it
OCaml weirdness
Understanding undocumented parts of the code base
Documented parts of the code base too
**Anything really**
---
## FAQ
### I dont know much about OCaml, where should I start? What should I have in mind?
Id suggesting going through Real World OCaml to get a feel for the language, to know what are its features, and to know what to Google when youre lost.
Beyond that, Id say, start hacking! Either on LIGOs code base, or on any personal project.
There is a Discord server if you want real-time help (which makes things go way faster than waiting for an answer on stackoverflow or looking mindlessly at the monitor).
### I want to add [X] to LIGO! Where should I begin?
Trying to add a new feature from scratch instead of building upon one can be quite complicated. However, if youre motivated, contact us! Well tell you what we see as the most likely plan to get the result you want to achieve.

View File

@ -1,6 +0,0 @@
---
id: introduction
title: Introduction
---
test

View File

@ -0,0 +1,10 @@
---
id: origin
title: Origin
---
LIGO is a programming language that aims to provide developers with an uncomplicated and safer way to implement smart-contracts. LIGO is currently being implemented for the Tezos blockchain and as a result, it compiles down to Michelson - the native smart-contract language of Tezos.
> Smart-contracts are programs that run within a blockchain network.
LIGO was initially meant to be a language for developing Marigold, on top of a hacky framework called Meta-Michelson. However, due to the attention received by the Tezos community, a decision has been put into action to develop LIGO as a standalone language that will support Tezos directly as well.

View File

@ -0,0 +1,45 @@
---
id: philosophy
title: Philosophy
---
To understand LIGOs design choices, its important to get its philosophy. There are two main concerns that we have in mind when building LIGO.
## Safety
Once a smart-contract is deployed, it will likely be impossible to change it. You must get it right on the first try, and LIGO should help as much as possible. There are multiple ways to make LIGO a safer language for smart-contracts.
### Automated Testing
Automated Testing is the process through which a program will run some other program, and check that this other program behaves correctly.
There already is a testing library for LIGO programs written in OCaml that is used to test LIGO itself. Making it accessible to users will greatly improve safety. A way to do so would be to make it accessible from within LIGO.
### Static Analysis
Static analysis is the process of having a program analyze another one.
For instance, type systems are a kind of static analysis through which it is possible to find lots of bugs. There is already a fairly simple type system in LIGO, and we plan to make it much stronger.
### Conciseness
Writing less code gives you less room to introduce errors and that's why LIGO encourages writing lean rather than chunky smart-contracts.
---
## Ergonomics
Having an ergonomic product is crucial on multiple levels:
Making features easily accessible ensures theyll actually get used.
Not wasting users time on idiosyncrasies frees more time for making contracts safer or building apps.
Keeping users in a Flow state makes it possible to introduce more complex features in the language.
There are multiple ways to improve ergonomics.
### The Language
LIGO should contain as few surprises as possible. This is usually known as the principle of least surprise.
Most programmers who will use LIGO have already spent a lot of time learning to develop in an existing language, with its own set of conventions and expectations. These expectations are often the most important to accommodate. This is why C-style syntaxes are especially popular (e.g. JavaScript), C-style is well known and new languages want to take advantage of that familiarity. Therefore as an extension of the principle of least surprise, LIGO supports more than one syntax. The least surprising language for a new developer is the one that they have already learned how to use. Its probably not practical to replicate the syntax of every programming language, so LIGO takes the approach of replicating the structure used by languages from a particular paradigm.
It is packaged in a Docker container, so that no particular installation instructions are required.
### Editor Support
Without editor support, a lot of manipulations are very cumbersome. Checking for errors, testing, examining code, refactoring code, etc. This is why there is ongoing work on editor support, starting with highlighting and code-folding.
### Docs
Docs include documentation of the languages, tutorials, as well as examples and design patterns.
Were a long way from there. But having extensive docs is part of our goals.

View File

@ -0,0 +1,20 @@
---
id: long-term
title: Longer term
---
Soon enough, the Schema for the front-end will look like this:
![LIGO Overview](/img/generic-front-end.png)
Basically, as we support more syntaxes (up to half a dozen), well have a bigger need for a unified representation and generation of the helpers around it.
For instance:
Parsers. So far, parsers are generated by LR grammars. LR grammars have a steep learning curve, regularly making not worth it for someone to learn the whole formalism to extend a given grammar with a few cases. Generating those LR Grammars would thus save a lot of time.
Displayers. The idea is that if you can parse and display code in a given syntax, it becomes much easier to have a translator between each syntax. So that not only it becomes possible for users to write code in their favorite syntax, but also to only read code in their favorite syntax.
BNFs. BNF grammars are a common formalism to represent grammars. They are understood by many tools, and are an easy way to document a given syntax.
## Super Type System
Soon enough, the Schema for the middle-end will look like this:
![LIGO Overview](/img/super-type-system.png)
Basically, this schema shows that the Back-End will stop being the main consumer of the Typed AST, and the External World will in its stead.
As such, annotating the AST with quality information, documenting it and exposing the libraries that produced the information in the first place will be paramount.
The imagined type-system so far is a mixture of MLF, extensible data-types and Algebraic Effects.

View File

@ -0,0 +1,20 @@
---
id: short-term
title: Short term
---
## Documentation and Testing
We lack documentation and tests. Top priority.
Tests are needed at multiple levels:
Unit tests. Most utility functions should be tested individually.
Interface tests. Parts of the pipeline (Typer, Transpiler-Compiler, etc.) should be tested as black boxes.
Integration tests. Typical user scenarios, as interacted with the CLI, should be tested.
## Exposing Features
Many features have already been developed or nearly developed, and mostly need to be shown some attention, and then be exposed to the outside world, for instance:
Testing LIGO code
Step-by-step interpreter
LIGO in the browser
Propagating source locations for error messages
Dry-running a contract
## Refactoring
For the longer-term, its crucial to refactor big parts of the code base. This is needed to lower the complexity of the code base, so that its easier both for everyone (including API consumers) to interact with it.

View File

@ -5,6 +5,15 @@
"API": ["api-cli-commands"]
},
"contributors-docs": {
"Introduction": ["contributors/introduction"]
"Introduction": ["contributors/origin", "contributors/philosophy"],
"Big Picture": [
"contributors/big-picture/overview",
"contributors/big-picture/front-end",
"contributors/big-picture/middle-end",
"contributors/big-picture/back-end",
"contributors/big-picture/vendors"
],
"Road Map": ["contributors/road-map/short-term", "contributors/road-map/long-term"],
"Contributing": ["contributors/contributing/getting-started"]
}
}

View File

@ -40,7 +40,7 @@ const siteConfig = {
headerLinks: [
{doc: 'setup-installation', label: 'Docs'},
{doc: 'api-cli-commands', label: 'CLI'},
{doc: 'contributors/introduction', label: 'Contributors'}
{doc: 'contributors/origin', label: 'Contributors'}
],
// If you have users set above, you add it here:

View File

@ -15,11 +15,6 @@
@media only screen and (min-width: 1500px) {
}
ul {
max-width: 350px;
margin: 0 auto;
text-align: left;
}
.projectTitle small {
max-width: 500px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB