Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Cairo out into separate Cairo and Cairo Zero languages #6917

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

mkaput
Copy link

@mkaput mkaput commented Jun 28, 2024

This PR is updating the situation around the Cairo language to match the current state of things.

Disclaimer: I am involved in the development of the Cairo compiler and its dev tooling.

Description

Historical context

Cairo is a programming language that allows writing zero-knowledge-provable programs. Cairo is also the smart-contract language of Starknet.

In Jan 2023, Cairo 1.0 was released (blog post). Cairo 1.0 (and all versions upwards) is a completely new language built from scratch.

A couple of weeks later, we have decided a new naming strategy has been established:

  • Cairo 1.0 and upwards is now called Cairo proper.
  • The old Cairo is now called Cairo Zero.
  • A tiny, strict subset of Cairo Zero, the assembly language of the Cairo virtual machine became CASM - Cairo Assembly.

These naming changes got community approval, but everything happened on an invite-only Telegram group, so I am unable to provide a link.

Cairo is not backwards-compatible with Cairo Zero. Cairo Zero development is frozen and the language will not receive any new features or updates.

As a side note: Cairo also brings another language - Sierra, which is an IR between Cairo and CASM. This PR is not concerning about Sierra at all.

What this PR changes

  1. Renamed existing Cairo language to Cairo Zero.
  2. Added a new language Cairo that represents the new Cairo.
  3. Updated grammar sources to the new location that provides grammars for both languages: https://github.com/software-mansion-labs/cairo-tm-grammar
    • I am maintaining this repository. It is just a repackaging of grammars that this repo pulls from upstream repositories. I made sure to have everything documented and properly attributed there.
    • The grammar for Cairo is new, and I made it for the official Visual Studio Code extension for Cairo.
    • The grammar for Cairo Zero is different from the one that was used here before.
      • The new grammar comes from the old, official Visual Studio Code extension for Cairo Zero.
      • The old grammar was written by @0xChqrles. It has bugs that make it stop highlighting on some files (example). The new grammar does not exhibit this problem. I have talked with @0xChqrles about this, and he approves stopping using his grammar.
  4. I have added heuristics for Cairo Zero that help disambiguate it from Cairo (as both languages use the same extension). With these heuristics and newly added samples, the classifier seems to identify the correct languages well, according to my testing.
  5. Some samples of CASM language can appear on GitHub as *.casm. I have added two as *.cairo to help the classifier, but this PR is not doing anything more, as CASM is not significant enough.

Checklist:

Signed-off-by: Marek Kaput <marek.kaput@swmansion.com>
Signed-off-by: Marek Kaput <marek.kaput@swmansion.com>
Signed-off-by: Marek Kaput <marek.kaput@swmansion.com>
Signed-off-by: Marek Kaput <marek.kaput@swmansion.com>
@mkaput mkaput requested a review from a team as a code owner June 28, 2024 15:18
lib/linguist/languages.yml Outdated Show resolved Hide resolved
@mkaput mkaput changed the title Cairo Update Cairo language Jun 28, 2024
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline.

Please can you replace your new samples which are not real-world files with real-world examples.

lib/linguist/languages.yml Outdated Show resolved Hide resolved
lib/linguist/heuristics.yml Outdated Show resolved Hide resolved
@mkaput
Copy link
Author

mkaput commented Jul 9, 2024

Please can you replace your new samples which are not real-world files with real-world examples.

Do you mean the CASM ones (1, 2)? Yes, they are auto-generated, but I used them because:

  1. they do appear on GitHub already, and
  2. they help the classifier distinguish Cairo 0 from Cairo, as they are full of Cairo 0-specific syntax; without these, the classifier fails to differentiate remaining samples

wdyt given this context?

@lildude
Copy link
Member

lildude commented Jul 9, 2024

Please can you replace your new samples which are not real-world files with real-world examples.

Do you mean the CASM ones (1, 2)? Yes, they are auto-generated, but I used them because:

  1. they do appear on GitHub already, and
  2. they help the classifier distinguish Cairo 0 from Cairo, as they are full of Cairo 0-specific syntax; without these, the classifier fails to differentiate remaining samples

wdyt given this context?

Yes, those files. The fact you can only get the classifier to match our current samples by fudging things kinda speaks for itself… either the current samples aren't good illustrations of the language or the new ones aren't. Or you're trying to match things which look completely different which normally indicates a whole different syntax and thus commonly a whole different language.

@mkaput
Copy link
Author

mkaput commented Jul 11, 2024

Yes, those files. The fact you can only get the classifier to match our current samples by fudging things kinda speaks for itself… either the current samples aren't good illustrations of the language or the new ones aren't. Or you're trying to match things which look completely different which normally indicates a whole different syntax and thus commonly a whole different language.

I removed the bigger file, but left the smaller one as it's a good representation and actually hand-writable for some example purposes. I added more real-world Cairo and Cairo 0 samples to provide more data for the classifier. PR description is updated with source links.

@mkaput mkaput requested a review from lildude July 11, 2024 15:07
@lildude lildude changed the title Update Cairo language Split Cairo out into separate Cairo and Cairo 0 languages Jul 12, 2024
@mkaput
Copy link
Author

mkaput commented Jul 22, 2024

@lildude is there anything I have to add here? :)

lildude
lildude previously approved these changes Jul 22, 2024
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Note: this PR will not be merged until close to when the next release is made. See here for more details.

@mkaput
Copy link
Author

mkaput commented Jul 22, 2024

Awesome! 😍 Thank you for review!

I saw this section in docs; thought you'd merge this now and will wait, just releasing from main. But it's fine whatever you do.

Are you able to give an order of magnitude, when do you plan to do a next release? I bet my community will love to hear about it, but it's also fine if you can't tell it here.

@lildude
Copy link
Member

lildude commented Jul 22, 2024

I make a release approx every 3-4 months. The last one was on 7 Jun so it won't be for a few months... probably late August.

This change has been suggested by the StarkWare Product Team,
so here it is.
@mkaput mkaput changed the title Split Cairo out into separate Cairo and Cairo 0 languages Split Cairo out into separate Cairo and Cairo Zero languages Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants