162 points · by graderjs · 4y ago · 85 comments
https://news.ycombinator.com/item?id=6047576
https://news.ycombinator.com/item?id=14091630
https://news.ycombinator.com/item?id=8799070
https://news.ycombinator.com/item?id=22102533
https://news.ycombinator.com/item?id=10526159
https://news.ycombinator.com/item?id=19665596
https://news.ycombinator.com/item?id=11912427
This shows up periodically and it looks pretty nightmarish (~15 years reading and writing C). If you want this kind of abstraction, I think you're better served by any of the dynamically-typed scripting languages.
I stumbled across this when a new chapter of crafting interpreters came out, and I ended up doing a deep dive into how to speed up CPython. My conclusion was that it wouldn’t be possible without rearchitecture of the fundamental types, and hence unpalatable, but a fun exercise none the lesser
If you’d be wrong to so quick to dismiss Cello. Cello is an order of magnitude quicker than python, even cython can only achieve 3x on CPython without annotation. The ideas behind Cello put it somewhere around JavaScript speed, but far more extendable, and definitely worthy of further investigation.
To expand further, fat pointers (void type, void data) could be superior to NaN boxing, and I’m not aware of any interpreted languages that have seriously implemented fat pointers, but it seems to be going well for Rust.
Have a look at PicoLisp. It has less than a handful of data types but i uses "Tag Bits". Julia is not really interpreted but it uses pointer tags for union types to save on boxing?
This seems to be different enough you may as well just use another language.
Sure, if you're going to do greenfield software development, and you don't absolutely need to kind of closeness to the metal (not just performance, but direct access) that C offers, then use something else (Rust, Zig, Go ... if you need to compile to native binaries, Java, C# & their myriad of variants if you don't).
But if you have to use C, to extend an existing project, use a specific library, or hook some other system... why not use Cello?
For sure, this is not a tight black-box abstraction, so you should strive to understand the semantics of how it works. Once you do though, it'll make your life a whole lot simpler.
I’m using it right now at work to build our firmware for our custom embedded board. It’s been brilliant: ESP-IDF is all C (mostly, some C++ but it all has C interfaces too) and wrapping, extending, calling and integrating into those has been a breeze.
In fact, today, I needed to be able to call the `esp_pthreads.h` functions (which describe some ESP32-specific extensions to it's pthread layer) and it took me, no joke, 5 minutes to wrap.
Pass the header through c2nim, add `{.importc, header: "esp_pthreads.h".}` pragmas to the proc definition, and done. Now I can call them without issue. Its liberating for sure!
That said, you can even wrap C++ if need be, though it's less elegant at times.
Seems to me, Cello would be more for those C programmers that didn't want to try the various alternative languages that are now out, and happen to agree with its developer's interpretation of preferred higher level abstractions and what they should look like. The point of these alternative languages is to offer features that C doesn't have or to implement them in easier or clearer ways.
I like V, nim, Zig, etc, but I just want a language that use the same idioms of C, with the same syntax flavor, without all the complexities of C++ (templates, inheritance, etc). I don't want complex, new features that new languages offer.
From the next release you will be even able to import C into D. https://dlang.org/changelog/2.099.0.html#__import
Vlang is the most simple in your list – it is a different syntax, but not much more complex than C.
But, I think all the macro magic in libcelli is a bit much.
The article shows it with syntax highlighting, that I could only guess wouldn’t actually work.
But also C isn't just for Intel, x86 and (some) ARM CPUs, there are other targets it has.
But although google has killed 264 projects so far [1], I believe that Go has too many dependents at Google and in industry to cancel. And even if it should happen anyway, the community will fork it.