102 points · by dustingetz · 14y ago · 33 comments
Go Python! ;-)
autogenerated C is used sometimes for complex conditional nestings. in some failure situations it is programmatically more efficient or easier to trace issues if every condition is enumerated
In any case, programs that generate code is, at least for me, a code smell.
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.
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
I'm a big fan of functional and otherwise dynamic language, but if I had to write my own Mars-landing controller, I would use C. No doubt there.
C is a good choice for code generation, as a replacement for Assembler. But I would never dare write mars landing code in C directly.
I guess the curiosity team used several languages destined for a 100% verified C compiler for a well defined subset of C.
Why not? I used to write code for airborne radars directly in C, so I may have a different perspective.
http://www.cs.virginia.edu/~jck/publications/Xiang.Yin.disse...
C let's you code at a level that is extremely close to the underlying machine language. If you are an experienced embedded developer you'll know exactly what code you are producing for the particular processor you happen to be working with.
I would not venture a guess, but I would not be surprised if the overwhelming majority of real-time, mission-critical systems out there are coded in C. The only other language I would consider would be Forth --which I have used extensively. I have played with the idea of going to something like C++. I have never found it to make sense in the context of a resource and horsepower-limited embedded system.
I don't know where the distain for C comes from. Yes, I am aware of the issues on can run into by writing unsafe code. Isn't part of our job to write safe code? I certainly do.
Because it's fascinating.
Its not the same old bullshit minutiae over-hyped as the latest and greatest thing, it's honestly a feat of human achievement. It means different things to different people. Creating inspiration, awe, and wonder. It shapes opinions on humanity, tech and life.
But forget all that for a second, and the intimate technical details of how things come together are still interesting to techy people. Even the logistics and implementation of traffic lights can tickle our curiosity. This thing is on another planet!
You sound like someone who has never built anything for just for fun.