Live data from Hacker News

Cello – A library that brings higher level programming to C

libcello.org

101–110 of 158 posts

Re: Cello – A library that brings higher level programming to C

#101
post #82
post #54

What features make it "higher level"? It looks like syntactic sugar on C code without any real improvements (aside from GC).

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…

You are right, it looks different: awful. It is even more cloudy than the syntax of bash.

Re: Cello – A library that brings higher level programming to C

#103
post #24

Earlier quoted context omitted.

What do you love about C and hate about C++?

As someone who likes C, I'd like to add a bit of a different look: The aspect that I love about C is how easy it becomes to read. C offers a (arguably) nice programming interface while not allowing the programmer to hide very many things that are going on. C allows you to make nice abstractions, but those abstractions are still built upon the same basic concepts that C supports, and these abstractions generally don't…

I'd argue that with heavy use of macros one can change C quite substantially. Case in point is the linked Cello library.

Pure C with few macros is quite refreshing to read. But it can get hairy quite quickly.

Re: Cello – A library that brings higher level programming to C

#104
post #18

Why not just use C++?

That's like saying "Why not just use lisp?" to a python programmer. They're entirely separate languages (albeit it they do share some commonalities, but not as many as you might think). C is my main language and I dabble in C++. I really dislike C++. I love C. I welcome any efforts to add a bit of higher level functionality to C. I have no desire (ever) to switch to C++.

> That's like saying "Why not just use lisp?" to a python programmer.

Only if a python programmer was resorting to contrived macros to shoehorn some of Lisp's features onto python.

If a python programmer wants to write lisp in python, why not simply use lisp?

Re: Cello – A library that brings higher level programming to C

#105
post #18

Earlier quoted context omitted.

That's like saying "Why not just use lisp?" to a python programmer. They're entirely separate languages (albeit it they do share some commonalities, but not as many as you might think). C is my main language and I dabble in C++. I really dislike C++. I love C. I welcome any efforts to add a bit of higher level functionality to C. I have no desire (ever) to switch to C++.

> That's like saying "Why not just use lisp?" to a python programmer. Only if a python programmer was resorting to contrived macros to shoehorn some of Lisp's features onto python. If a python programmer wants to write lisp in python, why not simply use lisp?

Why do you think that's not already happening? Have a look at Django ORM.

https://github.com/django/django/blob/master/django/db/model...

Re: Cello – A library that brings higher level programming to C

#106
post #82
post #54

What features make it "higher level"? It looks like syntactic sugar on C code without any real improvements (aside from GC).

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…

> * 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);

Re: Cello – A library that brings higher level programming to C

#107
post #71
post #61

Earlier quoted context omitted.

He was trying to illustrate the concept that in C you deal directly with blocks of memory. It can be useful because instead of worrying about the implementation of the language which you're using, you can think about what the hardware is doing and understand what's going to happen based on that. So, for example, you know if at offset 0xDEADBEEF there is are 8 bytes which are holding a number that you want to use, you…

> So, for example, you know if at offset 0xDEADBEEF there is are 8 bytes which are holding a number that you want to use, you can access that chunk of memory and use it however you want. And you can interpret it how it is appropriate for your use case, for example reading it into a string, or an int. Except these days with strict aliasing that's not true. If you access memory through a pointer of the wrong type, you'…

'Strict aliasing' is a dangerous optimisation that OpenBSD's gcc-local disables for a reason.

Re: Cello – A library that brings higher level programming to C

#108
post #95

Earlier quoted context omitted.

"Simple" was a poor choice of words as it doesn't capture what I mean. I meant "fewest possible abstractions over the underlying hardware". BF and Lisp are both much simpler than C, but don't fit what I was trying to get at, as they present a totally different abstraction that is actually quite different from the underlying hardware. (Actually, so is C, since assembly language is itself an abstraction and processors…

Like C, C++ doesn't force you in any way to have extra useless abstractions over the hardware. The rest of your team do (and C make this way harder).

No, you're still not getting it. It isn't about inefficient abstractions. C++ has lots of zero-cost abstractions, but that's not what the parent is talking about.

He's saying that C is simple because it offers a small set of mostly orthogonal features. You get structs, functions, pointers and integers, basically. You don't even have opaque 'String' types or any of that. It's all simple, orthogonal bits.

In C, if there are no macros involved, everything you read in code is arithmetic, function calls or pointer dereferencing. There is no overloading, there are no automatic secret implicit constructors, there are no destructors, no garbage collection, etc.

C++ has a huge amount of behaviour, a lot of it very abstract compared to C. For example, vtables. How are they implemented? That isn't clear at all from reading C++ code. You have to go look at the generated code. If there are vtables in C you have explicitly written

    struct vtable {
            foo_function *foo;
            bar_function *bar; };
    struct a {
            struct vtable vt;
            ...
    };

Re: Cello – A library that brings higher level programming to C

#109

Earlier quoted context omitted.

Here's a bunch of examples: http://www.geeksforgeeks.org/write-c-program-wont-compiler-c...

This is a great example of how many of the things in C that don't compile in C++ are horrible programming practices, and it's really nice that C++ doesn't allow such garbage.

I don't see what is 'horrible programming practice' about

    int *x = malloc(sizeof(int));

Re: Cello – A library that brings higher level programming to C

#110
post #54

What features make it "higher level"? It looks like syntactic sugar on C code without any real improvements (aside from GC).

> without any real improvements (aside from GC). You've really gone down the rabbit hole if you think GC is an improvment

Automatic memory management is an improvement. I prefer region-based memory management to GC but a GC is a godsend in, for example, dynamic languages where you don't want any restrictions, or functional programming where you're pretending to program for a machine with infinite memory.
Post reply on HN