{"id":15042783,"url":"https://github.com/karsdev/clarity","last_synced_at":"2026-03-13T16:34:07.027Z","repository":{"id":255193715,"uuid":"843150715","full_name":"KarsDev/Clarity","owner":"KarsDev","description":"Coding language, ast-compiled, fast, easy","archived":false,"fork":false,"pushed_at":"2025-02-25T16:18:40.000Z","size":1015,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T02:21:41.774Z","etag":null,"topics":["abstract-syntax-tree","ast","clarity","clr","coding-language","custom-programming-language","interpreter","java","java-8","library","native","native-functions","parser","programming-language","tokenizer"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KarsDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-15T22:23:59.000Z","updated_at":"2025-02-25T16:18:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3e35167-7f5d-4cb5-8b9c-1846bf918732","html_url":"https://github.com/KarsDev/Clarity","commit_stats":null,"previous_names":["karsdev/clarity"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarsDev%2FClarity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarsDev%2FClarity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarsDev%2FClarity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarsDev%2FClarity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KarsDev","download_url":"https://codeload.github.com/KarsDev/Clarity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137831,"owners_count":21053770,"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":["abstract-syntax-tree","ast","clarity","clr","coding-language","custom-programming-language","interpreter","java","java-8","library","native","native-functions","parser","programming-language","tokenizer"],"created_at":"2024-09-24T20:47:58.497Z","updated_at":"2026-03-13T16:34:06.979Z","avatar_url":"https://github.com/KarsDev.png","language":"Java","readme":"# Clarity Programming Language\n\n## Overview\n\nClarity is a high-level, object-oriented programming language designed to prioritize simplicity and clarity. It features a concise syntax and supports dynamic typing, making it easy to read and write. Clarity is suitable for both beginners and experienced developers who want to create clean, maintainable code.\n\n## Table of Contents\n1. [Installation](#installation)\n2. [Features](#features)\n3. [Basic Syntax](#basic-syntax)\n   - [Variables](#variables)\n   - [Functions](#functions)\n   - [Classes](#classes)\n   - [Control Structures](#control-structures)\n4. [Native Libraries](#native-libraries)\n5. [Examples](#examples)\n   - [Simple Program](#simple-program)\n   - [Using a Class](#using-a-class)\n   - [Looping Over a List](#looping-over-a-list)\n   - [Static Properties and Methods](#static-properties-and-methods)\n\n## Installation\n\nTo install Clarity, follow these steps based on your operating system:\n\n##### download Required Files:\n\nWindows: Download install_windows.bat\nMac: Download install_mac.sh\nLinux: Download install_linux.sh\n\nAlso, download clarity.jar\n\n##### Prepare for Installation:\nEnsure that `install_windows.bat`, `install_mac.sh`, or `install_linux.sh`, along with `clarity.jar`, are located in the same directory.\n\n##### Run the Installer:\nWindows: Double-click `install_windows.bat` to run the installer.\nMac: Open a terminal, navigate to the directory containing `install_mac.sh` and clarity.jar, then run the bash file.\nLinux: Open a terminal, navigate to the directory containing `install_linux.sh` and clarity.jar, then the bash file.\n\n##### Complete Installation:\nThe installer will place Clarity on your system `%userpath%/Clarity` and then remove the installer files. You can safely delete clarity.jar and the installer script if they are not automatically removed.\n(Java will automatically installed if version 8 or higher is not found)\n\n## Features\n\n- **Object-Oriented:** Support for classes, methods, and properties.\n- **Concise Syntax:** Minimalist syntax that enhances readability.\n- **Dynamic Typing:** Variables do not require explicit type declarations.\n- **Native Libraries:** Provides a standard library with essential functions for I/O operations, mathematical calculations, and error handling.\n- **Flexible Main Entry Point:** The program does not require a specific main function to run, similar to Python.\n\n## Basic Syntax\n\n### Variables\n\nVariables are declared using the `var` keyword. They can be initialized at the time of declaration or assigned values later.\n\n```clarity\nvar x\nx = 5\n\nvar y = 10\n```\n## Functions\n\nFunctions are defined using the fn keyword. A function can return a value or nothing (void).\n\n```clarity\n\nfn add(a, b) {\n    return a + b\n}\n\nfn displayMessage() {\n    native.println(\"Hello from Clarity!\")\n}\n```\n## Classes\n\nClasses in Clarity are defined using the class keyword and can have properties, a constructor, and methods.\n\n```clarity\n\nclass Person {\n    var name\n    var age\n\n    constructor(name, age) {\n        local.name = name\n        local.age = age\n    }\n\n    fn greet() {\n        native.println(\"My name is \" + local.getName() + \" and I'm \" + local.getAge() + \" years old\")\n    }\n\n    fn getName() {\n        return name\n    }\n\n    fn getAge() {\n        return age\n    }\n}\n```\n## Control Structures\n\nClarity supports common control structures like loops and conditionals.\n\nFor Loop:\n\n```clarity\n// foreach\nfor i : [1, 2, 3] {\n    native.println(i)\n}\n\n// for\nfor var i = 1, i \u003c= 100, i = i + 1 {\n    native.print(\"Iteration: \" + i + \"\\n\")\n}\n```\n\nWhile Loop:\n\n```clarity\nvar i = 0\nvar finished = false\nwhile !finished {\n    native.println(\"Not finished\")\n    i = i + 1\n    finished = i \u003e 100\n}\n```\n\nSelect Statement:\n\n```clarity\nvar i = int(native.input(\"Write a number from 1 to 3: \"))\nselect i {\n    when 1 {\n        native.println(\"You wrote 1\")\n        break\n    }\n    when 2 {\n        native.println(\"You wrote 2\")\n        break\n    }\n    when 3 {\n        native.println(\"You wrote 3\")\n        break\n    }\n    default {\n        native.println(i + \" is not a number between 1 and 3\")\n    }\n}\n```\n\nIf Statement:\n\n```clarity\nvar x = int(native.input(\"Write a number: \")) // asking for a number and converting it to integer\nif x \u003e 0 {\n    native.println(\"Your number is greater than 0\")\n} else if x \u003c 0 {\n    native.println(\"Your number is less than 0\")\n} else {\n    native.println(\"Your number is equal to 0\")\n}\n```\n\nAssert Statement:\n\n```clarity\nvar x = int(native.input(\"Write a number from 1 to 3: \"))\nassert x \u003e= 1 \u0026\u0026 x \u003c= 3 else \"The number \" + x + \" is not between i and 3!\"\n```\n\nIs Check:\n\n```clarity\nclass Inherited {\n}\n\nclass Inheritor inherits Inherited {\n}\n\nvar inheritor = new Inheritor()\n\nassert inheritor is Inherited // does not give any exception since inheritor is indirectly Inherited\n\n```\n\n## Native Libraries\n\nClarity includes a set of built-in libraries that provide essential functions for various operations. You can include these libraries using the include keyword.\n\nFor example:\n\n```clarity\n\ninclude native system\ninclude native math\n```\nCommon Native Functions\n```clarity\n    native.println(message): Prints a message with a newline.\n    native.print(message): Prints a message without adding a newline.\n    native.error.except(): Handles errors or exceptions.\n```\n## Examples\n## Simple Program\n\nA Clarity program does not require a specific main function to run. Here's a basic example:\n\n```clarity\n\nnative.println(\"Hello, World!\")\n```\n## Using a Class\n\n```clarity\nvar john = new Person(\"John\", 16)\njohn.greet()\n```\n## Looping Over a List\n```clarity\n\nfor i : [1, 2, 3] {\n    native.println(i)\n}\n```\n## Static Properties and Methods\n\n```clarity\n\nclass Test {\n    static const var name = \"Clarity\"\n\n    static fn getName() {\n        return Test.name\n    }\n}\n\nfor var i = 1, i \u003c= 100, i = i++ {\n    native.print(Test.getName() + \" loves you \" + i + \" times\\n\")\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarsdev%2Fclarity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarsdev%2Fclarity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarsdev%2Fclarity/lists"}