Hacker News new | ask | show | jobs
by shabble 4107 days ago
> No major language implementation that I'm aware of compiles to assembly.

I believe 'gcc -S' would demonstrate not. If my understanding is correct, it produces essentially asm internally regardless of that flag, but subsequently assembles and links it without presenting it externally, -S just makes it stop and dump the asm.

No idea about other C compilers, but it wouldn't surprise me if they have some similar feature.

2 comments

It is very common not just for C compilers, but for a long range of other compilers.

So common that it is unclear to me which of producing textual asm output or machine code is most common. Certainly there's been periods were the attitude was that producing machine code directly was unnecessarily complex and didn't belong in the compiler.

Correct. GCC always produces assembly and shells out to as; Clang originally did the same, but now goes straight from an internal representation to machine code by default, with the old behavior as a flag. Not sure about other compilers.

In addition to being wrong, the parent's point is also incredibly nitpicky.

Yes I've been reading a bit about GCC and yes, turns out I was very wrong. I'm sorry that my comment sounded overly critical, I was actually trying to defend JS and opposing the idea that somehow "we need to fix JS". Having said that, I can see why there exists a need for "compiling" from other languages to JS - the latter being the only alternative when it comes to running code in a browser - even though personally I consider it unnecessary overhead.