{"id":13466444,"url":"https://github.com/orangeduck/Cello","last_synced_at":"2025-03-25T21:32:16.610Z","repository":{"id":4002858,"uuid":"5100623","full_name":"orangeduck/Cello","owner":"orangeduck","description":"Higher level programming in C","archived":false,"fork":false,"pushed_at":"2024-12-01T16:32:48.000Z","size":2806,"stargazers_count":6928,"open_issues_count":28,"forks_count":384,"subscribers_count":240,"default_branch":"master","last_synced_at":"2025-03-20T13:02:42.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://libcello.org/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orangeduck.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2012-07-18T19:08:47.000Z","updated_at":"2025-03-19T08:40:26.000Z","dependencies_parsed_at":"2022-07-14T08:17:10.732Z","dependency_job_id":"4be62169-7cc2-479a-b675-660667dbb45c","html_url":"https://github.com/orangeduck/Cello","commit_stats":{"total_commits":251,"total_committers":30,"mean_commits":8.366666666666667,"dds":0.4820717131474104,"last_synced_commit":"dfcd86c9c2d32e09d86effd6cfd7c9b97a0291a0"},"previous_names":["orangeduck/libcello"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangeduck%2FCello","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangeduck%2FCello/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangeduck%2FCello/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orangeduck%2FCello/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orangeduck","download_url":"https://codeload.github.com/orangeduck/Cello/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245548343,"owners_count":20633563,"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-07-31T15:00:44.299Z","updated_at":"2025-03-25T21:32:16.192Z","avatar_url":"https://github.com/orangeduck.png","language":"C","readme":"Cello\n=====\n\n__Cello__ is a _library_ that brings higher level programming to C.\n\nBy acting as a _modern_, _powerful_ runtime system Cello makes many things easy \nthat were previously impractical or awkward in C such as:\n\n* __Generic Data Structures__\n* __Polymorphic Functions__\n* __Interfaces / Type Classes__\n* __Constructors / Destructors__\n* __Optional Garbage Collection__\n* __Exceptions__\n* __Reflection__\n\nAnd because Cello works seamlessly alongside standard C you get all the other \nbenefits such as great performance, powerful tooling, and extensive \nlibraries.\n\nExamples\n--------\n\n```c\n#include \"Cello.h\"\n\nint main(int argc, char** argv) {\n\n  /* Stack objects are created using \"$\" */\n  var i0 = $(Int, 5);\n  var i1 = $(Int, 3);\n  var i2 = $(Int, 4);\n\n  /* Heap objects are created using \"new\" */\n  var items = new(Array, Int, i0, i1, i2);\n  \n  /* Collections can be looped over */\n  foreach (item in items) {\n    print(\"Object %$ is of type %$\\n\",\n      item, type_of(item));\n  }\n  \n  /* Heap objects destructed via Garbage Collection */\n  return 0;\n}\n```\n\n```c\n#include \"Cello.h\"\n\nint main(int argc, char** argv) {\n  \n  /* Shorthand $ can be used for basic types */\n  var prices = new(Table, String, Int);\n  set(prices, $S(\"Apple\"),  $I(12)); \n  set(prices, $S(\"Banana\"), $I( 6)); \n  set(prices, $S(\"Pear\"),   $I(55)); \n\n  /* Tables also support iteration */\n  foreach (key in prices) {\n    var val = get(prices, key);\n    print(\"Price of %$ is %$\\n\", key, val);\n  }\n  \n  return 0;\n}\n```\n\nArticles\n--------\n\nLearning Resources:\n\n* [Installation](http://libcello.org/learn/installation)\n* [Cello World](http://libcello.org/learn/cello-world)\n* [Quickstart](http://libcello.org/learn/quickstart)\n* [Common Queries / Pitfalls](http://libcello.org/learn/queries-and-pitfalls)\n\nArticles about its creation and internal workings:\n\n* [Best Improvements of Cello 2.0](http://libcello.org/learn/best-improvements-of-cello-2.0)\n* [A Fat Pointer Library](http://libcello.org/learn/a-fat-pointer-library)\n* [Cello vs C++ vs ObjC](http://libcello.org/learn/cello-vs-cpp-vs-objc)\n* [Benchmarks](http://libcello.org/learn/benchmarks)\n* [Garbage Collection](http://libcello.org/learn/garbage-collection)\n\n\nMore Examples\n-------------\n\n```c\n#include \"Cello.h\"\n\nint main(int argc, char** argv) {\n\n  var items = new(Array, Int, \n    $I( 8), $I( 5), $I(20), \n    $I(15), $I(16), $I(98));\n\n  /* Iterate over indices using \"range\" */\n  foreach (i in range($I(len(items)))) {\n    print(\"Item Range %i is %i\\n\", i, get(items, i));\n  }\n\n  /* Iterate over every other item with \"slice\" */ \n  foreach (item in slice(items, _, _, $I(2))) {\n    print(\"Item Slice %i\\n\", item);\n  }\n  \n  return 0;\n}\n```\n    \n```c\n#include \"Cello.h\"\n\n/* Define a normal C structure */\nstruct Point {\n  float x, y;\n};\n\n/* Make it compatible with Cello */\nvar Point = Cello(Point);\n\nint main(int argc, char** argv) {\n  \n  /* Create on Stack or Heap */\n  var p0 = $(Point, 0.0, 1.0);\n  var p1 = new(Point, $(Point, 0.0, 2.0));\n  \n  /* It can be shown, compared, hashed, etc...\n  **\n  ** p0: \u003c'Point' At 0x000000000022FC58\u003e\n  ** p1: \u003c'Point' At 0x00000000004C7CC8\u003e\n  ** cmp: 1\n  ** hash: 2849275892l\n  */ \n  print(\"p0: %$\\np1: %$\\ncmp: %i\\nhash: %ul\\n\",\n    p0, p1, $I(cmp(p0, p1)), $I(hash(p0)));\n  \n  /* And collected by the GC when out of scope */\n  return 0;\n}\n```\n\nF.A.Q\n-----\n\n* __Why does this exist?__\n\nI made Cello as a fun experiment to see what C looks like hacked to its limits. \nAs well as being a powerful library and toolkit, it should be interesting to \nthose who want to explore what is possible in C.\n\n* __How does it work?__\n\nI recommend reading \n[A Fat Pointer Library](http://libcello.org/learn/a-fat-pointer-library) to get an \noverview of how Cello works. You can also peek at the source code, which I'm \ntold is fairly readable, or ask me any questions you like via e-mail.\n\n* __Can it be used in Production?__\n\nIt might be better to try Cello out on a hobby project first. Cello does aim to \nbe _production ready_, but because it is a hack it has its fair share of \noddities and pitfalls, and if you are working in a team, or to a deadline, \nthere is much better tooling, support and community for languages such as C++.\n\n* __Is anyone using Cello?__\n\nPeople have experimented with it, but there is no high profile project I know \nof that uses it. Cello is too big and scary a dependency for new C projects if \nthey want to be portable and easy to maintain.\n\n* __Can I get involved?__\n\nYes! That would be great. If you do anything with Cello I'd love to know, you \ncan e-mail me at `contact@theorangeduck.com`, or help with the development at \nthe [Cello github repo](https://github.com/orangeduck/libCello). Contributions \nare very welcome.\n\n* __Who are you?__\n\nHello! I'm Daniel Holden. You many know me from a \n[book I wrote](http://www.buildyourownlisp.com/) or my \n[personal website](http://theorangeduck.com/). I also have a rarely updated \n[twitter account](https://twitter.com/anorangeduck).\n","funding_links":[],"categories":["C","Miscellaneous","Scripting","C language extensions"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forangeduck%2FCello","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forangeduck%2FCello","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forangeduck%2FCello/lists"}