{"id":15601322,"url":"https://github.com/kevindasilvas/klang","last_synced_at":"2026-04-18T19:32:56.735Z","repository":{"id":63088751,"uuid":"405676471","full_name":"KevinDaSilvaS/klang","owner":"KevinDaSilvaS","description":"Klang is a strongly typed, with type inference, imperative and immutable programming language that transpiles to js.","archived":false,"fork":false,"pushed_at":"2021-09-17T21:45:50.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T19:36:35.829Z","etag":null,"topics":["compiler","compilers","haskell","javascript","klang","programming-language","programming-languages","transpiler"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KevinDaSilvaS.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-12T15:18:03.000Z","updated_at":"2023-01-28T12:06:32.000Z","dependencies_parsed_at":"2022-11-12T18:31:35.090Z","dependency_job_id":null,"html_url":"https://github.com/KevinDaSilvaS/klang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KevinDaSilvaS/klang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinDaSilvaS%2Fklang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinDaSilvaS%2Fklang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinDaSilvaS%2Fklang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinDaSilvaS%2Fklang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KevinDaSilvaS","download_url":"https://codeload.github.com/KevinDaSilvaS/klang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinDaSilvaS%2Fklang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","compilers","haskell","javascript","klang","programming-language","programming-languages","transpiler"],"created_at":"2024-10-03T02:20:46.095Z","updated_at":"2026-04-18T19:32:56.711Z","avatar_url":"https://github.com/KevinDaSilvaS.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# klang\nKlang is a strong typed, with type inference, imperative and immutable programming language that transpiles to js. \nKlang stands for not only the pokemon but the group of two words ```K```(Initial of the creator of the language Kevin da Silva) and ```lang``` for the word language.\nInspired by languages like Haskell, Javascript, python and tiger. Klang is written in haskell and can be run on the browser by compiling into js.\n\n## Features\n\n- Immutability: all variables in klang should start with the '_'(_validVariable) symbol and cant change their state\n- Only change of state occurs in runtime and only the loop iterator changes its state \n- Klang supports two kinds of types: Integers and Strings\n- Klang is a strong typed language that uses from type inference to infer type into the expression\n- Like in haskell ifs can only compare with same type like: Integer == Integer or String == String. Supported comparative operators(==, !=, \u003e, \u003c, \u003e=, \u003c=)\n- Arithmetic expressions(+, -, *, /) are supported for integers\n- Strings are double quoted: \"valid string\"\n- Output is done by: show _myVariable\n- Input is done like _readLine for string values and _readNum for integers\n- Loops are made using the routine keyword\n- Klang has no {} or () to create an execution block you have to use ':' (to open) and ';'(to close)\n\n### Valid Klang code\n```\nlet _v_ := 132 \nlet _hi := \"Hi \" \n\nlet _name     := _readLine\nlet _inputInt := _readNum + 3 + 5\n\nshow _inputInt * 2\n\nroutine 10 :\n    show _hi\n    show _name\n    show _GET_CURR_INDEX\n\n    let _VAR := 3\n    show _VAR\n\n    if _GET_CURR_INDEX \u003e 5 :\n        show \"index is greater than 5\"\n    ;\n;\n```\n\n### Generates the following output:\n```\nconst _v_ = 132  \nconst _hi = \"Hi \"  \nconst _name =  prompt(\"Please enter a valid string\")  \n\nconst _inputInt =  parseInt(prompt(\"Please enter a valid integer\")) + 3 + 5  \nconsole.log( _inputInt * 2 ) \nfor (let _GET_CURR_INDEX = 0; _GET_CURR_INDEX \u003c ( 10 ); _GET_CURR_INDEX++) {\n    console.log( _hi ) \n    console.log( _name ) \n    console.log( _GET_CURR_INDEX ) \n    const _VAR = 3  \n    console.log( _VAR ) \n    if (( _GET_CURR_INDEX ) \u003e ( 5 )) { \n        console.log( \"index is greater than 5\" ) \n     \n    }\n \n}\n\n```\n### Getting Started\n\n- First clone the project.\n- build the project (klang compiler is done in haskell so i recommend using stack by just typing ```stack build```).\n- create a file .klang \n- write the following on the file ```show \"hello world\"```\n- copy the path\n- on terminal run ``` stack run $YOUR_COPIED_FILEPATH```\n- If successful a file of same name with the extension .js will appear on your klang project folder\n- If an error occurs the compiler will give you an output with the possible reason of the error in red\n\n## DOCS KLANG\n\n### Variables\nIn klang all variables are constants and must start with the '_'(underscore) symbol, that means you cant change the value of a variable in your program.\nVariables must be followed of: ```\u003clet\u003e \u003cvariable_name\u003e \u003cassignment_symbol\u003e \u003cvalue\u003e```\nValid variable Assignment: \n```\nlet _myVar := 123\nlet _VARIABLE     := \"_VARIABLE IS A CONSTANT\"\nlet _another_one  := _VARIABLE\nlet _Calculations := _myVar + 2 * 3\nlet _v1 := 123 //outputs an error variable names should start with '_' and then be followed by only [A-Za-z_] characters\nlet _myVar := _VARIABLE //outputs an error constants can be declared only once in your program\n```\n\n### Ifs\nIn klang if statements can contain only one logical expression per if. Ifs in klang support the current comparative operators\u003e \u003e, \u003c, \u003e=, \u003c=, !=, and ==.\nIf statements must be like: ```\u003cif\u003e \u003cexpression_or_value\u003e \u003ccomparative_operator\u003e \u003cexpression_or_value\u003e \u003copen_block\u003e \u003cyour_code\u003e \u003cclose_block\u003e```\nValid if statements: \n```\nlet _myVar := 123\nlet _foo   := 45\n\nif _myVar \u003e _foo : \n    ...code here\n;\n\nif 200 \u003c _foo : \n    ...code here\n;\n\nif \"hi\" == \"HI\" : \n    ...code here\n;\n```\n\n### Loops\nIn klang loops receive an integer as iterator and the current iteration can be accessed by the ```_GET_CURR_INDEX``` reserved variable.\nLoops in klang are like the following:  ```\u003croutine_\u003e \u003cinteger\u003e \u003copen_block\u003e \u003cyour_code\u003e  \u003cclose_block\u003e```\nValid loops: \n```\nlet _myIterator := 5\n\nroutine _myIterator : \n    ...code here\n;\n\nroutine 10 : \n    ...code here\n;\n\nroutine _myIterator * 2 : \n    show _GET_CURR_INDEX // _GET_CURR_INDEX RECEIVES THE CURRENT INDEX VALUE FROM ZERO TO MAX-1 LIKE THE i in a for loop\n    ...code here\n;\n\nshow _GET_CURR_INDEX // OUTSIDE ROUTINE _GET_CURR_INDEX VALUE IS 1, _GET_CURR_INDEX CHANGES ITSELF ONLY INSIDE THE LOOP OUTSIDE IS RESERVED AS THE VALUE 1\n\n```\n### Output\nOutput messages in klang can be done just by using the show keyword\n```\n    show 3 + 4 * 6\n    show \"Hello World\"\n```\n\n### Input\nKlang has an input detection for integers and strings. _readNum and _readLine especifically. Like the _GET_CURR_INDEX the _readNum is also an immutable variable that used out of the context o input in runtime has default value of 1 and _readLine has a default value of \"\" out of the input context.  \n```\n    show _readNum + 4 * 6\n    let r := _readNum\n    routine _readNum : \n        show _readLine\n    ;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevindasilvas%2Fklang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevindasilvas%2Fklang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevindasilvas%2Fklang/lists"}