Hacker News new | ask | show | jobs
by shakna 3353 days ago
I've used Cello for a few side projects, and it doesn't even really feel like C in the end.

Just a few off the top of my head:

* No need to specify type. Use var.

* Simpler for loops

* Inbuilt types for Hash Tables

* File types, making file reading much easier

* Function types, making it easier to pass functions around

* Doctype access

* Threads & Mutexes

* Format strings

* GC (with ability to turn C-types into Cello-types for GCing.)

It is fundamentally syntax-sugar, but enough that what you end up with doesn't necessarily look like C at the end.

    with(f in new(File, $S("test.txt"), $S("r"))) {
      var k = new(String); resize(k, 100);
      var v = new(Int, $I(0));
      foreach (i in range($I(2))) {
        scan_from(f, 0, "%$ is %$ ", k, v);
        show(k); show(v);
      }
    }
(From: http://libcello.org/learn/file)
2 comments

> * No need to specify type. Use var.

I see types everywhere; they appear to just have been moved from the left-hand side to the right-hand side? eg:

  var i0 = $(Int, 5);
  var items = new(Array, Int, i0, i1, i2);
Mmm, kinda.

    var i0 = $(Int, 5);
    i0 = $(String, "Hello");
Perfectly valid.
You are right, it looks different: awful. It is even more cloudy than the syntax of bash.