4 ms·
Most of it automatically generated, therefore it is not written in C.
by EdiX 14y ago
Most of it automatically generated, therefore it is not written in C.
- edge17 14y agohuh? it is auto-generated C as described in the post
- jfoutz 14y agoBy that logic, it's written in machine code.
- edge17 14y agono, autogenerated C code means someone (maybe a build script) runs a Python script that generates a bunch of C files, and then the C compiler picks up those files. Those C files exist in the file tree and may be human readable. C files are being generated, not machine code, by some script. Fairly common practice in large C projects that have complex/heavily conditionals where you're less likely to introduce incorrect conditions if you let program logic printf your code to a file
- EdiX 14y agoYou can tell gcc to keep around the assembly files it generates and it is human readable, does it mean that C code compiled with gcc is actually written in assembly? Is the litmus that they are caching the intermediates of the compilation on disk instead of throwing them away and regenerating them every time?
- zvrba 14y agoEarly C++ compilers actually translated C++ source to C source for compilation by C compiler. Does that mean that the original source was C, not C++?
- edge17 14y agono, but there is a guy that wrote some python that prints out C code into a file. that is what auto-generating C code means. the caching of intermediates and regenerating of the C files is the business of the Makefile
- sophacles 14y agoYou are now officially being disingenuous. Stop it. Read the posts and apply thinking skills. A auto-generated means (by definition) programmers did not write the C code, they wrote something else. By ANALOGY (here is a definition with examples, since you seem to not understand analogy: http://grammar.about.com/od/rhetoricstyle/f/qanalogy07.htm http://grammar.about.com/od/rhetoricstyle/f/qanalogy07.htm ), the argument the Curiosity code was written in C, is the same as me saying my C code is actually written in machine code (raw high and low bits), since the machine code is generated by my compiler, even though I actually wrote C.
- edge17 14y agoIt sounds like you are saying that auto-generating refers only to DSL's. Here is an example of a guy writing some code that printf's some C code - http://www.opensource.apple.com/source/zlib/zlib-37.2/zlib/crc32.c http://www.opensource.apple.com/source/zlib/zlib-37.2/zlib/c... FILE *out; out = fopen("crc32.h", "w"); if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, "local const unsigned long FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); This example is in zlib. Whether it's the 'pretty' way to do it or not, this isn't a terribly uncommon thing to see in C code bases. In this case, this is a lookup table. Code is a tool, "auto-generating" code is not some fancy term, all it means is a button was pushed and a bunch of code came out the other end. Having worked on large C codebases, we used to do this sort of stuff all the time. Maybe it's the dumb way of doing things, but when you work on large teams that all maintain the same codebase, dumb and readable is more important than cleverness sometimes.
- 14y ago
- rat87 14y agoA scheme or haskell(or c++) program that is compiled with a compiler that uses c as an intermediate form is still a scheme/haskell/c++ program. Even if the intermediate code is analyzed by a static analyzer or humans(especially if it's not modified, but possibly to some extent even if the intermediate code is slightly modified or used by other intermediate code written by hand) the source language is the actual language.
- eliben 14y agoThis really depends on the kind of code generation being used. There's "dumb" code generation, and there's a DSL. In the "dumb" case, the input is usually some tabular data, and the code generator simply translates it to valid C syntax. It makes sense to say "it was written in C" in this case, although it's a bit moot since this is just data. In the DSL case, the logic is actually coded in a different language, and the code generator translates it to C. Here it would be more difficult to argue that "it was written in C", because C just serves as a compiler intermediate language. Naturally there are levels in between the above two, but the point is that it's difficult to judge without examining the actual module that was auto-generated.
- edge17 14y agotrue, though it's unlikely that you would launch a DSL. far more likely that a lot of the code being generated is lookup tables and the like. engineers that write this sort of fault tolerant related code will do a lot of things the 'dumb' way because it's often less error prone or easier to trace failures. a number of friends work on space related things, and there tends to be an emphasis placed on not being overly clever (i.e. practices like return values being true or false rather than enumerations, etc)