{"id":13610014,"url":"https://github.com/sebbekarlsson/glms","last_synced_at":"2025-10-13T20:31:08.469Z","repository":{"id":81577926,"uuid":"580138682","full_name":"sebbekarlsson/glms","owner":"sebbekarlsson","description":"Generalized Linear Model Script","archived":false,"fork":false,"pushed_at":"2023-12-15T22:28:34.000Z","size":439,"stargazers_count":40,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T10:06:55.891Z","etag":null,"topics":["interpreter","languages","scripting-languages"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebbekarlsson.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE.md","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-12-19T20:18:20.000Z","updated_at":"2024-11-28T13:27:18.000Z","dependencies_parsed_at":"2023-12-15T23:56:32.658Z","dependency_job_id":null,"html_url":"https://github.com/sebbekarlsson/glms","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Fglms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Fglms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Fglms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Fglms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebbekarlsson","download_url":"https://codeload.github.com/sebbekarlsson/glms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236396249,"owners_count":19142170,"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","languages","scripting-languages"],"created_at":"2024-08-01T19:01:40.276Z","updated_at":"2025-10-13T20:31:02.811Z","avatar_url":"https://github.com/sebbekarlsson.png","language":"C","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"\u003cdiv align=\"center\" style=\"text-align: center;\"\u003e\n  \u003cimg width=\"200\" src=\"glms.png\"/\u003e\n\u003c/div\u003e\n\n### Generalized Linear Model Script\n\u003e A scripting language focused on linear algebra, heavily inspired by [GLSL](https://en.wikipedia.org/wiki/OpenGL_Shading_Language)\n\u003e and [JavaScript](https://en.wikipedia.org/wiki/JavaScript).\n\n\u003e This language comes with types, functions and structures commonly used when doing linear algebra,\n\u003e such as: `vec2`, `vec3`, `vec4`, `dot`, `cross`, `lerp`, `sin`, `cos` ...etc\n\n\u003e (There are more to come, and everything is not implemented yet).\n\n### Caution :warning:\n\u003e This is a work in progress!\n\n### Building \u0026 using it :hammer:\n```bash\nmkdir build\ncd build\ncmake .. \u0026\u0026 make -j8\n\n./glms_e \u003cinput_file.gs\u003e\n```\n\n## Extensions :electric_plug:\n\u003e It's possible to create extensions for `GLMS`,  \n\u003e [here](https://github.com/sebbekarlsson/glms-canvas) is an example.  \n\u003e This specific extension let's you draw on a \"canvas\" using OpenGL.\n```glsl\nimport \"libglms_canvas.so\" as canvasLib;\ntypedef (canvasLib.canvas) canvas; // we're making a \"promise\" to the interpreter\n                                   // that this type will exist later.\n\ncanvas c = canvas(640, 480);\n\n// opens a window, changes can be seen in real-time\nc.shade((vec3 uv, vec3 fragCoord, vec3 resolution, number time) =\u003e {\n    return vec4(0.5 * (0.5 + cos(uv.x*time)), 0.5 * (0.5 + sin(uv.y * time)), cos(time), 1.0);\n});\n```\n\n## Documentation :open_book:\n\u003e To see documentation, built-in functions etc,  \n\u003e Have a look at [this](docs/signatures.md)\n\n## Integration\n\u003e Want to integrate `GLMS` for scripting in an existing project?  \n\u003e Have a look at [this](docs/integration.md)\n\n## Some interesting features :muscle:\n* `fetch` api, similar to the one in Javascript\n* `json` support\n* file IO\n* image manipulation\n* vector math\n* matrix math\n* almost all functions you'd see in `GLSL` exists in `GLMS` as well.\n* extension support (Extend the language by writing extensions)\n* ... and more\n\n\n## Some examples :mag:\n\n### Shader-like image manipulation\n```glsl\nnumber w = 640;\nnumber h = 480;\n\nimage img = image.make(w, h);\n\nimg.shade((vec3 uv, vec3 fragCoord, vec3 resolution) =\u003e {\n  vec3 center = resolution * 0.5;\n  number d = abs(distance(fragCoord, center));\n  number g = 255 * (d \u003c TAU * 6.0 * (1.0 + random()));\n  vec3 color = mix(vec3(0.1, 0.3, 0.9), vec3(1), g);\n  return vec4(color.xyz, 1.0);\n});\n\nimg.save(\"test.png\");\n```\n\n### Functional programming\n```glsl\narray arr = [1, 2, 3];\n\narray mapped = arr.map((number v) =\u003e v * 2);\n\nprint(mapped);  // [2.000000, 4.000000, 6.000000]\n```\n\n### Vectors\n```glsl\nvec3 a = vec3(1, 0, 0);\nvec3 b = vec3(0, 1, 0);\nvec3 c = cross(a, b);\n\nprint(c);\n\nvec3 d = vec3(random(), random(), random());\n\nvec3 e = vec3(random(), random(), random());\n\nprint(distance(d, e));\n\nvec3 f = vec3(random());\n\nprint(f);\n\nnumber dp = dot(d, f);\n\nprint(dp);\n```\n\n### Lerp\n```glsl\nnumber x = 25.012;\nnumber y = 98.241;\n\nnumber z = lerp(x, y, 0.1);\n\nprint(z); // 32.334900\n```\n\n### Clamp\n```glsl\nnumber value = 2312.0;\nvalue = clamp(value, 0.0, 1.0);\nprint(value); // 1.000000\n```\n\n### Structs\n```glsl\ntypedef struct {\n  number age;\n  string name;\n} Person;\n\nPerson p = Person(33, \"John Doe\");\n\nprint(p.age); // 33.000000\nprint(p.name); // John Doe\n```\n\n### HTTP Requests\n```glsl\nresponse r = fetch(\"https://example.org\")\n\nprint(r.status()) // 200\nprint(r.text()) // prints the whole response text\n\n// we can also request json API's\nresponse r = fetch(\"https://jsonplaceholder.typicode.com/posts\");\n\narray p = r.json();\n\nobject firstPost = p[0];\n\nprint(firstPost.title);\n```\n\n### Reading JSON\n```glsl\nfile f = file.open(\"assets/somefile.json\", \"r\");\nstring contents = f.read();\nf.close();\n\nobject data = json.parse(contents);\n  \nprint(data.firstName);\nprint(data.age);\n```\n\n### Template strings\n```glsl\nstring name = \"John\";\nstring x = `hello ${name}`;\n\nprint(x); // hello John\n```\n\n### More examples\n\u003e For more examples, see [examples](EXAMPLES.md)\n\n## FAQ\n\n### Q: Why did you create this language?\n\u003e I was looking for a scripting-language to be used in a game I was developing,\n\u003e and I wanted something that came with vector operatons right out of the box (just like GLSL), but I also\n\u003e wanted it to be expressive like Javascript.\n\n### Q: How do I integrate it into my application / game ?\n\u003e Have a look at [this](docs/integration.md)  \n\u003e If it's still not clear, feel free to create an issue or something with your question.\n\n### Q: What operating systems / platforms can this language run on?\n\u003e It will most likely only work on Linux right now (maybe MacOS as well), but\n\u003e you're always welcome to contribute to support more platforms!\n\n### Q: Any other plans for this language?\n\u003e It would be cool to add some frontends to the language, here's some I've had in mind:\n\n* GLSL - Would be cool to use this as a transpiler for GLSL\n* Javascript - Emitting Javascript would allow for web-applications being created with GLMS\n* WASM - Same reason as the Javascript one\n* 64bit assembly - Because it's cool :sunglasses:\n\n\u003e That being said, I'm not sure I'd ever implement any of these ideas.\n\u003e I'm just using this for scripting a game I'm developing at the moment.\n\n### Q: Is there some kind of community?\n\u003e I just threw together a Discord-server for whoever is interested, you can find it [here](https://discord.gg/tUWNHySs)\n\n### Q: Can I contribute?\n\u003e Please do! Simply fork and create pull-requests :fire:\n\n## Syntax highlighting\n* [glms-mode for emacs](https://github.com/sebbekarlsson/glms-mode)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebbekarlsson%2Fglms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebbekarlsson%2Fglms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebbekarlsson%2Fglms/lists"}