TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Cello – A library that brings higher level programming to C

348 pointsby dlsymabout 8 years ago

14 comments

int_19habout 8 years ago
Looking at the code, a great deal of this is non-portable and&#x2F;or U.B, so I would hesitate to call it C. And I&#x27;m not talking about some hypothetical problems, but stuff that should surface quite soon. For example, this is how stack allocations are made:<p><pre><code> #define alloc_stack(T) ((struct T*)header_init( \ (char[sizeof(struct Header) + sizeof(struct T)]){0}, T, AllocStack)) </code></pre> So far as I can see, there are basically no alignment guarantees here - the returned pointer to the char array is not guaranteed to be aligned properly for Header (which is a struct of a single void* field), nor is there any attempt to align T inside the array. If things get misaligned, on x86 and x64, it&#x27;ll work (but possibly much slower than normal), but on e.g. ARM you&#x27;ll get all kinds of weird things happening.
评论 #14096738 未加载
krat0sprakharabout 8 years ago
Cello seems to make its way to HN quite often. The author (also of buildyourownlisp.com fame) has previously posted his motivations for building libcello on HN: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8800575" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8800575</a><p>Another previous discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6047576" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=6047576</a>
AnimalMuppetabout 8 years ago
&gt; Can it be used in Production?<p>&gt; 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++.<p>Wow. Straight talk instead of salesmanship. High marks for that.
Safety1stClydeabout 8 years ago
As a superstitious C programmer, typedefing (void star) feels like walking on the cracks in the pavement, crossing the path of a black cat, walking under a ladder, or squeezing a lemon under the full moon to me. These kinds of tricks seem very clever at first but there always comes a point when they start to break down. I&#x27;d be leery about using union in 2017, but typedefing (void star) is like putting on your underpants outside your trousers, thinking you&#x27;re superman and jumping out of a window thinking that you can fly.
评论 #14096045 未加载
wycabout 8 years ago
The style reminds me of some J implementations!<p><pre><code> #define DO(n,x) {I i=0,_n=(n);for(;i&lt;_n;++i){x;}} </code></pre> <a href="http:&#x2F;&#x2F;code.jsoftware.com&#x2F;wiki&#x2F;Essays&#x2F;Incunabulum" rel="nofollow">http:&#x2F;&#x2F;code.jsoftware.com&#x2F;wiki&#x2F;Essays&#x2F;Incunabulum</a>
评论 #14093295 未加载
评论 #14101327 未加载
评论 #14101328 未加载
antirezabout 8 years ago
Cool. This is a bit extreme but on purpose I think, it is an exploratory project AFAIK. If I had my hands free I would spend my time writing a new C library since I firmly believe that the problems of C are, for the larger part, in its standard library and not in the language itself. C memory model is unsafe but if mediated by a sane library for strings, and if by default you have most of the things where bugs are put (data structures, facilities for parsing, ...) things get a lot simpler and safer.
wybiralabout 8 years ago
What features make it &quot;higher level&quot;? It looks like syntactic sugar on C code without any real improvements (aside from GC).
评论 #14094169 未加载
评论 #14093976 未加载
评论 #14094048 未加载
评论 #14095149 未加载
scytheabout 8 years ago
IIRC Cello doesn&#x27;t enforce type safety, which means you can foldl but it&#x27;s not much different from writing foldl in C and using void pointers everywhere.<p>I had thought about trying to make a type-safe version of Cello but I eventually realized that I can&#x27;t do it in cpp so at that point it became its own language and too much work (I did not write Cello).
评论 #14094219 未加载
amaksabout 8 years ago
There are several reasons why people use C, one of them is that the language makes it very explicit what generated code is going to look like. That&#x27;s one of the reasons why Windows kernel is written in C (<a href="https:&#x2F;&#x2F;msdn.microsoft.com&#x2F;en-us&#x2F;library&#x2F;windows&#x2F;hardware&#x2F;ff559740(v=vs.85).aspx" rel="nofollow">https:&#x2F;&#x2F;msdn.microsoft.com&#x2F;en-us&#x2F;library&#x2F;windows&#x2F;hardware&#x2F;ff...</a>, <a href="https:&#x2F;&#x2F;view.officeapps.live.com&#x2F;op&#x2F;view.aspx?src=http:&#x2F;&#x2F;download.microsoft.com&#x2F;download&#x2F;5&#x2F;b&#x2F;5&#x2F;5b5bec17-ea71-4653-9539-204a672f11cf&#x2F;KMcode.doc" rel="nofollow">https:&#x2F;&#x2F;view.officeapps.live.com&#x2F;op&#x2F;view.aspx?src=http:&#x2F;&#x2F;dow...</a>). Libraries like this obfuscate source code.
评论 #14094016 未加载
zaisteabout 8 years ago
Here&#x27;s the author of Cello talking about the project at PolyConf in 2015: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=bVxfwsgO00o" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=bVxfwsgO00o</a><p>« In this talk I dig into the depths of my programming library Cello - a fun experiment to see what C looks like when pushed to it&#x27;s limits. I&#x27;ll cover how Cello works internally, some of the cuter tricks used to make it look and feel so different, what is in store for future versions of Cello, and why it is important to push languages to their boundaries. »
kbartabout 8 years ago
How about performance? As I understand, it uses fat pointers fat pointers and GC, so performance drop is expected. There are not many reasons to use C nowadays beside performance.
评论 #14095792 未加载
hydrocatabout 8 years ago
Isn&#x27;t this something similar to vala ?
评论 #14095763 未加载
ndesaulniersabout 8 years ago
Why not just use C++?
评论 #14092177 未加载
评论 #14091911 未加载
评论 #14092011 未加载
评论 #14098775 未加载
评论 #14092031 未加载
评论 #14091921 未加载
r00t-about 8 years ago
Either the examples are terrible or the library is. I&#x27;m leaning towards the latter.