News for hackers. Stuff that matters.
Re:The C juggernaut illustrated (2012) by gavinhoward on Saturday February 04, 2023 @07:18PM (#34660040)
I agree.

I think Zig is the best at pretending to operate with C, but it's still pretend. You need to do special stuff to interoperate with C.

Disclaimer: I'm biased because I'm trying make a C killer even better than Zig is.

Re:The C juggernaut illustrated (2012) by andrewmcwatters on Saturday February 04, 2023 @07:29PM (#34660135)
Please share a link if you're able!
Re:The C juggernaut illustrated (2012) by gavinhoward on Saturday February 04, 2023 @11:31PM (#34661878)
Well, it's still a work in progress, but I have some docs.

It's called Yao. The main repo is https://git.yzena.com/Yzena/Yc , which is a monorepo that has other stuff as well.

Yao defines two types of files.

A "package" file defines stuff that a package can export. A package file looks like this: https://git.yzena.com/Yzena/Yc/src/commit/c0ade4cc5b/build.p... .

A "script" file is straight code, like a script. For a package, it is equivalent to `init()` functions for packages in Go. For a program, the main script file is the `main()`. A script file looks like this: https://git.yzena.com/Yzena/Yc/src/commit/c0ade4cc5b/build.r... .

Note: once the compiler/interpreter is at MVP, those two files will be working code. They will be the build scripts of the repo.

Speaking of the build scripts, the language has a way to allow users to define keywords. The build system already uses that to define its own keywords, turning Yao into a build system DSL.

(Yes, the first program written in Yao will be used to build Yao. It's a great test of the language.)

An example file, with explanation comments, is at https://git.yzena.com/Yzena/Yc/src/commit/c0ade4cc5b/src/yao... . All of the docs are at https://git.yzena.com/Yzena/Yc/src/commit/c0ade4cc5b/docs/ya... , but they are mostly design docs.

I think that should be enough links to get you started.

Pay particular attention to the example.y file w.r.t. C interoperability. The basic points are:

* Every function and type is associated with a C symbol, even if overloaded.

* Structs are laid out exactly like C. (There will be another compound type that won't have that guarantee, but it won't be default, and it, too, will have a C ABI.)

* It will have unions and enums like C.

* It will always use the C ABI, defining extensions to it for things like methods, and those definitions will be defined in the spec that every Yao compiler has to adhere to.

* It will always have the option to compile to C. C will be its bootstrap language.

That said, I still think there are many weaknesses in Yao compared to C. I don't have much confidence it will actually be a C killer, mostly because I'm not sure anymore that it is possible to add to C and kill it.