Remix.run Logo
johnisgood 14 hours ago

Nim is a high-level language as well and compiles to C.

the__alchemist 13 hours ago | parent [-]

Odin and Jai are others.

Voycawojka 13 hours ago | parent | next [-]

Does Odin compile to C? I thought it only uses LLVM as a backend

johnisgood 9 hours ago | parent | next [-]

No, Odin does not compile to C. It is a standalone programming language that compiles directly to machine code. It primarily uses LLVM as its backend for compiling to machine code, like you said.

sestep 10 hours ago | parent | prev [-]

Same question but for Jai.

9 hours ago | parent [-]
[deleted]
zem 11 hours ago | parent | prev [-]

chicken scheme compiles to c as well. it's a pretty convenient compilation target, you get to use all the compilers and tool chains out there and you don't add a dependency on llvm

dieggsy 10 hours ago | parent [-]

I love CHICKEN Scheme! Nice to see it mentioned. Though I think it's worth pointing out it compiles to something pretty far from handwritten C, to my understanding. I think this is true of both performance and semantics; for example you can return a pointer to a stack allocated struct from a foreign lambda (this is because chicken's generated C code here doesn't really "return", I think. Not an expert).

Of course you can always drop to manually written C yourself and it's still a fantastic language to interop with C. And CHICKEN 6 (still pre-release) improves upon that! E.g structs and Unions can be returned/passed directly by/to foreign functions, and the new CRUNCH extension/subset is supposed to compile to something quite a bit closer to handwritten C; there are even people experimenting with it on embedded devices.

jrapdx3 8 hours ago | parent | next [-]

Chicken indeed interoperates with C quite easily and productively. You're right that the generated C code is mostly incomprehensible to humans, but compiles without difficulty.

The Chicken C API has functions/macros that return values and those that don't return. The former include the fabulous embedded API (crunch is an altogether different beast) which I've used in "mixed language" programming to good effect. In such cases Scheme is rather like the essential "glue" that enables the parts written in other languages to work as a whole.

Of course becoming proficient in Scheme programming takes time and effort. I believe it's true that some brains have an affinity for Lispy languages while others don't. Fortunately, there are many ways to write programs to accomplish a given task.

zem 9 hours ago | parent | prev [-]

> this is because chicken's generated C code here doesn't really "return", I think. Not an expert.

not an expert either, but you're right about that, it uses cps transformations so that functions never return. there's a nice write up here: https://wiki.call-cc.org/chicken-compilation-process#a-guide...