{"id":13609008,"url":"https://github.com/davidgiven/cowgol","last_synced_at":"2026-01-17T04:35:39.677Z","repository":{"id":38816674,"uuid":"93265830","full_name":"davidgiven/cowgol","owner":"davidgiven","description":"A self-hosted Ada-inspired programming language for very small systems.","archived":false,"fork":false,"pushed_at":"2026-01-04T15:17:25.000Z","size":9518,"stargazers_count":264,"open_issues_count":26,"forks_count":25,"subscribers_count":11,"default_branch":"master","last_synced_at":"2026-01-09T07:59:09.672Z","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":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidgiven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-06-03T18:12:02.000Z","updated_at":"2026-01-04T15:17:29.000Z","dependencies_parsed_at":"2024-01-17T01:32:27.203Z","dependency_job_id":"d750e860-421e-414d-9837-bd2a17c438f5","html_url":"https://github.com/davidgiven/cowgol","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/davidgiven/cowgol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidgiven%2Fcowgol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidgiven%2Fcowgol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidgiven%2Fcowgol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidgiven%2Fcowgol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidgiven","download_url":"https://codeload.github.com/davidgiven/cowgol/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidgiven%2Fcowgol/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28495232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2024-08-01T19:01:31.668Z","updated_at":"2026-01-17T04:35:39.655Z","avatar_url":"https://github.com/davidgiven.png","language":"C","readme":"Cowgol 2.0\n==========\n\n\nWhat?\n-----\n\nCowgol is an experimental, Ada-inspired language for very small systems\n(6502, Z80, etc). It's different because it's intended to be self-hosted on\nthese devices: the end goal is to be able to rebuild the entire compiler on\nan 8-bit micro, although we're not there yet.\n\nHere's the bullet point list of features:\n\n  - a properly type safe, modern language inspired by Ada\n\n  - the compiler is written in itself and is fully bootstrapped\n\n  - a table-driven, easy to port backend (the 80386 backend is 1.2kloc with\n    no other compiler changes needed)\n\n  - tiny: the 80386 Linux compiler binary is 70kB (including ELF overhead)\n\tThe 8080 CP/M compiler 58kB (split across two executables)\n\n  - fast: on my PC it'll compile itself in ~~360ms~~ ~~130ms~~ 80ms.\n\n  - global analysis: dead code removal and static variable allocation,\n    leading to small and efficient binaries\n\n### About the compiler\n\nRight now it's in a state where you can build the cross-compiler on a PC, then\nuse it to compile the compiler for your selected device, and if it's small\nenough to fit use *that* to compile and run real programs. Realistically you'll\nbe cross-compiling on a PC.\n\nThe following targets are supported. Adding more is easy.\n\n  - Z80 and 8080, on CP/M.\n\n  - 6502 and 65c02, on the BBC Micro with Tube second processor.\n\n  - 6303, on the 6303 version of Fuzix (if anyone knows about FLEX and wants to\n\tmake this work, please get in touch).\n\n  - 6502 interpreted bytecode, on the BBC Micro with Tube second processor;\n\tthis works just like above, but produces a stack-based bytecode with\n\tintegrated interpreter. It's much smaller, but also slower.\n\n  - 80386, on Linux.\n\n  - ARM Thumb2, on Linux.\n\n  - PowerPC, on Linux.\n\n  - 68000, on Atari ST TOS and Amiga CP/M-68k (although most of the system calls aren't hooked up\n\tyet so you can't do anything more than print stuff) and Linux m68k (if you\n\tcan still find a machine which will run this).\n\n  - 8086, on DOS (it emits small mode .exe files with 64kB of code and 64kB of data).\n\n  - PDP11, on V7 Unix (thanks to\n\t[shattered@github](https://github.com/shattered) for contributing the PDP11\n\tbackend for this).\n\n  - Generic and terrible C. This produces very big and slow binaries which\n    are used for bootstrapping the compiler if you don't have a Cowgol\n\tcompiler.\n\n  - Basic. Yes, really --- there's a backend which will transpile into terrible\n\tMicrosoft Basic. I wrote this mainly as a joke and only a subset of the\n\tlanguage is supported, but it does work.\n\nIn addition, there's emulator and assembler support for these platforms, but no compiler:\n\n  - the OBP spaceflight computer (used by, among other things, the OAO-3\n\tCopernicus orbiting observatory)\n\n(It _used_ to [support the Apollo Guidance\nComputer](http://cowlark.com/2019-07-20-cowgol-agc/index.html) used in the\nApollo spacecraft, but I had to remove the code generator while rewriting the\ncompiler and I haven't reworked the AGC backend.)\n\nIn terms of machines you can run the compiler _on_:\n\n  - 80386 and ARM and PowerPC and 68000 Linux, duh.\n\n  - A BBC Micro with Tube second processor. [Follow this link for a live\n\tin-browser\n\tdemo](https://bbc.godbolt.org/?\u0026model=MasterTurbo\u0026disc1=https://cowlark.com/cowgol/bbct.ssd\u0026disc2=https://cowlark.com/cowgol/bbctwork.ssd\u0026rom=https://cowlark.com/cowgol/assembler.rom)\n\tcourtesy of Matt Godbolt's excellent JSBeeb emulator: press SHIFT+F12\n\t(that's SHIFT+BREAK on a BBC Micro) to start the compiler, and when it's\n\tdone type OUT to run the result. This is generating full 65c02 machine\n\tcode.\n\n  - Generic CP/M (both Z80 and 8080).\n\nMany of the other platforms have unfinished system call libraries, so while the\ncompiler tests all pass and the compilers are being built, they won't work if\nyou run them. This should be easy to fix if necessary --- let me know and ask.\n(I just haven't got round to it yet.) Other platforms have working system call\nlibraries but Cowgol doesn't provide an assembler, so you need to source your\nown (for example: MS-DOS and Atari ST TOS). So the compiler technically works\nthere; you just can't do anything useful with it.\n\n### About the language\n\nHere's a randomly chosen example pulled from the compiler source.\n\n```\n# Free up the node tree rooted in the parameter. This is more exciting than it\n# should be because we don't have recursion.\n#\n# Editorial note: actually this subroutine no longer exists in the compiler\n# source code because I replaced it with something simpler and better. No\n# matter, the example still stands.\nsub Discard(node: [Node]) is\n        var pending := node;\n        while pending != (0 as [Node]) loop\n                node := pending;\n                pending := node.dlink;\n\n                # Unlink and push any children.\n                if node.left != (0 as [Node]) then\n                        node.left.dlink := pending;\n                        pending := node.left;\n                end if;\n                if node.right != (0 as [Node]) then\n                        node.right.dlink := pending;\n                        pending := node.right;\n                end if;\n\n                # Now free this node.\n                Free(node as [uint8]);\n        end loop;\nend sub;\n```\n\nThe bullet list set of features is:\n\n  - strongly typed --- no implicit casting (not even between integers of\n\tdifferent widths or signedness)\n\n  - records, pointers, etc.\n\n  - subroutines with multiple input and output arguments\n\n  - arbitrarily nested subroutines, with access to variables defined in an\n\touter subroutine\n\n  - no recursion and limited stack use (most of the platforms I'm targeting\n\tdon't really support stack frames)\n\n  - byte, word and quad arithmetic for efficient implementation on small\n\tsystems\n\n  - simple type inference of variables if they're assigned during a declaration\n\n  - separate compilation with global analysis\n\nThere's more about the language in the links below.\n\n\n\nWhy?\n----\n\nI've always been interested in compilers, and have had various other\ncompiler projects: [the Amsterdam Compiler Kit](http://tack.sourceforge.net/)\nand [Cowbel](http://cowlark.com/cowbel/), to name two. (The\n[languages](http://cowlark.com/index/languages.html) section of my website\ncontains a fair number of entries. The oldest compiler which still exists\ndates from about 1998.)\n\nCowgol is based on what I've learnt from all this. It's supposed to be\n_useful_, not just a toy. I'm pleasantly surprised by how good the generated\ncode is; not that it's anything up to that of, say, gcc, but the main code\ngeneration binary of gcc is 23552kB, and Cowgol's is 65kB...\n\n\n\nWhere?\n------\n\n- [Check out the GitHub repository](http://github.com/davidgiven/cowgol) and\n  build from source. (Alternatively, you can download a source snapshot from\n  [the latest release](https://github.com/davidgiven/cowgol/releases/latest),\n  but I suggest the GitHub repository because I don't really intend to make\n  formal releases often.) [Build instructions are on their own page.]\n  (doc/building.md)\n\n- [Ask a question by creating a GitHub\n  issue](https://github.com/davidgiven/cowgol/issues/new), or just email me\n  directly at [dg@cowlark.com](mailto:dg@cowlark.com). (But I'd prefer you\n  opened an issue, so other people can see them.)\n\n\n\nHow?\n----\n\nWe have documentation! Admittedly, not much of it.\n\n- [How to build and use the compiler](doc/building.md); tl;dr: **read this**.\n\n- [Everything you want to know about Cowgol, the language](doc/language.md);\n  tl;dr: very strongly typed; Ada-like syntax; multiple return parameters; no\n  recursion; limited aliasing; nested functions.\n\n- [An overview of Cowgol, the toolchain](doc/toolchain.md); tl;dr: single-pass\n  compiler frontend; global analyser and linker feeding into a third-party\n  assembler; written in pure Cowgol.\n\n- [Frequently Asked Questions](doc/faq.md); tl;dr: random.\n\n\n\nWhy not?\n--------\n\nIt's new, it's buggy, it's underdeveloped, and so far only one actual program\nis written in Cowgol, which is the Cowgol compiler. (And cowlink and cowwrap.)\n\nApart from actual bugs, there are some unimplemented parts of the language.\n\n  - no `null`. This one's semantic, but right now you have to cast `0` to\n\tpointer types to use `null`. (I _do_ know about languages which don't have\n\t`null` but they're all for larger machines than Cowgol's aimed at.)\n\n  - no debugging. Well... there's `print()`.\n\n  - no stable standard library. I hack stuff in as I need it.\n\nYour mileage (or kilometrage, depending) may vary. You Have Been Warned.\n\n\n\nWho?\n----\n\nCowgol was written mostly by me, David Given, with additional contributions\nfrom [shattered@github](https://github.com/shattered). Feel free to contact me\nby email at [dg@cowlark.com](mailto:dg@cowlark.com). You may also [like to\nvisit my website](http://cowlark.com); there may or may not be something\ninteresting there.\n\n\n\nLicense?\n--------\n\nCowgol is open source software available [under the 2-clause BSD\nlicense](https://github.com/davidgiven/cowgol/blob/master/COPYING). Simplified\nsummary: do what you like with it, just don't claim you wrote it.\n\nThe exceptions are the contents of the `third_party` directory, which were\nwritten by other people and are not covered by this license. This directory as\na whole contains GPL software, which means that if you redistribute the entire\ndirectory, you must conform to the terms of the GPL.\n\n`third_party/amigacpm` contains a ld linker script for Amiga CP/M-68k,\n(https://github.com/juollila/cpm68k-amiga). The linker script is in the public\ndomain.\n\n`third_party/lib6502` contains a hacked copy of the lib6502 library, which is ©\n2005 Ian Plumarta and is available under the terms of the MIT license. See\n`third_party/lib6502/COPYING.lib6502` for the full text.\n\n`third_party/zmac` contains a copy of the venerable zmac 8080 and Z80\nassembler. It's in the public domain.\n\n`third_party/lemon` contains a copy of the lemon parser generator. It's in the\npublic domain.\n\n`third_party/apout` contains a copy of the apout PDP-11 SysV binary emulator,\nprimarily written by Warren Toomey and Eric A. Edwards. It is distributed under\nthe terms of the MIT license; see `third_party/apout/COPYRIGHT` for the full\ntext.\n\n`third_party/rc2014emu` contains a subset of the RC2014 emulator written by\nAlan Cox. It is distributed under the terms of the GPL 3.0 license; see\n`third_party/rc2014emu/COPYING` for the full text.\n\n`third_party/emu2` constains a copy of the emu2 DOS emulator written by\n[dmsc@github](https://github.com/dmsc) (and others). It is distributed under\nthe terms of the GPL 2.0 license; see `third_party/emu2/LICENSE` for the full\ntext.\n\n`third_party/djlink` contains a copy of the djlink 16-bit linker written by\n[dj@delorie.com](https://delorie.com). It is distributed under the terms of the\nGPL 2.0 license; see x`third_party/djlink/copying` for the full text, with\nadditional grants described in `third_party/djlink/copying.dj`.\n\n`third_party/musashi` contains a copy of the Musashi 68000 emulation library,\nwritten by Karl Stenerud. It is distributable under the terms of the MIT\nlicense; see `third_party/musashi/readme.txt` for the full text. It also in\nturn contains a copy of John R. Hauser's softfloat library, distributable under\na custom but MIT-like license; see `third_party/musashi/softfloat/README.txt`\nfor the text.\n\n`third_party/libz80ex` contains a copy of the z80ex Z80 emulation library,\nwritten bypigmaker57@kahoh57.info. It is distributable under the terms of the\nGPL GPL 2.0 license; see `third_party/z80ex/COPYING` for the text.","funding_links":[],"categories":["Uncategorized","C"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidgiven%2Fcowgol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidgiven%2Fcowgol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidgiven%2Fcowgol/lists"}