A Separate and Simpler C89 Build

Now and again the idea comes up to switch to take C99 features for granted, given that standard is now... over 20 years old.

The principal benefit of stepping up from C89 to C99 is in libRebol, so that it automatically terminates the variadic APIs. It is a SIGNIFICANT benefit!

As libRebol usage is on the rise, I'm finding my productivity adversely affected by the usability factors of not having termination be implicit. It's easy to make mistakes, kind of like messing up a printf()'s arguments...but a worse version of that, because of how nested libRebol expressions often are.

But even more importantly: I don't think the truly innovative aspects of the API show off as well when they are contaminated with the rebEND "tics" and other workarounds. That makes me sad. :crying_cat_face:

Is it Time for a Compromise?

As the system has become more granular with ~30 extensions, it gets easier to pick some of those as "C99 and above only". For instance: what C89-only system can run ZeroMQ...which presumably can't be built for such a system in the first place?

But some extensions are mandatory to get a baseline usable system. You can't do much without file I/O. So if a system supports C89 and POSIX it seems disingenuous to say "There's no FILESYSTEM extension, but you can still compile the core..."

Right now I'm dealing with the suboptimal situation of expressing the C portion of the "rich console" in C89. And it makes me wonder:

Could we say that C89 platforms work, but just don't have a rich console? e.g. they would read one line at a time with scanf(), run it, and print the result out with printf().

Hence in a C89 build, you would un-include the "modern" CONSOLE extension and use the CONSOLE-C89 extension, or somesuch. This would have the advantage of keeping us from making the modern codebase look like it's contaminated with archaic concerns. We don't at this point have any platforms or clients that are "real" that only have C89...and I gather if we did, people would be happy to have scripts run on them at all.

In the near term, the odds are we're only going to be seeing these C89 build modes on Travis or wherever we force the issue... as a matter of principle. We could also say "to heck with it, don't waste the time up front...let someone else do it if and when it comes up". But I think I'd rather keep it going.

I just want us to be putting our best face forward with the code most people see and hack on. And it's pretty clear that C89 isn't giving us that (due to fundamentally missing the feature of variadic macros).

(FWIW, pre-C99 compilers did often support variadic macros... but with a gnarly non-standard syntax that only worked in their compiler. So it's not unlikely that someone could hack in a way to make libRebol work on their older compilers without rebEND, if they were motivated...or just do a little custom preprocessing step of their own.)

3 Likes