in ,

Cello • High Level C, Hacker News

  # include "Cello.h"  int main (int argc, char argv) {    var items=new (Array, Int,     $ I (8), $ I (5), $ I (16,     $ I (15), $ I (16), $ I (90));    / Iterate over indices using "range" /   foreach (i in range ($ I (len (items)))) {     print ("Item Range% i is% i  n", i, get (items, i));   }    / Iterate over every other item with "slice" /   foreach (item in slice (items, _, _, $ I (2))) {     print ("Item Slice% i  n", item);   }    return 0; }  

  # include " Cello.h "  / Define a normal C structure / struct Point {   float x, y; };  / Make it compatible with Cello / var Point=Cello (Point);  int main (int argc, char argv) {    / Create on Stack or Heap /   var p0=$ (Point, 0.0, 1.0);   var p1=new (Point, $ (Point, 0.0, 2.0));    / It can be shown, compared, hashed, etc ...     p0:    p1:    cmp: 1   hash:  l   /   print ("p0:% $  np1:% $  ncmp:% i  nhash:% ul  n",     p0, p1, $ I (cmp (p0, p1)), $ I (hash (p0)));    / And collected by the GC when out of scope /   return 0; }  

F.A.Q
  • Why does this exist?
  • I made Cello as a fun experiment to see what C looks like hacked to its limits. As well as being a powerful library and toolkit, it should be interesting to those who want to explore what is possible in C.
  • How does it work?
  • I recommend reading A Fat Pointer Library to get an overview of how Cello works.You can also peek at the source code, which I’m told is fairly readable, or ask me any questions you like via e-mail.
  • Can it be used in Production? It might be better to try Cello out on a hobby project first. Cello does aim to be production ready , but because it is a hack it has its fair share of oddities and pitfalls, and if you are working in a team, or to a deadline, There is much better tooling, support and community for languages ​​such as C .
  • Is anyone using Cello?
  • People have experimented with it , but there is no high profile project I know of that uses it. Cello is too big and scary a dependency for new C projects if they want to be portable and easy to maintain.

  • Can I get involved?
  • Yes! That would be great. If you do anything with Cello I’d love to know, you can e-mail me at [email protected] , or help with the development at the Cello github repo . Contributions are very welcome.
  • Who are you?
  • Hello! I’m Daniel Holden. You many know me from a book I wrote
  • or my personal website . I also have a rarely updated twitter account . (Read More)

    What do you think?

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    GIPHY App Key not set. Please check settings

    FreeBSD is an amazing operating system, Hacker News

    Researchers completely re-engineer yeast to make more biofuel, Ars Technica

    Researchers completely re-engineer yeast to make more biofuel, Ars Technica