Live data from Hacker News

Cello – A library that brings higher level programming to C

libcello.org

131–140 of 158 posts

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

#131
post #84

Looking at the code, a great deal of this is non-portable and/or U.B, so I would hesitate to call it C. And I'm not talking about some hypothetical problems, but stuff that should surface quite soon. For example, this is how stack allocations are made: #define alloc_stack(T) ((struct T*)header_init( \ (char[sizeof(struct Header) + sizeof(struct T)]){0}, T, AllocStack)) So far as I can see, there are basically no alig…

Apparently ARM allows unaligned loads now (permitted in ARMv6, default in ARMv7). There seem to be some instructions that don't support it, like STM. Also, afaik code needs to be aligned properly, and function pointers need to be aligned properly lest you will switch between arm and thumb mode. Apparently you can tell the ARM compiler to assume all memory accesses are unaligned.

Under ARMv8, I think alignment is less of an issue.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....

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

#132
post #25

IIRC Cello doesn't enforce type safety, which means you can foldl but it's not much different from writing foldl in C and using void pointers everywhere. I had thought about trying to make a type-safe version of Cello but I eventually realized that I can't do it in cpp so at that point it became its own language and too much work (I did not write Cello).

I'm going to say you're right, given one of the first declarations is typedef void* var; Cello is extremely impressive and could be fun for hobby projects, but for something you'd actually want to use on a real product you'd be better off just creating a new language (it could compile down to C even, like Vala did).

>> (it could compile down to C even, like Vala did).

Nim is another take on that particular strategy.

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

#133

Earlier quoted context omitted.

Why not just write another language, that compiles to machine code, but doesn't totally enforce type safety. Call it Iron.

And make sure Iron has a small group of annoying, hardcore fans who relentlessly disrupts any thread about C or indeed programming in general with their ham fisted advocacy.

To be fair I think I've seen one comment mention rust so far in this thread.

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

#134

Earlier quoted context omitted.

I'm not the parent, but C has a certain simple elegance: everything's an int; those things which aren't ints (e.g. compound structures like structs and arrays) are represented using pointers and offsets, so in a sense they're also ints; except for floats, but meh. In C++, everything is an int; except for objects; and templates; and lambdas; and classes; and exceptions; and all the other things which keep getting chuc…

>I like languages with a clear, simple concept behind their operation. So you dont like C because Undefined behaviour complexitys. Im confused now.

As I said, C is gnarly, mostly for legacy and "practicality" (WorseIsBetter) reasons.

Undefined behaviour, declared as in a language standard, isn't too bad; it might forbid some potentially-useful combinations of expressions, but there'll usually be a workaround.

The problem is compilers which allow undefined behaviour by default, rather than aborting with a helpful error message. This puts the burden of avoiding undefined behaviour on the programmer, which is really bad. This might be unsolvable for C, due to the nature of its particular undefined behaviour.

For brand new languages, I'd recommend minimising undefined behaviour as much as possible, but definitely ensure that any that remains can be found statically!

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

#135

Take a turd and roll it in sugar it's still a turd. To me C is obsolete and most people who have a "reason" to use C don't really have a real reason other than stupidity. C++ does everything that C does except only better. ;-)

>C++ does everything that C does except only better.

This expression is too dangerous to use without try {} catch {}.

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

#136
post #46

The style reminds me of some J implementations! #define DO(n,x) {I i=0,_n=(n);for(;i http://code.jsoftware.com/wiki/Essays/Incunabulum

I think Arthur Whitney's (in)famous code makes its way to HN about once a year.

#A=As #I=it #S=sh #o=o #u=uld

A I Sou

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

#137

Earlier quoted context omitted.

C++ isn't strictly a superset of C! Which I always found crazy. Some C will not compile for C++.

Can you provide C code that will not compile with c++ compiler?

> Can you provide C code that will not compile with c++ compiler?

C99 native complex numbers

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

#138

Why not just use C++?

A good and valid reason would be compiler availability. C++11, 14 and 17 might not stable for every compiler out there.

C++11 and further can be fancy, and not be supported in every possible platform like exotic ones.

Bad reasons would be to talk about the gimmicks of C++, but generally it boils down to programmers being taught well about the language, because it's not an easy one to understand fully, as there many weird pitfalls.

C++ still has to fix some its flaws, like compile times (this should be improved with modules).

So to put it simply, you can still do good work with C because C compilers are just simple and straightforward. When you don't need C anymore (because you only use for it's size and speed, not for the high level), you use something more high level like python. C++ should allow programmers to do everything, but C++ is not perfect and not fully accessible to everyone.

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

#139
post #95

Earlier quoted context omitted.

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 ther…

The run-time cost of C++ abstractions is also NOT what I was talking about.

I was talking about how C++ requires more communication with your team, because some "abstraction" features you might not want (RAII, RTTI, polymorphic dispatch, templates, exceptions) are a lot more easy to introduce than with C.

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

#140

Earlier quoted context omitted.

I'm going to say you're right, given one of the first declarations is typedef void* var; Cello is extremely impressive and could be fun for hobby projects, but for something you'd actually want to use on a real product you'd be better off just creating a new language (it could compile down to C even, like Vala did).

>> (it could compile down to C even, like Vala did). Nim is another take on that particular strategy.

Another recent one is Ivory. http://ivorylang.org
Post reply on HN