{"id":13670461,"url":"https://github.com/Beariish/little","last_synced_at":"2025-04-27T13:32:17.415Z","repository":{"id":45798232,"uuid":"514619782","full_name":"Beariish/little","owner":"Beariish","description":"A small, easily embedded language implemented in a single .c file","archived":false,"fork":false,"pushed_at":"2023-09-07T23:28:53.000Z","size":68,"stargazers_count":290,"open_issues_count":5,"forks_count":18,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-01-27T05:20:26.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/Beariish.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}},"created_at":"2022-07-16T15:46:20.000Z","updated_at":"2025-01-19T18:41:08.000Z","dependencies_parsed_at":"2024-04-01T00:32:07.511Z","dependency_job_id":"e9959647-d12f-4694-9a1d-ca995f51aa7f","html_url":"https://github.com/Beariish/little","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/Beariish%2Flittle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beariish%2Flittle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beariish%2Flittle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beariish%2Flittle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Beariish","download_url":"https://codeload.github.com/Beariish/little/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251145628,"owners_count":21543074,"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-08-02T09:00:42.822Z","updated_at":"2025-04-27T13:32:16.756Z","avatar_url":"https://github.com/Beariish.png","language":"C","funding_links":[],"categories":["C","Others"],"sub_categories":["Embeddable Scripts and Languages"],"readme":"# little - tiny bytecode language\r\nlittle is a _small_, _fast_, _easily embeddable_ language implemented in C.\r\n\r\n---\r\n```js\r\nvar speak = fn(animal) {\r\n    if animal is \"cat\" { return \"meow\" }\r\n    elseif animal is \"dog\" { return \"woof\" }\r\n    elseif animal is \"mouse\" { return \"squeak\" }\r\n    return \"???\"\r\n}\r\n\r\nvar animals = [ \"cat\", \"dog\", \"mouse\", \"monkey\" ]\r\nfor animal in array.each(animals) {\r\n    io.print(string.format(\"%s says %s!\", animal, speak(animal)))\r\n}\r\n```\r\n---\r\n## Feature Overview\r\n* Tiny implementation - core langauge is \u003c2500 sloc in a single .h/.c pair\r\n* Light embedding - compiles down to less than 20kb, 3 API calls to get started\r\n* Reasonably fast for realtime applications\r\n* Low memory footprint with simple mark and sweep garbage collector\r\n* Supports null, numbers, booleans, strings, functions, closures, arrays, tables, and native procedures\r\n* Optional, consise stdlib - an extra ~1000 sloc\r\n* Supports 32- and 64-bit, and will likely compile anywhere!\r\n* Feature-rich C api to integrate and interact with the VM\r\n---\r\n## Simple embedding example\r\n```c\r\n#include \"little.h\"\r\n#include \"little_std.h\"\r\n\r\n// this is called if the vm encounters an error, letting us react\r\nvoid my_error_callback(lt_VM* vm, const char* msg)\r\n{\r\n    printf(\"LT ERROR: %s\\n\", msg);\r\n}\r\n\r\nint main(char** argv, int argc)\r\n{\r\n    lt_VM* vm = lt_open(malloc, free, my_error_callback);                    // open new VM\r\n    ltstd_open_all(vm);                                                      // register stdlib\r\n                   \r\n    const char* my_source_code = ...                                         // read source from file/stream/string\r\n\r\n    uint16_t n_return = lt_dostring(vm, my_source_code, \"my_module\")         // run code as \"my_module\" \r\n    if(n_return) printf(\"LT RETURNED: %s\", ltstd_tostring(vm, lt_pop(vm)));  // if our code returns, print the result\r\n}\r\n```\r\n---\r\n## Links\r\n* **[Language overview](doc/lt.md)**\r\n* **[Standard library](doc/ltstd.md)**\r\n* **[C API reference](doc/api.md)**\r\n* **[C API examples](doc/example.md)**\r\n---\r\n## Known issues\r\n* Recursion is broken, sorry\r\n    * just write better code\r\n\r\n---\r\n## Potential improvements\r\n* Drop the AST for single pass compiler\r\n    *  but only if it actually makes the impl smaller\r\n* precomputed goto/jumptable vm instruction dispatch\r\n* copy fewer strings probably\r\n\r\n---\r\n## Contribution\r\nFeel free to open an issue or pull request if you feel you have something meaninfgul to add, but keep in mind the language is minimalist by design, so any merging will be very carefully picked\r\n\r\n---\r\n## License\r\nPlease see [LICENSE](LICENSE) for details","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBeariish%2Flittle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBeariish%2Flittle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBeariish%2Flittle/lists"}