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 – High Level C

251 pointsby thisisastopsignover 5 years ago

18 comments

kazinatorover 5 years ago
The strategy in the GC for determining the stack top for hunting GC roots will not work on all architectures.<p>On aaarch-64, the address of a local dummy variable may be above a register save area in the stack frame, and thus the scan will miss some GC roots.<p>In TXR Lisp, I used to use a hacked constant on aarch64: STACK_TOP_EXTRA_WORDS. It wasn&#x27;t large enough to straddle the area, and so operation on aarch64 was unreliable.<p><a href="http:&#x2F;&#x2F;www.kylheku.com&#x2F;cgit&#x2F;txr&#x2F;commit&#x2F;?id=3aa731546c4691fac333846f15950578425f43da" rel="nofollow">http:&#x2F;&#x2F;www.kylheku.com&#x2F;cgit&#x2F;txr&#x2F;commit&#x2F;?id=3aa731546c4691fac...</a><p>A good stack-top-getting trick occurred to me: call alloca for a small amount of memory and use <i>that</i> address. It has to be below everything; alloca cannot start allocating above some register save area in the frame, because then it would collide with it; alloca has not know the real stack top and work from there.<p>Since we need to scan registers, we use <i>alloca</i> for the size of the register file (e.g. setjmp jmp_buf), and put that there: kill two birds with one stone.<p><a href="http:&#x2F;&#x2F;www.kylheku.com&#x2F;cgit&#x2F;txr&#x2F;commit&#x2F;?id=7d5f0b7e3613f8e8be84ac0d541a7bbcb4782f1d" rel="nofollow">http:&#x2F;&#x2F;www.kylheku.com&#x2F;cgit&#x2F;txr&#x2F;commit&#x2F;?id=7d5f0b7e3613f8e8b...</a>
评论 #22107149 未加载
评论 #22105296 未加载
aerovistaeover 5 years ago
Seen this posted here years ago. Now as then, my gut feeling is that anyone doing serious work in C would never use something like this-- I feel like the fine grained low level control is exactly the reason they chose C in the first place, and they&#x27;re not looking to escape from it or they would just choose a different language.
评论 #22102751 未加载
评论 #22103065 未加载
评论 #22103718 未加载
评论 #22103738 未加载
评论 #22108932 未加载
评论 #22103279 未加载
analog31over 5 years ago
This is just an amusing aside: C is the lowest level of an actual cello. ;-)
评论 #22103493 未加载
drongokingover 5 years ago
Isn&#x27;t this sort of what Glib is getting at? Bringing higher level data structures and capabilities (extendable arrays, hash tables, heaps, etc.) into C.<p><a href="https:&#x2F;&#x2F;developer.gnome.org&#x2F;glib&#x2F;stable&#x2F;glib-data-types.html" rel="nofollow">https:&#x2F;&#x2F;developer.gnome.org&#x2F;glib&#x2F;stable&#x2F;glib-data-types.html</a><p>You don&#x27;t get Cello&#x27;s macros, and it uses reference counting instead of invisible garbage collection, but you get a lot of fun high-level capabilities.
评论 #22104365 未加载
winridover 5 years ago
There was a snippet I saw a while ago where someone made C look like Java for a joke, using macros. I wish I could find it to share here, it&#x27;s great.
评论 #22106669 未加载
评论 #22103141 未加载
评论 #22103323 未加载
gokover 5 years ago
Previously <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14091630" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14091630</a>
评论 #22102788 未加载
kazinatorover 5 years ago
I&#x27;m left wondering about the iteration example that is also quoted in the home page:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;orangeduck&#x2F;Cello&#x2F;blob&#x2F;master&#x2F;examples&#x2F;iteration.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;orangeduck&#x2F;Cello&#x2F;blob&#x2F;master&#x2F;examples&#x2F;ite...</a><p>Okay, so the vector is garbage-collectable once the function terminates ... but it has references to stack-allocated integers i0, i1 and i2. That leaves me wondering: won&#x27;t the GC walk these and trample on stack memory that has been deallocated&#x2F;reused.<p>(Maybe those integer values have a tag right in the <i>val</i> pointer that gets the GC to avoid dereferencing them.)
noncomlover 5 years ago
Just my opinion, don&#x27;t mean to be inflammatory, but if the user has to know and manually manage stack vs heap objects, then I wouldn&#x27;t call it &quot;High Level&quot; language.
评论 #22102996 未加载
评论 #22102976 未加载
rs23296008n1over 5 years ago
Didn&#x27;t C++ start out as a set of hacks on C? Fairly sure it was originally a preprocess stage ahead of an ordinary c compiler.<p>Raises the question of how usefully far you can make C twist using macros &#x2F; preprocessor.<p>Candidates like Forth or Lisp seem possible. A few weekends at most. Might need to take a few liberties.<p>Python... Perhaps if you implement a less dynamic subset? Duck typing may trip you up. To what extent?<p>What about Elixir?
评论 #22104726 未加载
评论 #22105027 未加载
scouttover 5 years ago
Thanks. I didn&#x27;t know about this library. Interesting, but perhaps I am missing something... about stack &quot;allocation&quot;:<p><pre><code> var i0 = $(Int, 5); </code></pre> vs<p><pre><code> int i0[5]; </code></pre> In both cases it doesn&#x27;t need GC. What would be the reasons for redefining it? I wonder how it couples with local <i>static</i> variables.
shmerlover 5 years ago
Is it using macros to achieve that?
self_awarenessover 5 years ago
For a different take for &quot;better C&quot;, try Zig language, it looks pretty cool.<p><a href="https:&#x2F;&#x2F;ziglang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;</a>
loegover 5 years ago
This gets reposted every couple years and it&#x27;s still bad for all of the same reasons.<p>It&#x27;s not higher level than C in the sense that you get any additional safety guarantees or real beneficial abstractions. If you are fine without the safety but want abstractions, use C++. If you want safety and abstractions, use Rust or Go or Zig. If you really want a transpile-to-C language, you&#x27;ve got Nim.<p>Finally, it&#x27;s not good at being C; everything it does is poor practice and should be quickly recognized as such by experienced C developers, IMO. It&#x27;s got no developer community and no real-world production consumers.
h0bziiover 5 years ago
What type of sorcery is this?
评论 #22102940 未加载
FpUserover 5 years ago
This is great. It made me smile.
tucziover 5 years ago
Why not just C++?
评论 #22102724 未加载
评论 #22104063 未加载
einpoklumover 5 years ago
This isn&#x27;t a library, it&#x27;s a sort-of-a-modification of C, it seems.<p>Well, for a non-C language with high-level abstractions that lets me use C code relatively seamlessly - I&#x27;m content with C++. Many complain about its complexity, but you can actually avoid a lot of that complexity in _your_ code using facilities with complex implementation but relatively easy use.
reanimusover 5 years ago
Looks interesting, but I can&#x27;t help but notice they&#x27;re distributing their source tarball via that site, and it doesn&#x27;t have HTTPS. I don&#x27;t understand why projects don&#x27;t have SSL certs these days, especially considering Let&#x27;s Encrypt has automated it all and made it free.