{"id":28229296,"url":"https://github.com/dibsonthis/vortex","last_synced_at":"2025-09-02T04:43:36.811Z","repository":{"id":153581471,"uuid":"617981219","full_name":"dibsonthis/Vortex","owner":"dibsonthis","description":"Vortex Programming Language","archived":false,"fork":false,"pushed_at":"2024-04-04T06:36:26.000Z","size":414003,"stargazers_count":80,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-10T14:43:08.086Z","etag":null,"topics":[],"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/dibsonthis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2023-03-23T14:08:49.000Z","updated_at":"2025-05-17T16:14:17.000Z","dependencies_parsed_at":"2025-06-10T14:50:09.369Z","dependency_job_id":null,"html_url":"https://github.com/dibsonthis/Vortex","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dibsonthis/Vortex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FVortex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FVortex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FVortex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FVortex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dibsonthis","download_url":"https://codeload.github.com/dibsonthis/Vortex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FVortex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273233249,"owners_count":25068725,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-05-18T15:14:04.301Z","updated_at":"2025-09-02T04:43:36.801Z","avatar_url":"https://github.com/dibsonthis.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vortex\n\nVortex is a language designed to explore links and relationships between entities.\n\nIt heavily relies on side effects, and as such it would fall under the Dysfunctional Programming paradigm.\n\n## About Vortex\n\nVortex is a dynamically typed programming language that comes with C interoperability out of the box.\n\n## Start Using Vortex Now\n\nRead through the [Vortex Documentation](https://dibs.gitbook.io/vortex-docs/) here to get a deeper understanding of the language and how it works.\n\nThe docs include a Getting Started guide you can follow.\n\n\u003c!-- If you want to start using Vortex straight away, we've pre-compiled the intepreter and standard library modules for an easy to use seamless experience. Running the below will create a self contained scaffold in the current directory that includes everything you need to run Vortex programs, namely:\n\n- The Vortex interpreter\n- Vortex standard library modules\n- Vortex config file\n- Basic source directory scaffold\n- A run script to launch your application\n\nIf you wish to make changes to the scaffolded directory, make sure to update the config file to point to the correct entry point.\n\nTo run the program, simply call `./run` in the root directory. This will launch the intepreter with the provided entry point.\n\nTo create an isolated self contained Vortex environment, simply cd into your desired directory and run the following code:\n\nMac:\n```bash\ncurl https://raw.githubusercontent.com/dibsonthis/vortex-dist/main/mac/scaffold | bash\n```\n\nLinux:\n```bash\ncurl https://raw.githubusercontent.com/dibsonthis/vortex-dist/main/lin/scaffold | bash\n```\n\nWindows:\n```bash\ncurl -LO -k https://raw.githubusercontent.com/dibsonthis/vortex-dist/main/win/scaffold.bat\nscaffold.bat\n``` --\u003e\n\n\u003c!-- More information cam be found here: [Vortex Dist](https://github.com/dibsonthis/vortex-dist) --\u003e\n\n## Features\n\nAlongside the standard functionality that most programming languages provide (eg. branching, loops, lists, objects etc.), Vortex also provides:\n\n- C interop\n- First class functions\n- Decorators\n- Recursion\n- Coroutines\n- Hooks\n\n## Hooks\n\nVortex allows you to bind variables to functions that get called whenever the variable changes. These functions are called hooks. Currently, Vortex has support for only one type of hook: 'onChange'.\n\n(Note: Previous versions of Vortex supported an 'onCall' hook that could be bound to functions, however this has been deprecated in favour of using decorators for this purpose)\n\nFor example, if we wanted automatically increment variable y whenever variable x changes, we could use the 'onChange' hook to do so:\n\n```go\nvar x = 0\nvar y = 0\n\nx::onChange((info) =\u003e {\n    y += 1\n})\n\nx = 2 // y: 1\nx = 4 // y: 2\n```\n\nHooks can also be applied to object properties. In the example below, we're defining a type (really, it's just a function that returns an object, but with slight differences) named 'Color'. Inside this type, we create a function that caps an input to a low and high number. We apply this function to all three arguments passed in to the constructor (r, g, b) to make sure they are capped on init. After that, we assign an 'onChange' hook to each argument, making sure we run the cap function to it each time it changes. Finally, we build the object and return it.\n\nThis ensures that any object instantiated with the constructor 'Color' has constraints that the hook deals with internally. As you can see, adding 400 to 'r' caps it to 255, and subtracting 300 from 'g' caps it to 0, without the user having to do any checks on their behalf.\n\n```go\ntype Color = (r, g, b) =\u003e {\n    const cap = (num, low, high) =\u003e {\n        if (num \u003e high) {\n            return high\n        } else if (num \u003c low) {\n            return low\n        }\n        return num\n    }\n\n    r = cap(r, 0, 255)\n    g = cap(g, 0, 255)\n    b = cap(b, 0, 255)\n\n    r::onChange((info) =\u003e {\n        info.current = cap(info.current, 0, 255)\n    })\n\n    g::onChange((info) =\u003e {\n        info.current = cap(info.current, 0, 255)\n    })\n\n    b::onChange((info) =\u003e {\n        info.current = cap(info.current, 0, 255)\n    })\n\n    return { r: r, g: g, b: b }\n}\n\nvar color = Color(100, 200, 234)\ncolor.r += 400\ncolor.g -= 300\n\nprint(color) // { r: 255.000000, g: 0.000000, b: 234.000000 }\n```\n\nThe function provided to the onChange hook (the function that gets called when the bound variable changes) must have one parameter. This parameter becomes an object at runtime containing the old value and the current value. In the example above, the 'info' parameter is an object that contains the properties 'old' and 'current' that can be references within the hook function.\n\n### Imports\n\nIn order to allow for best practices and modularity, Vortex allows two types of imports: module and variable\n\n## Module Import\n\nModule imports allow the user to import an entire file (module) into the current scope. The imported module can be used as an object:\n\n```go\nimport math : \"../modules/math\"\nconst res = math.fib(10)\n```\n\n## Variable Import\n\nVariable imports allow the user to pick and choose what they want to import into the local scope:\n\n```go\nimport [PI, e, fib] : \"../modules/math\"\n\nconst res = PI * e + fib(20)\n```\n\nVortex's imports use relative paths to retrieve modules.\n\n## How to compile and use Vortex\n\nClone the repo.\n\nGo to the root of the directory.\n\n\u003ci\u003e[Mac/Linux]\u003c/i\u003e Run the build script: build.sh (requires clang++) \\\n\u003ci\u003e[Windows]\u003c/i\u003e Run the build script: winbuild.sh (requires clang++)\n\nIf you're on Mac/Linux, the installer will ask if you want to store the interpreter in usr/local/bin (and set up modules in usr/local/share). If you're on Windows, it asks to install them in C:/Program Files. This allows you to call Vortex from anywhere. If you choose yes, you'll need to input your password to continue.\n\n\u003cb\u003eNote:\u003c/b\u003e If you choose to add Vortex in your bin folder (and modules in share), you can later remove them by running the uninstall.sh script found in usr/local/share/vortex\n\nDepending on your system, the interpreter would have compiled in one of the system folders in bin/build (either mac, windows or linux). The executable we just compiled (vortex) is the interpreter that we'll be using to run our Vortex code.\n\nIf you chose not to add Vortex to your bin folder, you can manually add it to your PATH so you can call it globally. Otherwise, you'll need to either store it somewhere accessible or within your project.\n\nChoosing not to add Vortex to your PATH when building means the standard library modules will also not be added and therefore cannot be used.\n\nHowever, the modules can be compiled separately using the scripts found in the Modules directory.\n\n## Your first Vortex program\n\nLet's write a very quick Vortex program that defines some functions and calls them in a loop.\n\nStart by creating a vortex source file (a file ending in the extension .vtx) and paste the below code in:\n\n```go\nconst addVars = (a, b) =\u003e a + b\nconst mulTwo = (a) =\u003e a * 2\n\nfor (0..5, index) {\n    const add = addVars(index, index + 1)\n    const res = mulTwo(add)\n    print(res, \"\\n\")\n}\n\nprint(\"Obligatory 'Hello World'\\n\")\n```\n\nRun the above Vortex program by calling: vortex \u003cpath/to/dir\u003e/hello.vtx\n\nThis is the expected output:\n\n```go\n2\n6\n10\n14\n18\nObligatory 'Hello World'\n```\n\nCongratulations! You just ran your first Vortex code 🎉\n\n\u003c!-- ## How to start using Vortex\n\nYou can find the [full Vortex documentation here](https://dibs.gitbook.io/vortex-docs/). This includes steps on how to get started using Vortex on your local machine. --\u003e\n\n## Examples\n\n### Priority Queue\n\n```go\n\n// Define a priority queue constructor\n\nconst PriorityQueue = (max = None) =\u003e ({\n    data: [],\n    max: max,\n    enqueue: (value, priority = 0) =\u003e {\n        if (this.max == None) {\n            var _value = [value, priority]\n            this.data.append(_value)\n            this.data = this.data.sort((a, b) =\u003e a[1] \u003c b[1])\n        } else {\n            if (this.data.length() \u003c this.max) {\n                var _value = [value, priority]\n                this.data.append(_value)\n                this.data = this.data.sort((a, b) =\u003e a[1] \u003c b[1])\n            }\n        }\n    },\n    dequeue: () =\u003e {\n        var value = this.data[0][0]\n        this.data.remove(0)\n        if (value == None) {\n            return None\n        }\n        return value\n    },\n    clear: () =\u003e {\n        this.data = []\n    },\n    size: () =\u003e this.data.length(),\n    front: () =\u003e (this.data[0])[0],\n    back: () =\u003e (this.data[this.data.length()-1])[0]\n})\n\nconst pq = PriorityQueue()\n\nconst Priority = {\n    CRITICAL: 0,\n    ERROR: 1,\n    DEBUG: 2,\n    INFO: 3\n}\n\npq.enqueue(\"Logging in\", Priority.INFO)\npq.enqueue(\"Encoutered a critical error\", Priority.CRITICAL)\npq.enqueue(\"Uh ohhhh\", Priority.ERROR)\npq.enqueue(\"Logging out\", Priority.INFO)\npq.enqueue(\"Encountered bug\", Priority.DEBUG)\npq.enqueue(\"The end is here\", Priority.CRITICAL)\n\nwhile (pq.size() \u003e 0) {\n    println(pq.dequeue())\n}\n\n/*\nOutput:\n\nEncoutered a critical error\nThe end is here\nUh ohhhh\nEncountered bug\nLogging in\nLogging out\n*/\n```\n\n### Decorators\n\n```go\nconst Timer = (func) =\u003e {\n    return (...args) =\u003e {\n        const start = clock()\n        var value = func(...args)\n        const duration = clock() - start\n        print(f\"Duration (${func.info().name}): \", duration, \"\\n\")\n        return value\n    }\n}\n\n@Timer\nconst somefunc = () =\u003e {\n    var i = 0\n    for (0..100) {\n        for (0..100) {\n            i += 1\n        }\n    }\n    print(i, \"\\n\")\n}\n\nsomefunc()\n\n/*\nOutput:\n\n10000.000000\nDuration (somefunc): 0.002987\n*/\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdibsonthis%2Fvortex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdibsonthis%2Fvortex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdibsonthis%2Fvortex/lists"}