State of the Languages

Welcome to the first post in the Tezos language series. We’ll give you a peek behind the curtain of Tezos smart contract language development on a weekly basis.

Let us know if you have

  • feedback
  • suggestions
  • a language you would like to add

This week in development

LIGO

The LIGO team was pelted with GitLab issues and spent most of their time keeping up.

Developers made suggestions as well as bug reports via Gitlab—a lot of them—so LIGO will adjust their process to sort bugs and suggestions into different categories in order to prioritize better.

SmartPy

The SmartPy team worked hard this week to finish their next release.

In addition to new features they will announce soon, this release will be SmartPy’s first open source version.


Thanks for reading, and check back next week for a new update!

Eowyn on behalf of the LIGOlang team

8 Likes

Readers, thank you for your excellent feedback on our last report. We hope you enjoy this week’s insights into Tezos smart contract language development.

Let us know if you have:

  • feedback
  • suggestions
  • a language you would like to add

Recent development

Albert

The Albert team recently submitted an academic article to the 2020 edition of the Trusted Smart Contract Workshop. It provides, among other things,

  • an overview of the current state of Albert
  • details on how Albert compiles to Michelson
  • an example smart contract written in Albert

For more detail you can peruse their academic article here:

Albert, an intermediate smart-contract language for the Tezos blockchain

LIGO

The LIGO team has been working on a diverse set of improvements. They:

  • changed the calling conventions in CameLIGO and ReasonLIGO to make them more similar to OCaml/Reason. In particular, the following equivalences now hold, as one would expect:

    fun x y -> z
      ~=
    fun x -> fun y -> z
    
    (* when f is not a built-in operator: *)
    f x y
      ~=
    (f x) y
    
  • fixed a bug which prevented using failwith in both branches of a conditional.

    let main ((b, _) : bool * unit) =
      if b
      then failwith "b is true"
      else failwith "b is false"
    
  • improved many unhelpful “not a X” type errors, along with errors related to typing built-in operators (e.g. “wrong types”, “bad X”.)

  • added a record update operation to all syntaxes, e.g. {r with b = 2048; c = 42} in CameLIGO.

  • added support for Tezos key and signature literals as type-annotated base58 strings. For example ("edpk..." : key).

  • added syntax for ‘attributes’ to all syntaxes, including an “inline” hint which will encourage the compiler to inline a particular definition, even if it is used more than once.

SmartPy

The SmartPy team shipped its first open source release this week!

Now they are back to working on SmartPy core current projects:

  • the testing framework
  • Michelson static analysis / decompilation.

Thank you for reading. Check back soon for more updates!

Eowyn on behalf of the LIGOlang team

3 Likes

Thank you for following the latest in Tezos smart contract language development! We’re introducing two new Tezos smart contract languages in this installment: SCaml and Archetype.

Let us know if you have:

  • feedback or suggestions
  • a language you would like to add

Recent development

Archetype

The Archetype team worked on preparing the next release: 0.1.13

  • Reorganized tests with more than 220 unit tests (previously ~50 tests).

  • Implemented the ‘rational’ type. Rational values enable easy formulation of computations, like percentage and ratio. For example, in the following snippet, the exec action transfers 20% of the transferred amount to the argument address dest:

    archetype rational_rat_tez_mult
    action exec (dest : address) {
    effect {
        var m = 0.2 * transferred;
        transfer m to dest
        }
    }
    

    It is transcoded to amount div 5 where div is the euclidean division.

  • Implemented the duration type. Duration values are used to compute dates by addition/subtraction of a duration to a date. In the following snippet, the exec action transfers if current date is one week after last_exec date

    archetype rational_duration
    variable last_exec : date = 2020-01-01
    action exec (dest : address) {
        called by admin
        effect {
            if now > last_exec + 1w then (
            last_exec := now;
            transfer transferred to dest
            )
        }
    }
    

LIGO

The LIGO team is making its way towards a more mature compiler:

  • Refactoring the AST to turn some built-in cases into functions. The more expressive the type system, the more cases we can turn into functions, and the less cases there are, the easier it is to modify the compiler. The new typechecker helps as it slowly passes more and more tests.

  • Improved the documentation by rewriting a large chunk of it and automatically testing the examples in the docs. Experience tells us these can quickly get out of sync, and the CI is more proactive in noticing errors than we could ever be.

  • Working on an interpreter for LIGO independent of the Michelson backend, to be able to unit-test LIGO code directly in LIGO.

  • Error messages are improving everywhere: after the work on the current typer’s error messages, we’re just starting work on propagating source locations and other info to know where errors come from in the new typer. The ReasonLigo parser errors are also being improved. Finally, some lexical checks have been added for duplicate constructors or record fields, use of reserved words as identifiers, etc.

  • An [@@inline] (in CameLIGO, and [@inline] in ReasonLIGO) annotation was added, it indicates that a function should be inlined at its call sites

