Hacker News new | ask | show | jobs
by tobltobs 4102 days ago
Following your logic, all "masters" should code in assembler?
1 comments

No major language implementation that I'm aware of compiles to assembly. Maybe you are referring to machine language and/or bytecode, which are not targeted at humans, so the 'masters' should not code in them because the 'masters' are humans. Advanced Javascript has many capabilities such as first-class functions and great introspection because of the way objects are. The fact that there is a lot of shitty js code around doesn't make js a shitty language, just like the tons of shitty C from our Commodore-64-childhood don't make C a shitty language.
> 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.

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.