{"id":13610001,"url":"https://github.com/dibsonthis/Glide","last_synced_at":"2025-04-12T22:32:26.151Z","repository":{"id":153582358,"uuid":"598095629","full_name":"dibsonthis/Glide","owner":"dibsonthis","description":"Glide programming language","archived":false,"fork":false,"pushed_at":"2023-04-07T11:06:22.000Z","size":1886,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-07T16:41:40.628Z","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":"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":"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":"2023-02-06T11:47:00.000Z","updated_at":"2023-05-02T21:32:19.000Z","dependencies_parsed_at":"2023-05-19T18:15:33.294Z","dependency_job_id":null,"html_url":"https://github.com/dibsonthis/Glide","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/dibsonthis%2FGlide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FGlide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FGlide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dibsonthis%2FGlide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dibsonthis","download_url":"https://codeload.github.com/dibsonthis/Glide/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248641090,"owners_count":21138139,"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-01T19:01:40.174Z","updated_at":"2025-04-12T22:32:25.289Z","avatar_url":"https://github.com/dibsonthis.png","language":"C++","readme":"## Glide: Programming Language geared towards data transformations\n\nGlide is a statically (and dynamically) typed language designed to make reading and writing data transformations easier.\n\n# How to use:\n\nTo compile your own version of Glide, simply change the \"Type\" in main.cpp to \"INTERP\", and compile using \"C/C++: clang++ build interpreter\". Note: currently only tested on Mac, but try your luck with the Windows build too. It may throw some errors that should be easy to iron out.\n\nIf you want to build in developer mode, leave \"Type\" as \"DEV\" and compile using \"C/C++: clang++ build and debug active file\".\n\nFor both instances, you need to be in main.cpp for compilation to work.\n\nIf you compile the interpreter, the executable is found in \"bin/build/interp\".\n\nIf you compile in debug mode, the executable is found in \"bin/build/dev\".\n\n# Examples\n\n## Basic data transformation:\n```\nx = 1..100 \n\t\u003e\u003e map[x =\u003e x * 2.5]\n\t\u003e\u003e filter[x =\u003e x \u003e 125]\n\t\u003e\u003e reduce[+]\n\nprint[x]\n\nOutput: 9187.500000\n```\n\n## Multiple dispatch + refinement types:\n```\nPosInt :: type = x::int =\u003e x \u003e 0\n\nDeposit :: type = {\n    amount: PosInt\n}\nWithdrawal :: type = {\n    amount: PosInt\n}\nCheckBalance :: type\n\napplyAction = [action::Deposit] =\u003e \"Depositing $\" + action.amount\napplyAction = [action::Withdrawal] =\u003e \"Withdrawing $\" + action.amount\napplyAction = [action::CheckBalance] =\u003e \"Checking balance...\"\n\nd :: Withdrawal = {\n    amount: 35\n}\n\nres = applyAction[d]\n\n// Output: \"Withdrawing $35\"\n```\n\n## Pattern matching:\n```\npop_f = ls::[] =\u003e {\n    match[ls] {\n        []: []\n        [first ...rest]: [first rest]\n        []\n    }\n}\n\nres = 1..10 \u003e\u003e pop_f\n\n// Output: [1 [2 3 4 5 6 7 8 9]]\n```\n\n```\nCash :: type = {\n    amount: int\n}\nPayPal :: type = {\n    amount: int\n    email: string\n}\nCreditCard :: type = {\n    amount: int\n    cardNumber: string\n    securityCode: string\n}\n\nPaymentMethod = Cash | PayPal | CreditCard\n\ndescribePayment = [method::PaymentMethod] =\u003e {\n    match[method] {\n        Cash: \"CASH - $\" + method.amount\n        PayPal: \"PAYPAL - $\" + method.amount + \" - \" + method.email\n        CreditCard: \"CREDIT - $\" + method.amount + \" - \" + method.cardNumber + \" - \" + method.securityCode\n        \"Undefined payment method\"\n    }\n}\n\np1 :: PaymentMethod = {\n    amount: 23556\n    cardNumber: \"838128384\"\n    securityCode: \"8372\"\n}\n\np2 :: PaymentMethod = {\n    amount: 42882\n}\n\np3 :: PaymentMethod = {\n    amount: 42882\n    email: \"blah@test.com\"\n}\n\ndescribePayment[p2]\n\n// Output: \"CASH - $42882\"\n```\n\n## Tagged unions + pattern matching:\n```\nAnimal = Dog::type | Cat::type | Bird::type\n\np = [bool | Animal]\n\nx :: p = [true Bird]\n\ncategoryId = match[x] {\n    [true {Dog}]: 1\n    [true {Cat}]: 2\n    [true {Bird}]: 3\n    [false {Dog | Cat}]: 4\n    [false {Bird}]: 5\n    (-1)\n}\n\ncategoryId \u003e\u003e print\n\n// Output: 3\n```\n\n# Data tranformation API\n\n## This is an example of data transformation using the csv module:\n\n```\ncsv = import[\"imports/csv.gl\"]\n\nemployees = csv.load[\"src/data/employees.csv\" schema: { \n\tid: int\n\tage: int \n\tsalary: float\n\tis_manager: bool\n\tdepartmentId: int\n}]\n\ndepartments = csv.load[\"src/data/departments.csv\" schema: {\n\tid: int\n}]\n\nextract_schema = {\n\tid: id::int =\u003e \"EMP_\" + id\n\tname: name::string =\u003e name\n\tsalary: salary::int =\u003e salary\n\tis_manager: is_manager::bool =\u003e is_manager\n\tdepartment: obj =\u003e csv.ref[departments \"id\" obj.departmentId]\n}\n\nstage_1_schema = {\n\tsalary: [salary::int obj] =\u003e match[obj] {\n\t\t{ is_manager: true }: salary * 1.35\n\t\tsalary * 0.85\n\t}\n}\n\nstage_2_schema = {\n\ttax: obj =\u003e match[obj] {\n\t\t{ salary: x =\u003e x \u003c 100000 }: 10\n\t\t14.5\n\t}\n\temployeeID: obj =\u003e \"00\" + obj.id.split[\"_\"].last\n}\n\nemployees \n\u003e\u003e csv.extract[extract_schema]\n\u003e\u003e (t1=)\n\u003e\u003e csv.reshape[stage_1_schema]\n\u003e\u003e (t2=)\n\u003e\u003e csv.reshape[stage_2_schema]\n\u003e\u003e (t3=)\n\u003e\u003e csv.group_by[\"department\" csv.COUNT[]]\n\u003e\u003e (t4=) \n\u003e\u003e (x =\u003e t3)\n\u003e\u003e csv.group_by[\"department\" csv.AVG[\"salary\"]]\n\u003e\u003e (t5=)\n```\n\n## Employees.csv\n\n```\nid,name,age,location,salary,is_manager,departmentId\n1,Allan Jones,32,Sydney,100000.00,true,1\n2,Allan Jones,25,Melbourne,150000.00,false,1\n3,James Wright,23,Brisbane,89000.00,false,2\n4,Haley Smith,25,Bondi,78000.00,true,2\n5,Jessica Mayfield,27,Greenacre,120000.00,true,2\n6,Jessica Rogers,22,Surry Hills,68000.00,false,3\n7,Eric Ericson,24,Camperdown,92000.00,false,4\n```\n\n## Departments.csv\n\n```\nid,name\n1,Sales\n2,Marketing\n3,Engineering\n4,Analytics\n```\n\n## Output of t3:\n\n```\n[ {\n  is_manager: true\n  name: Allan Jones\n  salary: 135000.000000\n  id: EMP_1\n  department: Sales\n  employeeID: 001\n  tax: 14.500000\n} {\n  is_manager: false\n  name: Allan Jones\n  salary: 127500.000000\n  id: EMP_2\n  department: Sales\n  employeeID: 002\n  tax: 14.500000\n} {\n  is_manager: false\n  name: James Wright\n  salary: 75650.000000\n  id: EMP_3\n  department: Marketing\n  employeeID: 003\n  tax: 10\n} {\n  is_manager: true\n  name: Haley Smith\n  salary: 105300.000000\n  id: EMP_4\n  department: Marketing\n  employeeID: 004\n  tax: 14.500000\n} {\n  is_manager: true\n  name: Jessica Mayfield\n  salary: 162000.000000\n  id: EMP_5\n  department: Marketing\n  employeeID: 005\n  tax: 14.500000\n} {\n  is_manager: false\n  name: Jessica Rogers\n  salary: 57800.000000\n  id: EMP_6\n  department: Engineering\n  employeeID: 006\n  tax: 10\n} {\n  is_manager: false\n  name: Eric Ericson\n  salary: 78200.000000\n  id: EMP_7\n  department: Analytics\n  employeeID: 007\n  tax: 10\n} ]\n```\n\n## Explanation of the above code:\n\n1- Import the csv module\n\n2- Load the 2 pieces of data (employees and departments). Think of these as two tables in a database. The schema object is used to transform the types of the data, since csv data is all string based. This may or may not be useful once we load from a database, given that we may already know the types ahead of loading.\n\n3- We define the extraction schema. This is the first stage of the pipeline. What we're doing here is extracting the relevant columns, but also with the option to transform that data as we extract (as shown in the id column). We can also create new columns here based on known data, as shown in the departments column. Any column not defined here is not extracted.\n\n4- We then set up two other stages, which do the same thing as the extraction schema, except they only affect the columns defined in the schema. The rest of the columns are left intact.\n\n5- We run the pipeline, starting with the extraction, and then the reshaping of the data. Note that we are saving each step of the transformation in its own variable for future reference (this is possible because we are piping the result of a transformation into a partial equal op, which then evaluates and saves the data).\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdibsonthis%2FGlide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdibsonthis%2FGlide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdibsonthis%2FGlide/lists"}