{"id":18412936,"url":"https://github.com/viktorstrate/taro-lang","last_synced_at":"2025-04-12T23:48:07.909Z","repository":{"id":50713177,"uuid":"499605021","full_name":"viktorstrate/taro-lang","owner":"viktorstrate","description":"The Taro Programming Language","archived":false,"fork":false,"pushed_at":"2023-08-07T16:57:26.000Z","size":3328,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T23:47:56.280Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://viktorstrate.github.io/taro-lang/","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/viktorstrate.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":"2022-06-03T18:00:26.000Z","updated_at":"2024-03-25T20:23:02.000Z","dependencies_parsed_at":"2024-11-06T03:44:18.070Z","dependency_job_id":"8d2ff835-0ff0-4f1b-9db0-6d29667bc577","html_url":"https://github.com/viktorstrate/taro-lang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktorstrate%2Ftaro-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktorstrate%2Ftaro-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktorstrate%2Ftaro-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viktorstrate%2Ftaro-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viktorstrate","download_url":"https://codeload.github.com/viktorstrate/taro-lang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647257,"owners_count":21139081,"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-11-06T03:44:08.004Z","updated_at":"2025-04-12T23:48:07.889Z","avatar_url":"https://github.com/viktorstrate.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Taro Programming Language\n\nA programming language that transpiles to pure javascript,\nwhich aims for great interoperability with javascript, strictly typed, generics, trait oriented.\nIt is heavily inspired by many functional and modern languages like Swift, Rust and Haskell.\n\nIt is designed such that transpilation to javascript is as direct as possible, by leveraging javascript features with minimal overhead.\n\n## Taro compared to Typescript\n\nThe main goal for both Taro and Typescript is to make programming javascript more safe.\nTypescript does this by adding a type system on top of javascript.\nTaro on the other hand is a completely different programming language that transpiles to javascript.\nThis allows for an even stricter and more flexible type system by leveraging [algebraic data types](https://en.wikipedia.org/wiki/Algebraic_data_type).\nBy making a completely new language, inconsistencies and complexities in Javascript can be removed and new features like [pattern matching](https://en.wikipedia.org/wiki/Pattern_matching) can be added.\n\n## Features\n\n- [x] Super fast type-checking and transpilation\n- [x] Javascript interoperability\n- [x] Strict type safety\n- [x] Type inference\n- [x] Structures\n- [x] Tuples\n- [x] Functions\n- [x] Enumerations\n- [ ] Traits\n- [ ] Generics\n- [ ] Extensions\n- [ ] Async support\n- [ ] Pattern matching\n- [ ] Error handling\n- [ ] Generate Typescript definitions\n\n## Documentation\n\n### Variables\n\nVariables are declared using the `let` keyword.\nBy default a variable is immutable, to declare a mutable variable, the `var` keyword is used instead.\n\n```\nlet greeting = \"Hello, World!\"\n```\n\nA type signature can optionally be added, either for clarity or in special cases where the compiler is unable to infer the type by itself.\n\n```\nlet greeting: String = \"Hello, World!\"\n```\n\n### Structures\n\nStructures are backed by javascript classes.\nTo declare a new structure, each of its attributes must be declared upfront.\nEach attribute is declared in the same way as stand-alone variables are,\nexcept that the value is optional.\nWhen specified, this will be used as a default value when initialized.\n\n```\nstruct Car {\n  let maxSpeed: Number\n  let model: String\n  let wheels = 4\n}\n```\n\nNext, the Car struct can be initialized and assigned to a variable.\nNotice that the wheels attribute is not specified and the default value of 4 is used instead.\nAll attributes without a default value must be specified when instantiating a new instance.\n\n```\nlet deLorean = Car { maxSpeed: 100, model: \"DMC DeLorean\" }\n```\n\nAttributes can then be retrieved as such.\n\n```\nlet model: String = deLorean.model\n```\n\n### Tuples\n\nTuples are typed primitives that combine multiple expressions into one.\n\n```\nlet a: (String, Number, Boolean) = (\"hello\", 42, true)\n```\n\nEach component can be accessed in the following way\n\n```\nlet first: String = a.0\nlet second: Number = a.1\nlet third: Boolean = a.2\n```\n\n### Functions\n\nFunctions can either be declared normally,\n\n```\nfunc sum(a: Number, b: Number) -\u003e Number {\n  return a + b\n}\n```\n\nor as a lambda.\n\n```\nlet sum = (a: Number, b: Number) -\u003e Number {\n  return a + b\n}\n```\n\n### Enumeration\n\nAn enum is declared with a name and then a list of values the enum can take.\nEach value can have a tuple of data associated with it.\n\nEnum declarations are only used to type-check and will be removed when compiled to javascript.\n\n```\nenum IP {\n  v4(Number, Number, Number, Number)\n  v6(String)\n}\n\nlet my_ip = IP.v4(127, 0, 0, 1)\n```\n\nIn contexts where the type can be inferred, it is not necessary to write the name of the enum.\nThis means that the last line above can also be written as such.\n\n```\nlet my_ip: IP = .v4(127, 0, 0, 1)\n```\n\n### Javascript interoperability\n\nRaw javascript can be inserted as an expression anywhere using an escape block.\n\nThe content of an escape block is not evaluated or checked by the compiler,\nit will instead simply be inserted into the raw javascript output.\n\n```\nlet num = @{ 1 + 2 }\n```\n\nThis code will not compile however, this is because the compiler cannot infer the type of the expression `@{ 1 + 2 }`.\nThis can be solved by explicitly stating the type signature of the variable.\n\n```\nlet num: Number = @{ 1 + 2 }\n```\n\n#### Exposing external Javascript\n\nThe `external` keyword can be added in front of a variable to indicate that the object exists somewhere else.\n\n```\nexternal add: (Number, Number) -\u003e Number\nlet x = add(1, 2)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviktorstrate%2Ftaro-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviktorstrate%2Ftaro-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviktorstrate%2Ftaro-lang/lists"}