{"id":3191,"url":"https://github.com/Zolang/Zolang","last_synced_at":"2025-07-31T13:30:26.881Z","repository":{"id":215156441,"uuid":"150035879","full_name":"Zolang/Zolang","owner":"Zolang","description":"A programming language for generating code for multiple platforms","archived":false,"fork":false,"pushed_at":"2022-06-01T23:09:05.000Z","size":2465,"stargazers_count":145,"open_issues_count":8,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-15T00:20:03.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zolang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-09-23T23:58:14.000Z","updated_at":"2024-05-31T20:39:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d6e6998-5076-429e-bc9a-83ded5963a49","html_url":"https://github.com/Zolang/Zolang","commit_stats":null,"previous_names":["zolang/zolang"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zolang%2FZolang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zolang%2FZolang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zolang%2FZolang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zolang%2FZolang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zolang","download_url":"https://codeload.github.com/Zolang/Zolang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228248488,"owners_count":17891447,"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":[],"created_at":"2024-01-05T20:16:34.027Z","updated_at":"2024-12-05T06:31:29.754Z","avatar_url":"https://github.com/Zolang.png","language":"Swift","funding_links":[],"categories":["Tools","Converters","Converters [🔝](#readme)"],"sub_categories":["Web View","Vim"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cb\u003e Zolang \u003c/b\u003e \u0026bull;\n  \u003ca href=\"https://github.com/Zolang/ZolangTemplates\"\u003eZolangTemplates\u003c/a\u003e \u0026bull;\n    \u003ca href=\"https://github.com/Zolang/ZolangIDE\"\u003eZolang IDE\u003c/a\u003e\n\u003c/p\u003e\n\n![Zolang Logo](https://github.com/Zolang/Zolang/blob/master/Images/zolang-banner.png \"Zolang logo\")\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat\" style=\"max-height: 300px;\" alt=\"Swift\"/\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/badge/platforms-Linux%20%7C%20MacOS-green.svg\" alt=\"Platforms\"/\u003e\n\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\" alt=\"MIT\"/\u003e\n\u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\" /\u003e\n\u003c/p\u003e\n\n\u003cb\u003eTable of Contents\u003c/b\u003e\n\n[What is it?](#What)\n\n- [What Zolang is Not](#IsNot)\n\n[Documentation](#Docs)\n\n- [Installation](#Install)\n- [Getting Started](#GetStarted)\n- [Example](#Example)\n- [Language Overview](#Overview)\n  - [Types](#Types)\n  - [Operators](#Operators)\n  - [Comments](#Comments)\n  - [Models](#Models)\n  - [Functions](#Functions)\n  - [Arithmetic](#Arithmetic)\n  - [Loops](#Loops)\n  - [Metaprogramming](#Metaprogramming)\n\n[Roadmap](#Roadmap)\n\n[Why Zolang?](#Why)\n\n[Name](#Name)\n\n[License](#License)\n\n# Zolang\n\u003e A lightweight frontend for virtually any general purpose programming language.\n\n\u003ca name=\"What\"\u003e\u003c/a\u003e\n## What is it?\n\nZolang is a programming language with capabilities that make it transpilable to virtually any other programming language.\n\nZolang does this by offloading code generation to its users through [Stencil (template language)](https://stencil.fuller.li/en/latest/) specification files.\n\nTheoretically though, these (`.stencil`) specification files could make Zolang output any kind of text. Making the language a very useful code generation tool and a decent lightweight alternative to many cross-platform frameworks. \n\n\u003ca name=\"IsNot\"\u003e\u003c/a\u003e\n### What Zolang is Not\nZolang is not a general purpose programming language and probably won't have support for standard library functionalities in the forseeable future. This is because Zolang uses a templating language for compilation, which is not the expected usage of such a language, and becomes slow quite quickly, limiting the amount of code feasable for Zolang development.\n\n\u003ca name=\"Docs\"\u003e\u003c/a\u003e\n## Documentation\n\n\u003ca name=\"Install\"\u003e\u003c/a\u003e\n### Installation\n\n#### MacOS\n\n```\ncurl -LO https://github.com/Zolang/Zolang/releases/download/0.1.19/zolang\nmv zolang /usr/local/bin/\nchmod +x /usr/local/bin/zolang\n```\n\n#### Linux \u0026 Mac (Build From Source)\n\nAt the time of writing there is a bug in Swift on Linux that prevents me from providing working build for Linux so if you're running on Linux you will (for now) have to have Swift installed ([Download Swift](https://swift.org/download/#releases)) and simply build from source.\n\n```\ngit clone https://github.com/Zolang/Zolang\ncd Zolang\nswift build -c release\ncd .build/release\ncp -f Zolang /usr/local/bin/zolang\n```\n\n#### Verify installation\n\n```\nzolang\n```\n\n\u003ca name=\"GetStarted\"\u003e\u003c/a\u003e\n### Getting Started\n\n#### Setting up development environment\n\nZolang is best with Visual Studio Code using the [zolang-ide](https://marketplace.visualstudio.com/items?itemName=valdirunars.zolang-ide) extension\n\n#### Initializing Project\n\nIf you don't have an existing project start by creating a project folder and navigate to it\n\n```\nmkdir  MyZolangProject\ncd MyZolangProject\n```\n\nThen initialize the project\n\n```\nzolang init\n```\n\nThis will create a zolang.json file that will be used to specify build settings for your Zolang and setup the project's file structure.\n\n\u003ca name=\"Example\"\u003e\u003c/a\u003e\n### Example\n\n#### The Config File\n\nA typical ```zolang.json``` project file compiling to Swift, Kotlin and Python would look something like this:\n\n```JSON\n{\n  \"buildSettings\": [\n    {\n      \"sourcePath\": \"./.zolang/src\",\n      \"stencilPath\": \"./.zolang/templates/swift\",\n      \"buildPath\": \"./.zolang/build/swift\",\n      \"fileExtension\": \"swift\",\n      \"separators\": {\n        \"CodeBlock\": \"\\n\"\n      },\n      \"flags\": [\n        \"swift\"\n      ] \n    },\n    {\n      \"sourcePath\": \"./.zolang/src\",\n      \"stencilPath\": \"./.zolang/templates/kotlin\",\n      \"buildPath\": \"./.zolang/build/kotlin\",\n      \"fileExtension\": \"kt\",\n      \"separators\": {\n        \"CodeBlock\": \"\\n\"\n      },\n      \"flags\": [\n        \"kotlin\"\n      ]\n    },\n    {\n      \"sourcePath\": \"./.zolang/src/\",\n      \"stencilPath\": \"./.zolang/templates/python2.7\",\n      \"buildPath\": \"./.zolang/build/python2.7\",\n      \"fileExtension\": \"py\",\n      \"separators\": {\n        \"CodeBlock\": \"\\n\"\n      },\n      \"flags\": [\n        \"python2.7\"\n      ]\n    }\n  ]\n}\n```\n\nNotice the `./.zolang/templates/{LANGUAGE}` This is the location of the `.stencil` files that customize the actual code generation process. The Zolang organization has [a repo of supported languages](https://github.com/Zolang/ZolangTemplates). But `zolang init` only fetches the three (Swift, Kotlin and Python).\n\n`./zolang/src` is where all the Zolang code is stored.\n\n`flags` are compile time constants that can be used in ```only``` statements see [docs](#Docs)\n\n\u003e 😇 P.S. It only took around an hour to add the templates needed to be able to compile Zolang to both Kotlin and Swift! So you shouldn't restrain yourself from using Zolang if your favorite language is not yet supported. Just add it and continue hacking.\n\n#### Your First Model Description\n\nWe could create a file `./zolang/src/Person.zolang`\n\n```zolang\ndescribe Company {\n  name as text\n  revenue as number\n\n  employeeNames as list of text default []\n}\n```\n\n#### Building\n\nJust ...\n\n```\nzolang build\n```\n\n... and enjoy checking out the readable code generated to `./zolang/build/swift/Person.swift` and `./zolang/build/kotlin/Person.kt`\n\n#### Hot Reloading\n\nZolang supports hot reloading or live compilation through the `watch` action\n\n```\nzolang watch\n```\n\nThis action will observe changes to Zolang source files with paths specified in `zolang.json` and rebuild.\n\n![Zolang hot-reloading](https://github.com/Zolang/Zolang/blob/master/Images/hot-reload-demo.gif \"Zolang live compilation demo\")\n\n\u003ca name=\"Overview\"\u003e\u003c/a\u003e\n### Language Overview\n\n\u003ca name=\"Types\"\u003e\u003c/a\u003e\n#### Types\n\nZolang has five primitive types\n\n- boolean\n- text\n- number\n- list\n- dictionary\n\n##### boolean\n\nValues are either ```true``` or ```false```\n\nSee section below on operators for further information\n\n##### text\n\nDefined within double quotes\n\n```\n\"a piece of text\"\n```\n\nYou can format a piece of text using ```${...}```\n\n```\n\"this is a string with an embedded variable: ${someVar}\"\n```\n\nThe limitation when it comes to ```text``` in Zolang is that the language doesn't care for characters that need to be escaped.\n\nThe text: ```\"this is a text \\n\"``` would remain unchanged when compiling to other languages which might become a problem if `\\n` is handled differently in the other languages the Zolang code is being compiled to. Thankfully languages seem to handle character escaping in a somewhat similar fassion so most of the time this does not make a difference.\n\n##### number\n\nZolang currently only has one type to represent numbers.\n\nNumbers work just as you would expect:\n\n```zolang\nlet num1 as number be 0.12345\n\nlet num2 as number be 5\n```\n\n##### list\n\nThe same goes for lists. They represent ... you guessed it, lists of data; and are declared by using the ```list``` keyword followed by a ```of``` keyword and finally the type of the element you want to represent.\n\nList literals are defined with a comma separated sequence of expressions wrapped inside enclosing brackets ```[...]``` \n\n```zolang\nlet myList as list of text be [ \"1\", \"2\", \"3\" ]\n```\n\n##### dictionary\n\nDictionaries might be a bit different to the key-value types you're used but fear not they're just as easy to understand.\n\nIn Zolang dictionaries only have one available Key type, `text`, so their usage becomes similar to lists:\n\n```zolang\nlet myDict as dictionary of number be { \"num1\": 5, \"num2\": 7.5 }\n```\n\nThis is to make sure all pure Zolang models are easily serializable to JSON so that later on templates in [ZolangTemplates](https://github.com/Zolang/ZolangTemplates) will be able to autogenerate serialization methods for all models.\n\n\u003ca name=\"Operators\"\u003e\u003c/a\u003e\n#### Operators\n\n##### Prefix Operators\n\nThere is only one supported prefix operator in Zolang\n\n```not``` and ```!``` both meaning the same thing and are meant to be used as negation for boolean types\n\n##### Infix Operators\n\nInfix operators in Zolang:\n\n- ```or```, ```||```: boolean or\n- ```and```, ```\u0026\u0026```: boolean and\n- ```\u003c```: less-than\n- ```\u003e```: greater-than\n- ```\u003c=```: lesser-than-or-equal\n- ```\u003e=```: greater-than-or-equal\n- ```equals```, ```==```: equality\n- ```plus```, ```+```: addition\n- ```minus```, ```-```: subtraction\n- ```multiplied by```, ```times```, ```*```: multiplication\n- ```divided by```, ```over```, ```/```: division\n- ```modulus```, ```%```: modulus\n\n\u003e NOTE! Watch out for precedence. Zolang offloads precedence handling to the languages being compiled to. With types that are of number type this is seldom an issue but as Zolang doesn't currently support type checking, any operator can be used on any type, so beware.\n\n\u003ca name=\"Comments\"\u003e\u003c/a\u003e\n#### Comments\n\nZolang currently only supports single line comments prefixed by `#`. Currently, comments are ignored in the build phase and can only be used to document Zolang code.\n\n```zolang\n# This is a comment\n```\n\n\u003ca name=\"Models\"\u003e\u003c/a\u003e\n#### Describing a Model\n\n```zolang\ndescribe Person {\n  name as text \n  street as text\n  number as number\n  friendNames as list of text\n}\n```\n\nNow like you can create a `Person` by calling:\n\n```zolang\nlet john as Person be Person(\"John\", \"Wall Street\", 15, [ \"Alice\", \"Bob\" ])\n```\n\n##### Access Control\n\nIt can be handy to be able to specify some ground rules as to what code can access what properties.\n\nIf we look at `Person` example from above we might want to limit access to his address to be only accessable from within the `Person`'s description.\n\nThis can be done by using the `private` access limitation specifier\n\nCurrently supported access limitation specifiers are\n- `private`\n\nIf nothing is specified the property/function will be declared public\n\n```zolang\nprivate street as text\nprivate number as number\n```\n\n##### Default Values\n\nProperties can also have default values\n\n```zolang\nprivate street as text default \"John\"\n```\n\n##### Static\n\nZolang allows static declaration of properties/functions:\n\n```zolang\nstatic species as text default \"Homo Sapiens\"\n```\n\nThis can then be accessed by calling:\n\n```zolang\nPerson.species\n```\n\n\u003ca name=\"VariableDeclaration\"\u003e\u003c/a\u003e\n#### Variable Declaration\n\n```zolang\nlet person as Person be Person(\"John Doe\", \"John's Street\", 8, [ \"Todd\" ])\n```\n\n\u003ca name=\"Mutation\"\u003e\u003c/a\u003e\n#### Mutation\n\n```zolang\nmake person.name be \"Jane Doe\"\n```\n\n\u003ca name=\"Functions\"\u003e\u003c/a\u003e\n#### Functions\n\nFunctions in Zolang can be declared in a model description, in `Person`, the model we described above we could define a function address which would combine street and number as so:\n\n```zolang\ndescribe Person {\n  name as text \n  street as text\n  number as number\n  friendNames as list of text\n  \n  address return text from () {\n    return \"${street} ${number}\"\n  }\n}\n```\n\n##### Invoking Functions\n\n```zolang\nperson.speak(\"My address is ${person.address()}\")\n```\n\n\u003ca name=\"Arithmetic\"\u003e\u003c/a\u003e\n#### Arithmetic\n\nLets say we wanted to calculate something like `1 + 2 + (3 * 4) / 5`\n\nIn Zolang this would be written in various ways:\n\n```zolang\n1 + 2 (3 * 4) / 5\n```\n\n```zolang\n1 plus 2 plus (3 times 4) over 5\n```\n\n```\n1 plus 2 plus (3 times 4) divided by 5\n```\n\n\u003ca name=\"Loops\"\u003e\u003c/a\u003e\n#### Looping through Lists\n\n```zolang\nlet i as number be 1\n\nwhile (i \u003c person.friendNames.count) {\n  make i be i plus 1\n}\n```\n\n\u003ca name=\"Metaprogramming\"\u003e\u003c/a\u003e\n#### Metaprogramming\n\nIn Zolang there are two features designed for metaprogramming purposes, ```raw``` and ```only```\n\n##### raw\n\n```zolang\nraw {'Any text here'}\n```\n\nThis will tell the compiler to skip the code generation process for \"Any text here\" and forward it as is to the compiler's output\n\n##### only\n```only \"\u003cflag1\u003e\", \"\u003cflag2\u003e\",... { \u003ccode\u003e }```\n\nUsing `only` we can tell the compiler to ignore code for buildSettings not included in a comma separated list of flags (flags are specified in `./zolang.json` under `\"flags\"` in each buildSetting)\n\n```zolang\nonly \"python2.7\", \"swift\" {\n  print(\"text\")\n}\n```\n\n##### Putting it all Together\n\nUsing these two features (`raw` \u0026 `only`) we could create a facade for logging to the console:\n\n```zolang\ndescribe Sys {\n  static log return from (txt as text) {\n    only \"python2.7\", \"swift\" {\n      raw {'print(txt)'}\n    }\n    only \"kotlin\" {\n      raw {'println(txt)'}\n    }\n  }\n}\n\nSys.log(\"Hello World!\")\n```\n\n\u003ca name=\"Roadmap\"\u003e\u003c/a\u003e\n## Roadmap / Upcoming Features\n\n- Faster compilation\n- Fetch [ZolangTemplates](https://github.com/Zolang/ZolangTemplates) from the Zolang CLI\n- Update Zolang from the Zolang CLI\n- Type checking\n- For loop\n- Function mutation\n\n\u003ca name=\"Why\"\u003e\u003c/a\u003e\n## Why Zolang?\n\nZolang doesn't try to be a general purpose programming language, it is limited in features and is yet to have a standard library, so why use Zolang instead of other programming languages?\n\n... well, it's transpilable to multiple languages including Kotlin, Swift and Python and there are few limits to how many languages can be supported, to give you the idea of how soon your favorite language will be supported (if not already) adding support for all the three aforementioned languages took about an hour.\n\nThis means that Zolang is very good for implementing basic logic in your app with a single source of truth, generating code needed for virtually all platforms your app is running on.\n\n### A User Story: The Story Behind Zolang\n\nThe idea for Zolang came from within a fast moving startup. It was moving fast in the sense that the tech stack was rapidly changing every now and then, the product had projects in 4 languages, Swift, TypeScript, JavaScript and Ruby. All of which had duplications in definitions of models.\n\nSo every time the tech stack changed drastically, changes had to be made in many of the (if not all four) implementations. So we wanted a language where we could write the model layer of our application with a single source of truth, generating code for all of our programming languages.\n\n\u003ca name=\"Name\"\u003e\u003c/a\u003e\n## Name\n\nI'm a Star Wars fan and in the Star Wars world Zolan is the home planet of a species called clawdites, who are known for their ability to transform their appearance to look like virtually any other creature.\n\nAs the language aims to be transpilable to virtually any other programming language the clawdites came quickly to mind. Sadly the species doesn't have a catchy name, so I found myself falling back to their planet Zolan. And since this is a language and lang is often used as an abbreviation for language the \"g\" was soon to follow.\n\nRemember this guy from \"Attack of the Clones\":\n\n![Clawdite](https://github.com/Zolang/Zolang/blob/master/Images/clawdite.gif \"The clawdite from Attack of the Clones\")\n\nThat is a clawdite, my inspiration for the name and logo.\n\n\u003ca name=\"License\"\u003e\u003c/a\u003e\n## License\n\nMIT License\n\nCopyright (c) 2018 Thorvaldur Runarsson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZolang%2FZolang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZolang%2FZolang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZolang%2FZolang/lists"}