nullplan wrote:So, I guess what I'm asking is: Did you just re-invent a high-level assembler? Because C started with that idea in the late 70ies and look where it is now.
Lots of people love to think of C as a high-level assembler, (including myself,) but it started out with modifications of an interpreted language. Around 1969, Ken Thompson took BCPL and adapted it to his minimalist tastes, producing B. Using B, Thompson, Dennis Ritchie, and others found certain tasks would be much more convenient with a type system, and I guess they wanted the performance of a compiled system, so Ritchie produced the first C compiler. I don't think Unix was translated to C for 2 or 3 years. (Somewhere, I have a copy of Ritchie's own writings on the origin of C. I'll share it when I find it.)
I guess the tradition of using C as a high-level assembler took shape in the 80s & 90s with the slow conversion of assembly-language programmers to C. I know many programmers didn't want to convert, thinking all high-level languages hopelessly inefficient for the small computers they worked on. Change happened inexorably, Fortran C and Pascal displaced assembler, and C displaced the other two, perhaps because it's more structured than Fortran and more low-level than Pascal. Fortran's lack of structure made it the bad boy of the bunch, but it was for a time considered the fastest language. Pascal was just too prissy; "Real programmers don't eat quiche."
All along, a major driving force was the connection in the minds of many programmers between low-level coding and efficiency, which was a very strong belief whether it was true or not. The belief was no doubt reinforced by the obvious gross inefficiencies of so much 90s software. Here's an interesting article on the inherent
inherent inefficiencies of object-oriented languages. In the 90s, ignoring these problems, OO became a sort of God worshipped for the wonderous benefits it would miraculously bestow. In some circles you couldn't speak a bad word about OO! Of course, Real Programmers couldn't stand it, but, distrusting this ridiculous propaganda, they kept to their own doctrine of low-level = good, and made C fit their purposes. They needed a high-level language, even a structured one, because they're writing more complex programs for more complex machines, but hardcore subcultures keep the hardcore spirit. (I'm looking back as someone who was recently a member of such a subculture.
) It's funny how the roots of the subculture have been forgotten; they once considered both C and Unix as bloated and slow.
Anyway, I think I've drifted way off topic even though I'm not sure what the topic even is any more!
I do know that some of the points raised on the original topic made me worry, possibly without reason. You just have to know the ABI your compiler conforms to, don't you? Given that, you could easily generate offsets from the C struct declaration. Write a script in Perl or whatever, run it from the makefile... Any thoughts of portability here merely consist of supporting the various different ABIs your compilers may produce, not some mystic version of "code quality".