{"id":25566141,"url":"https://github.com/bndrmrtn/zxl","last_synced_at":"2025-04-12T10:42:11.058Z","repository":{"id":274861344,"uuid":"923187299","full_name":"bndrmrtn/zxl","owner":"bndrmrtn","description":"Zx Language – Interpreted scripting language for web development. Features built-in HTTP server and HTML template literals. 🚀","archived":false,"fork":false,"pushed_at":"2025-04-09T14:59:36.000Z","size":370,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T15:49:54.281Z","etag":null,"topics":["interpreter","language","scripting","simplicity","web"],"latest_commit_sha":null,"homepage":"https://zxl.mrtn.vip","language":"Go","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/bndrmrtn.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":"2025-01-27T19:35:17.000Z","updated_at":"2025-04-09T14:59:39.000Z","dependencies_parsed_at":"2025-01-29T20:26:59.967Z","dependency_job_id":"2e884bde-d43e-4ee8-b2cf-ca6daeb0d721","html_url":"https://github.com/bndrmrtn/zxl","commit_stats":null,"previous_names":["bndrmrtn/zexlang","bndrmrtn/zxl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndrmrtn%2Fzxl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndrmrtn%2Fzxl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndrmrtn%2Fzxl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bndrmrtn%2Fzxl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bndrmrtn","download_url":"https://codeload.github.com/bndrmrtn/zxl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248557105,"owners_count":21124156,"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":["interpreter","language","scripting","simplicity","web"],"created_at":"2025-02-20T22:28:09.130Z","updated_at":"2025-04-12T10:42:11.047Z","avatar_url":"https://github.com/bndrmrtn.png","language":"Go","funding_links":["https://www.paypal.me/instasiteshu","https://ko-fi.com/bndrmrtn"],"categories":[],"sub_categories":[],"readme":"# Zx (/ziː.ɛks/) Language\n\nZx is a simple programming language\nthat is designed to be easy to use and understand.\n\n[Examples](https://github.com/orgs/zxlgo/repositories)\n\n## About\n\nZx is a weakly-typed, interpreted language that is designed to be easy to use and understand.\nZx is built in Go as a learning project and is not intended to be used in production.\n\n## Features\n\n- Weakly-typed\n- Interpreted\n- Zx Blocks\n- Threads and Concurrency\n\n# Syntax Highlihting\n\nZx now has a `VSCode` plugin for highlighting code (no LSP currently). [Download now](https://marketplace.visualstudio.com/items/?itemName=zxl.zx)\n\n## Installation\n\nTo install Zx, you need to have Go installed on your system.\n\n```bash\ngo install github.com/bndrmrtn/zxl@latest\n```\n\n## Usage\n\nTo run a Zx program, you can use the `zxl` command.\n\n```bash\nzxl run \u003cfile\u003e\n```\n\nFlags can be used to cache or debug the program.\n\n```bash\nzxl run \u003cfile\u003e --cache --debug\n```\n\n## Examples\n\n#### Basic Hello World program:\n\n```zxl\nprintln(\"Hello, World!\");\n```\n\n#### Define a variable and print it:\n\n```zxl\nlet x = 10;\nprintln(x);\n```\n\n#### Define a function and call it:\n\n```zxl\nfn add(a, b) {\n  return a + b;\n}\n\nlet result = add(10, 20);\nprintln(result);\n```\n\n### Error handling:\n\n```zxl\nerror err: fail(\"This is a helper to throw an error\");\nif err != nil {\n  println(\"error occurred:\", err);\n}\n```\n\n```zxl\nerror otherErr {\n  const x = 5;\n  x = 6; // an error will happen\n}\n\nif otherErr != nil {\n  println(\"error occurred:\", otherErr);\n}\n\nprintln(x); // x is in the same scope as global so it will print 5, because\n            // thats the value of x before the error occurred\n```\n\n#### Define a block and use it:\n\n```zxl\ndefine MyBlock {\n  let x = 10;\n\n  fn construct(value) {\n    this.x = value;\n  }\n}\n\nlet block = MyBlock(20);\nprintln(block.x);\n```\n\n### Using namespaces:\n\nFile `main.zx`:\n```zxl\nnamespace main;\n\nimport(\"other.zx\");\nother.printHello();\n```\n\nFile `other.zx`:\n```zxl\nnamespace other;\n\nfn printHello() {\n  println(\"Hello from other.zx!\");\n}\n```\n\n### Loops\n\n```zxl\nfor i in range(10) {\n  println(i);\n}\n\nfor i in range([10, 20]) {\n  println(i);\n}\n\nfor i in range([10, 20, 2]) {\n  println(i);\n}\n\nfor letter in \"Hello\" {\n  println(letter);\n}\n\nfor i in 7 {\n  println(i);\n}\n\nfor i in [5, 6, 7] {\n  println(i);\n}\n\nlet i = 0;\nwhile i \u003c 10 {\n  println(i);\n  i = i + 1;\n}\n```\n\n### Arrays\n\n```zxl\nuse iter;\n\nlet myArr = array {\n  name: \"John\",\n  \"age\": 30,\n  city: \"New York\",\n};\n\nfor row in iter.Array(myArr) {\n    println(row.key + \":\", row.value);\n}\n```\n\n### Concurrency\n\n```zxl\nuse thread;\n\nfn doLater() {\n  // some task\n}\n\nthread.spawn(doLater);\nthread.sleep(1000); // Wait one second\n```\n\n### Usage of Portals\n\n```zxl\nuse thread;\n\ndefine User {\n  let name;\n  let age;\n  let portal;\n\n  fn construct(name, age) {\n    this.name = name;\n    this.age = age;\n  }\n\n  fn intro() {\n    println(\"Hello, I am \", this.name, \"and I am \", this.age, \" years old.\");\n    this.portal.send(true);\n  }\n}\n\nlet users = [];\nusers.append(User(\"John\", 25));\nusers.append(User(\"Jane\", 23));\nusers.append(User(\"Emily\", 21));\n// ...\n\n// create a portal for communication between threads\nconst portal = thread.portal(users.length);\n// create a custom spawner with users.length async threads\nconst spawner = thread.spawner(users.length);\n\n// spawn all async methods\nfor user in users {\n  user.portal = portal;\n  spawner.spawn(user.intro);\n}\n\n// wait for all async methods to finish\nfor i in (users.length) {\n  // portal.receive() waits until any async method sends a message to it\n  portal.receive();\n}\n\n// close the portal and spawner\nportal.close();\nspawner.close();\n```\n\n## Support\n\nSupport my work by giving this project a star.\n\n- [PayPal](https://www.paypal.me/instasiteshu)\n- [Ko-Fi](https://ko-fi.com/bndrmrtn)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbndrmrtn%2Fzxl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbndrmrtn%2Fzxl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbndrmrtn%2Fzxl/lists"}