{"id":13468986,"url":"https://github.com/erg-lang/erg","last_synced_at":"2025-05-11T03:45:09.126Z","repository":{"id":56712012,"uuid":"523365444","full_name":"erg-lang/erg","owner":"erg-lang","description":"A statically typed language compatible with Python","archived":false,"fork":false,"pushed_at":"2025-04-07T03:02:05.000Z","size":19184,"stargazers_count":2783,"open_issues_count":74,"forks_count":57,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-11T03:44:57.311Z","etag":null,"topics":["compiler","erg","language","programming-language","python","rust","transpiler"],"latest_commit_sha":null,"homepage":"http://erg-lang.org","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erg-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":"FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"erg-lang","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-08-10T13:59:09.000Z","updated_at":"2025-05-08T21:36:42.000Z","dependencies_parsed_at":"2023-09-25T20:37:02.745Z","dependency_job_id":"81f977d3-029d-4d3e-8562-649b90d1b5d8","html_url":"https://github.com/erg-lang/erg","commit_stats":{"total_commits":2471,"total_committers":21,"mean_commits":"117.66666666666667","dds":"0.30594900849858353","last_synced_commit":"6cb4e75fea8c791bf15f5ecdbb4e0bca2d3bb4d8"},"previous_names":[],"tags_count":94,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erg-lang%2Ferg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erg-lang%2Ferg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erg-lang%2Ferg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erg-lang%2Ferg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erg-lang","download_url":"https://codeload.github.com/erg-lang/erg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514553,"owners_count":21920334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","erg","language","programming-language","python","rust","transpiler"],"created_at":"2024-07-31T15:01:23.581Z","updated_at":"2025-05-11T03:45:09.106Z","avatar_url":"https://github.com/erg-lang.png","language":"Rust","readme":"# The Erg Programming Language\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg width=\"500\" src=\"./assets/erg_logo_with_slogan.svg\"\u003e\n\u003c/div\u003e\n\n\u003cbr\u003eThis is the main source code repository for [Erg](https://erg-lang.org/). This contains the compiler and documentation.\n\n\u003cp align='center'\u003e\n    \u003ca href=\"https://github.com/erg-lang/erg/releases\"\u003e\u003cimg alt=\"Build status\" src=\"https://img.shields.io/github/v/release/erg-lang/erg.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/erg-lang/erg/actions/workflows/main.yml\"\u003e\u003cimg alt=\"Build status\" src=\"https://github.com/erg-lang/erg/actions/workflows/main.yml/badge.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://discord.gg/zfAAUbgGr4\" rel=\"nofollow\"\u003e\u003cimg alt=\"Discord\" src=\"https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord\u0026amp;logoColor=white\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003cbr\u003e\n    \u003ca href=\"https://erg-lang.org/web-ide/\" data-size=\"large\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?style=for-the-badge\u0026label=\u0026message=playground\u0026color=green\"\u003e\n    \u003c/a\u003e\n\u003cbr\u003e\n    \u003ca href='./README_JA.md'\u003e日本語\u003c/a\u003e | \u003ca href='./README_zh-CN.md'\u003e简体中文\u003c/a\u003e | \u003ca href='./README_zh-TW.md'\u003e繁體中文\u003c/a\u003e\n\u003c/p\u003e\n\n## Erg can be recommended to a person that\u0026colon;\n\n* wants Rust-like robustness and comfortable compiler support, and yet, doesn't need the verbose type specifications \u0026 memory management model like Rust.\n* frustrated with Python, but can't throw away Python code assets.\n* wants a simple and consistent language like ML.\n* wants a practical general-purpose language with dependent/refinement types.\n* wants a language like Scala that can be used both object-oriented and functional.\n\n## Features\n\n\u003e Some features are not yet implemented. Please see [TODO.md](./TODO.md) for implementation status.\n\n1. Robustness\n\n    Erg has a smart \u0026 powerful type system. For example, Erg can do null checking (Option type), division by zero, and out-of-range addresses in arrays at compile time.\n\n    ```python\n    rand = pyimport \"random\"\n\n    l = [1, 2, 3]\n    assert l in [Nat; 3] # type checking\n    assert l in [1..3; 3] # more detailed\n    l2 = l.push(rand.choice! 0..10)\n    assert l2 in [0..10; 4]\n    assert l2 + [3, 5, 7] in [0..10; 7]\n    # This causes an IndexError, Erg can detect it at compile time\n    l2[10] # IndexError: `l2` has 7 elements but was accessed the 11th element\n\n    2.times! do!:\n        print! \"hello, \", end := \"\"\n    # =\u003e hello, hello,\n    -2.times! do!:\n        print! \"hello, \", end := \"\"\n    # TypeError: `.times!` is a method of `Nat` (0 or more Int), not `Int`\n\n    {Meter; Sec; meter; kg; sec} = import \"unit\"\n\n    velocity x: Meter, t: Sec = x / t\n\n    v = velocity 3kg, 2sec # TypeError: the type of `x` was mismatched: expect `Meter`, found `Kg`\n    v = velocity 3meter, 2sec # v == 1.5 m/s\n    ```\n\n2. Simplicity\n\n    Erg consists of a very simple syntax, which can significantly reduce the amount of code compared to other languages. However, its functionality is not inferior to them.\n\n    Since the type inference system is powerful, you can code like a dynamically typed language.\n\n    ```python\n    fib 0 = 0\n    fib 1 = 1\n    fib n = fib(n - 1) + fib(n - 2)\n    assert fib(10) == 55\n    ```\n\n    Even for and while expressions are just one of the subroutines, so this is possible.\n\n    ```python\n    loop! block! = while! do! True, block!\n\n    # equals to `while! do(True), do! print! \"hello\"`\n    loop! do!:\n        print! \"hello\"\n    ```\n\n3. Functional \u0026 Object-oriented\n\n    Erg is a pure object-oriented language. Everything is an object; types, functions, and operators are all objects. On the other hand, Erg is also a functional language.\n    Erg requires some kinds of markers to be placed on code that causes side effects or changes internal state, which can localize the complexity of code. This will greatly improve the maintainability of your code.\n\n    ```python\n    # Functional style (immutable), same as `sorted(list)` in Python\n    immut_arr = [1, 3, 2]\n    assert immut_arr.sort() == [1, 2, 3]\n    # Object-oriented style (mutable)\n    mut_arr = ![1, 3, 2]\n    mut_arr.sort!()\n    assert mut_arr == [1, 2, 3]\n    i = !1\n    i.update! old -\u003e old + 1\n    assert i == 2\n\n    # Functions cannot cause side effects\n    inc i: Int! =\n        i.update! old -\u003e old + 1\n    # SyntaxError: cannot call a procedural method in a function\n    # hint: only methods of mutable types can change the state of objects\n\n    # Code that uses a lot of side effects is redundant, so you will naturally write pure code\n    Counter! = Inherit Int!\n    Counter!.\n        new i: Int = Counter! !i\n        inc! ref! self =\n            self.update! old -\u003e old + 1\n\n    c = Counter!.new 1\n    c.inc!()\n    assert c == 2\n    ```\n\n4. Interoperability\n\n    Erg is internally compatible with Python and can import the Python API at zero cost.\n\n    ```python\n    # using built-in Python modules\n    math, time = pyimport \"math\", \"time\"\n    {sin; pi} = math\n    # using an external Python module\n    tqdm = pyimport \"tqdm\"\n\n    print! sin pi # 1.2246467991473532e-16\n    for! tqdm.tqdm(0..99), i =\u003e\n        time.sleep! 0.01 * i\n    ```\n\n5. Readable Error Messages\n\n    Erg emphasizes the readability of error messages; Erg is a programmer-friendly language, ~~unlike C++.~~\n\n    ```python\n    proc! x =\n        l = [1, 2, 3]\n        l.push!(x)\n        l\n    ```\n\n    ```console\n    Error[#12]: File example.er, line 3, in \u003cmodule\u003e::proc!\n    2│     l = [1, 2, 3]\n    3│     l.push!(x)\n             ^^^^^\n    AttributeError: List object has no attribute `.push!`\n    hint: to update the internal state of an object, make it mutable by using `!` operator\n    hint: `List` has `push`, see https://erg-lang.github.io/docs/prelude/List/##push for more information\n    hint: `List!` has `push!`, see https://erg-lang.github.io/docs/prelude/List!/##push! for more information\n    ```\n\n## Requirements\n\nA [Python3 (3.7~3.11)](https://www.python.org/) interpreter is required. If it is already installed on your machine, no setup is required.\n\n## Installation\n\n### Installing by cargo (Rust package manager)\n\n```sh\ncargo install erg\n```\n\n### Building from source\n\nBuilding from source code requires the Rust toolchain.\n\n```sh\ngit clone https://github.com/erg-lang/erg.git\ncd erg\ncargo build --release\n```\n\n### Building by Nix\n\nIf you've been installed [Nix](https://nixos.org/), the following command will be generate binary into `result/bin/erg` under the project.\n\n```sh\ngit clone https://github.com/erg-lang/erg.git\ncd erg\nnix-build\n```\n\nIf you've been enabled [Nix Flakes](https://wiki.nixos.org/wiki/Flakes).\n\n```sh\ngit clone https://github.com/erg-lang/erg.git\ncd erg\nnix build\n```\n\n### Flags\n\nBy enabling the `--features` flag, you can customize the installation and build.\n\n* You can change the language of the error message by using  `--features {language}`\n\n```sh\n--features japanese\n--features simplified_chinese\n--features traditional_chinese\n```\n\nAnd more languages will be added (we are looking for translators. Please join the [Translation Project](./doc/EN/dev_guide/i18n_messages.md)).\n\nOther flags:\n\n* Install and build ELS (Erg Language Server)\n  * `--features els`\n* Debugging mode (for contributors)\n  * `--features debug`\n* Rich REPL experience (cursor movement, pasting, history, etc.)\n  * `--features full-repl`\n* Makes the display look better\n  * `--features unicode` and `--features pretty`\n* Enable all features (exclude features for developers)\n  * `--features full`\n* See [here](https://github.com/erg-lang/erg/blob/main/doc/EN/dev_guide/build_features.md) for more flags.\n\n## Contribution\n\nContributions are always welcome!\nTo get started with contributions, please look [CONTRIBUTING.md](https://github.com/erg-lang/erg/blob/main/CONTRIBUTING.md).\n\nIf you have any questions, please feel free to ask them on the [Discord channel](https://discord.gg/zfAAUbgGr4).\n\n## License\n\nAll files in the [assets](./assets) and [doc](./doc) folders are licensed with [CC-BY-4.0](./doc/LICENSE). The rest of the files in this repository are licensed with [Apache License 2.0](./LICENSE-APACHE) + [MIT License](./LICENSE-MIT).\n\nFor credits about third party crates, see [THIRD_PARTY_CREDITS.md](./THIRD_PARTY_CREDITS.md).\n","funding_links":["https://github.com/sponsors/erg-lang"],"categories":["Rust","Uncategorized","rust","Python Implemented in Other Languages"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferg-lang%2Ferg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferg-lang%2Ferg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferg-lang%2Ferg/lists"}