Better task management:

  • Increased visibility for issues that need review from multiple people

  • Developing new processes so intentionally delayed tasks are not forgotten

In the larger context of the community:

  • we have worked on making Tezos more efficient (investigation in gas pricing, storage and amendments)

  • we’re preparing for the WebAssembly summit and for upcoming training at Nomadic Labs on February 12th (https://training.nomadic-labs.com/training.html).

SCaml

  • The first Docker image of SCaml is out at https://hub.docker.com/repository/docker/dailambda/scaml. It’s still simple but you can try SCaml easily by running:

    $ docker run dailambda/scaml:1.0.3 scamlc xxx.ml
    
  • Implemented the type-checking of classes of types (such as comparable, packable, storable, and parameterable) in SCaml so that invalid uses of comparisons, closure creations, contract storages and parameters are detected at SCaml level.

  • Added --convert and --revert options to scamlc command to convert and revert SCaml values to Michelson values.

  • ML types are converted to Michelson types now with annotations of record field names and variant constructor names. For example, the following ML type definition:

    type config = 
      { title          : string
      ; beginning_time : timestamp
      ; finish_time    : timestamp
      }
            
    type action = 
      | Vote of string
      | Init of config
    

    is converted to the following Michelson type, with %-annotations:

    (or :action
       (string %Vote)
       (pair :config %Init
          (string %title)
          (pair (timestamp %beginning_time) (timestamp %finish_time)))) 
    

    This makes the output Michelson code easier to read, especially for deciphering the structure of storages and parameters.

SmartPy

The SmartPy team has continued working on

  • the testing framework

  • decompilation

  • new constructions to handle lambdas

  • inter-contract communication


Thanks for reading, and check back soon for our next update!

Eowyn on behalf of the LIGOlang team

1 Like

Thank you for following the latest in Tezos smart contract language development!

Let us know if you have:

  • feedback or suggestions
  • a language you would like to add

Recent development

Albert

No recent updates.

Archetype

The Archetype team added several new features:

  • addupdate method for assets

     archetype effect_method_asset_addupdate
     ...
     action exec () {
       effect {
         my_asset.addupdate("my_id", {value = 3})
       }
     }
    

    is equivalent to

     archetype effect_method_asset_addupdate
     ...
     action exec () {
       effect {
         if (my_asset.contains("my_id")) then
           my_asset.update("my_id", {value = 3})
         else
           my_asset.add({id = "my_id"; value = 3})
       }
     }
    
  • bytes as a buitin type

    variable b : bytes = 0x1af0
    
  • a_contract.my_entry(args) has been replaced by transfer 0tz to a_contract call my_entry(args)

  • Froze api verification for release

  • Continued to add tests for verification (~20 tests)

In addition, they began to write a language reference page, which you can find here:
https://docs.archetype-lang.org/archetype-language/archetype-reference

LIGO

The LIGO team worked on a major rewrite of the online documentation along with a new reference presentation to prepare for the Nomadic Labs training session and hackathon. They also attended the WebAssembly summit and WebAssembly CG meeting. A useful takeaway: writing documentation can reveal missing features!

In addition to participation in these events, they

  • Simplified the Abstract Syntax of LIGO by removing redundant cases (this is required in order to develop new features in the compiler)

  • Did code cleanup & CI maintenance in preparation to auto-generate some LIGO boilerplate.

  • Worked on a switch allowing LIGO users to decide which version of the Tezos protocol to use

Michelson

No recent updates.

SCaml

The SCaml team is working on community planning. Tezos Japan and BlockChainJam are planning a hands-on using SCaml in Tokyo in March (https://www.tezos.or.jp/2020/01/30/smartcontract-for-begineer/). SCaml will provide technical advice for their tutorial materials.

The hands-on is targeted at Japanese engineers, many of who have difficulty with English documents. SCaml provides an open door to writing Tezos smart contracts, since it is just OCaml and there are already good OCaml books and tutorials in Japanese.

SmartPy

The SmartPy team worked on several points related to the SmartPy explorer (Michelson typing and pretty-printing, decompiler plumbing, faster UI, etc.) and is slowly approaching a new release. This will reach https://SmartPy.io/dev in the next few days or weeks.

Other elements that are currently tested:

  • private entry points that exist in tests but not on-chain yielding very nice testing and development idioms
  • a few improvements to the SmartPy type inference engine to improve overloading when necessary (e.g., euclidean division)

SmartPy also has a few secret projects that we’re especially excited about! We hope to be able to share these in the next few weeks.


Thanks for reading, and check back soon for our next update!

Eowyn on behalf of the LIGOlang team

1 Like

Thank you for following the latest in Tezos smart contract language development!

Let us know if you have:

  • feedback or suggestions
  • a language you would like to add

Recent development

Albert

No recent updates from the Albert team.

Archetype

version 0.1.13

The Archetype team just released version 0.1.13, which is the last alpha version before the 1.0 release. For more details please see: https://github.com/edukera/archetype-lang/blob/dev/CHANGES.md

Notable changes:

  • multi-criteria sort function for assets
    archetype multi_sort
    asset my_asset identified by id {
      id : string;
      v1 : int;
      v2 : int;
      v3 : int;
    } initialized by {
      {"id0"; 1; 2; 7};
      {"id1"; 1; 3; 9};
      {"id2"; 1; 3; 8};
      {"id3"; 1; 2; 6}
    }
    action exec () {
      effect {
        var res = my_asset.sort(v1, asc(v2), desc (v3))
        (* res = ["id0"; "id3", "id1", "id2"] *)
      }
    }
    
  • Transformations of intermediate representation
  • Bug fixes
  • Continuing to write language reference documentation https://docs.archetype-lang.org/archetype-language/archetype-reference

LIGO

The LIGO team continues working to improve the core of the language. Recent and upcoming developments include:

  • Added a tail recursive function to the language
  • Adding an AST pretty-printer to help debugging programs
  • Adding optimization passes

Beyond the work on LIGO, the team is also

  • Adding new features to Michelson for better interactions between smart-contracts
  • Adding new helpers to Michelson for integration with higher-level languages
  • Writing blog posts that detail how Tezos can be made simpler, and Michelson better

New website development includes

  • dark mode
  • a new logo
  • continued improvements to the documentation

Michelson

No recent updates from the Michelson team.

SCaml

version 1.1.0

The SCaml team released SCaml 1.1.0 “Salting” just after Tezos protocol upgrade 006 “Carthage”.

Since Carthage is a maintenance release of Tezos 005 “Babylon” there is no big change in Salting. It fixes some bugs and improves usability. Specifically:

  • SCaml is now installable via a simple shell script using Docker.
  • SCaml specific errors now have error codes.
  • Added more tests and examples.
  • SCaml record field and variant constructor names are now annotated to Michelson.
  • Added --scaml-convert and --scaml-revert for value conversion between SCaml and Michelson.
  • Michelson’s type “classes”, such as comparable, packable, parameterable types, etc. are now checked by the SCaml type checker.

Documented surprises

SCaml is a strict subset of OCaml. Ideally, within its limited language features, any valid OCaml program should be valid SCaml. Unfortunately there are some exceptions, therefore we have detailed surprises OCaml programmers may encounter in SCaml.

The most unintuitive SCaml surprise is the restriction of no unpackable free variable occurrence in function bodies. This comes from the same restriction in Michelson’s function closures, so the other functional language compilers to Michelson should have the same kind of restrictions. We have documented several ways to work around this restriction.

Social: the virus turned every meeting virtual

Japan and other Asian countries are experiencing 2019-nCoV situation few weeks prior to Western countries. All meetups are canceled around us to slow down the epidemic.

Our Tezos hands-on using SCaml planned on 2020-03-21 is not an exception, but we are planning to make it virtual. This is a challenge since hands-ons are more bidirectional than usual tech meetups, but it is an unstoppable change in tech communities this year.

SmartPy

No recent updates from the SmartPy team.


Thank you for reading, and check back soon for our next update!

Eowyn on behalf of the LIGOlang team

2 Likes

Thank you for following the latest in Tezos smart contract language development. The last few weeks have been challenging, but we’re happy to see people use their time stuck in quarantine to learn and develop skills in writing Tezos smart-contracts!

Let us know if you have:

  • feedback or suggestions
  • a language you would like to add

Recent development

Albert

No recent updates from the Albert team.

Archetype

The Archetype team added

  • Crypto functions: blake2b, sha256, sha512 and check_signature
  • Functions concat, slice and length for string/bytes types

Then also worked on

  • SmartPy output
  • Fixing bugs

LIGO

The LIGO team worked on

  • Refactoring the code base for better JSON outputs (error/values)
  • The boilerplate generator.
    In the past we factorized parts of the code that were similar, but those parts are somewhat arbitrary and make refactoring and changes more difficult (if you need to update a common part for just one of its use cases, it becomes a problem). It was useful to reduce the amount of code while there was little automation; now that we can generate some parts of the boilerplate we can start to bring back each AST in a single file without grouping the common parts of the AST in a separate file.
  • A pure OCaml substitute for cpp, which is now under unit testing before integration and release.
    Currently, the LIGO compiler relies on the C preprocessor (cpp) to textually combine several contracts into one by means of the #include directive, and perform the conditional compilation of contracts by means of the #if directive. The use of a preprocessor is meant as a temporary solution until a proper module system is designed which will enable the type-safe composition of contracts based on their abstract representations. In the meantime, cpp is an external dependency of the LIGO compiler, and a relatively large piece of software, so the substitute will make the LIGO distribution lighter.

SCaml

The SCaml team has nothing special to report for SCaml this time. They are busy with main core development.

SmartPy

No recent updates from the SmartPy team.


Thank you for reading, and check back soon for our next update!

Eowyn on behalf of the LIGOlang team